akoksal commited on
Commit
8046c49
1 Parent(s): 77c5165
Files changed (1) hide show
  1. app.py +26 -23
app.py CHANGED
@@ -30,29 +30,32 @@ def wordtoten(word: str):
30
  wtt += '0'
31
  return wtt
32
 
33
- def spellword(word: str):
34
- word = to_lower(word)
35
- syllable_list = []
36
- tenword = wordtoten(word)
37
- len_spell = tenword.count('1')
38
-
39
- for i in range(tenword.count('1')):
40
- for x, y in SPELL_SLICER:
41
- if tenword.startswith(x):
42
- syllable_list.append(word[:y])
43
- word = word[y:]
44
- tenword = tenword[y:]
45
- break
46
-
47
- if tenword == '0':
48
- syllable_list[-1] = syllable_list[-1] + word
49
- elif word:
50
- syllable_list.append(word)
51
-
52
- if len(syllable_list) != len_spell:
53
- return False
54
-
55
- return "$".join(syllable_list)
 
 
 
56
 
57
  def predict(name, sl, topk, topp):
58
  if name == "":
 
30
  wtt += '0'
31
  return wtt
32
 
33
+ def spellword(word_b: str):
34
+ word_b = to_lower(word_b).strip()
35
+ x = []
36
+ for word in word_b.split():
37
+ syllable_list = []
38
+ tenword = wordtoten(word)
39
+ len_spell = tenword.count('1')
40
+
41
+ for i in range(tenword.count('1')):
42
+ for x, y in SPELL_SLICER:
43
+ if tenword.startswith(x):
44
+ syllable_list.append(word[:y])
45
+ word = word[y:]
46
+ tenword = tenword[y:]
47
+ break
48
+
49
+ if tenword == '0':
50
+ syllable_list[-1] = syllable_list[-1] + word
51
+ elif word:
52
+ syllable_list.append(word)
53
+
54
+ if len(syllable_list) != len_spell:
55
+ return False
56
+
57
+ x.append("·".join(syllable_list))
58
+ return " ".join(x)
59
 
60
  def predict(name, sl, topk, topp):
61
  if name == "":