示例#1
0
def getNearRhymes(inputString):
	rhymes = []
	pron1 = Wordsmith.tokenize(inputString)

	words = Wordsmith.getRelevantWords(inputString)
	if not words:
		return []

	for word in words:
		word = str(word)
		if inputString == word:
			continue
		elif "'" in word:
			continue

		pron2 = Wordsmith.tokenize(word)
		if not pron2:
			continue
		
		score = nearRhymeScore(pron1, pron2)
		if score > 0:
			rhymes.append((word, score))

	
	return sorted(rhymes, key=lambda t: t[1], reverse=True)
示例#2
0
def check(inputString, word):
    if inputString == word:
        return -1

    pron1 = Wordsmith.tokenize(inputString)
    pron2 = Wordsmith.tokenize(word)

    print pron1
    print pron2

    return nearRhymeScore(pron1, pron2)
示例#3
0
def check(inputString, word):
    if inputString == word:
        return -1

    pron1 = Wordsmith.tokenize(inputString)
    pron2 = Wordsmith.tokenize(word)

    print pron1
    print pron2

    return nearRhymeScore(pron1, pron2)
示例#4
0
 def add(self, word):
     stress = Wordsmith.getStress(Wordsmith.tokenize(word))
     if (len(stress) < 1):
         return False
     phone = stress[-1][1]
     if phone not in self.buckets.keys():
         self.buckets[phone] = []
     if not word in self.buckets[phone]:
         self.buckets[phone].append(word)
示例#5
0
	def add(self, word):
		stress = Wordsmith.getStress(Wordsmith.tokenize(word))
		if (len(stress) < 1):
			return False
		phone = stress[-1][1]
		if phone not in self.buckets.keys():
			self.buckets[phone] = []
		if not word in self.buckets[phone]:
			self.buckets[phone].append(word)
示例#6
0
def getNearRhymes(inputString):
    rhymes = []
    pron1 = Wordsmith.tokenize(inputString)

    words = Wordsmith.getRelevantWords(inputString)
    if not words:
        return []

    for word in words:
        word = str(word)
        if inputString == word:
            continue
        elif "'" in word:
            continue

        pron2 = Wordsmith.tokenize(word)
        if not pron2:
            continue

        score = nearRhymeScore(pron1, pron2)
        if score > 0:
            rhymes.append((word, score))

    return sorted(rhymes, key=lambda t: t[1], reverse=True)
示例#7
0
def get_rhyme_score(word1, word2):
    if word1 == word2:
        return 0
    pron1 = Wordsmith.tokenize(word1)
    pron2 = Wordsmith.tokenize(word2)
    return nearRhymeScore(pron1, pron2)
示例#8
0
 def getListFromWord(self, word):
     stress = Wordsmith.getStress(Wordsmith.tokenize(word))
     if (len(stress) < 1):
         return False
     phone = stress[-1][1]
     return self.get(phone)
示例#9
0
	def getListFromWord(self,word):
		stress = Wordsmith.getStress(Wordsmith.tokenize(word))
		if (len(stress) < 1):
			return False
		phone = stress[-1][1]
		return self.get(phone)
示例#10
0
def get_rhyme_score(word1,word2):
    if word1 == word2:
        return 0
    pron1 = Wordsmith.tokenize(word1)
    pron2 = Wordsmith.tokenize(word2)
    return nearRhymeScore(pron1,pron2)