Spaces:
Sleeping
Sleeping
Yarik
commited on
Commit
•
5ded30a
1
Parent(s):
58373da
Add application file
Browse files- accentor.py +23 -6
accentor.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from ukrainian_word_stress import StressSymbol
|
2 |
from ukrainian_accentor_transformer import Accentor
|
3 |
|
4 |
def stress_replace_and_shift(stressed: str):
|
@@ -22,15 +22,32 @@ def stress_replace_and_shift(stressed: str):
|
|
22 |
break
|
23 |
return new_stressed
|
24 |
|
|
|
25 |
accentor_transformer = Accentor()
|
26 |
|
27 |
-
def accentification(sentence: str):
|
28 |
-
|
29 |
-
|
30 |
sentence = sentence.replace(
|
31 |
StressSymbol.CombiningAcuteAccent, ""
|
32 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
accented_sentence = accentor_transformer(sentence)
|
35 |
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from ukrainian_word_stress import StressSymbol, Stressifier
|
2 |
from ukrainian_accentor_transformer import Accentor
|
3 |
|
4 |
def stress_replace_and_shift(stressed: str):
|
|
|
22 |
break
|
23 |
return new_stressed
|
24 |
|
25 |
+
stressify = Stressifier(stress_symbol=StressSymbol.CombiningAcuteAccent)
|
26 |
accentor_transformer = Accentor()
|
27 |
|
28 |
+
def accentification(sentence: str, mode: str):
|
29 |
+
if (mode != "none"):
|
30 |
+
sentence = sentence.replace("+", "")
|
31 |
sentence = sentence.replace(
|
32 |
StressSymbol.CombiningAcuteAccent, ""
|
33 |
)
|
34 |
+
if (mode == "vocab"):
|
35 |
+
accented_sentence = stressify(sentence)
|
36 |
+
elif (mode == "model"):
|
37 |
+
accented_sentence = accentor_transformer(sentence)
|
38 |
+
else:
|
39 |
+
accented_sentence = sentence
|
40 |
+
return accented_sentence
|
41 |
|
|
|
42 |
|
43 |
+
|
44 |
+
# def accentification(sentence: str):
|
45 |
+
#
|
46 |
+
# sentence = sentence.replace("+", "")
|
47 |
+
# sentence = sentence.replace(
|
48 |
+
# StressSymbol.CombiningAcuteAccent, ""
|
49 |
+
# )
|
50 |
+
#
|
51 |
+
# accented_sentence = accentor_transformer(sentence)
|
52 |
+
#
|
53 |
+
# return accented_sentence
|