Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
synesthesiam committed Jul 3, 2024
1 parent f2034a0 commit 4586838
Show file tree
Hide file tree
Showing 10 changed files with 707 additions and 284 deletions.
4 changes: 2 additions & 2 deletions gruut-lang-ca/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
"VERSION",
"lexicon.db",
"g2p/model.crf",
#"espeak/lexicon.db",
#"espeak/g2p/model.crf",
# "espeak/lexicon.db",
# "espeak/g2p/model.crf",
]
+ extra_files
},
Expand Down
27 changes: 19 additions & 8 deletions gruut/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ def main():

# -------------------------------------------------------------------------
text_processor = TextProcessor(
default_lang=args.language, model_prefix=args.model_prefix,
default_lang=args.language,
model_prefix=args.model_prefix,
)

if args.debug:
Expand Down Expand Up @@ -131,7 +132,7 @@ def output_sentences(sentences, writer, text_data=None):
for sentence in sentences:
sentence_dict = dataclasses.asdict(sentence)
writer.write(sentence_dict)

for text, text_data in input_text(lines):
try:
graph, root = text_processor(
Expand Down Expand Up @@ -165,7 +166,7 @@ def output_sentences(sentences, writer, text_data=None):
punctuations=(not args.no_punctuation),
)
)

output_sentences(sentences, writer, text_data)

except Exception as e:
Expand Down Expand Up @@ -199,7 +200,9 @@ def get_args() -> argparse.Namespace:

parser.add_argument("text", nargs="*", help="Text to tokenize (default: stdin)")
parser.add_argument(
"--ssml", action="store_true", help="Input text is SSML",
"--ssml",
action="store_true",
help="Input text is SSML",
)
parser.add_argument(
"--stdin-format",
Expand Down Expand Up @@ -230,13 +233,19 @@ def get_args() -> argparse.Namespace:
help="Disable time replacement (4:01pm -> four oh one P M)",
)
parser.add_argument(
"--no-pos", action="store_true", help="Disable part of speech tagger",
"--no-pos",
action="store_true",
help="Disable part of speech tagger",
)
parser.add_argument(
"--no-lexicon", action="store_true", help="Disable phoneme lexicon database",
"--no-lexicon",
action="store_true",
help="Disable phoneme lexicon database",
)
parser.add_argument(
"--no-g2p", action="store_true", help="Disable grapheme to phoneme guesser",
"--no-g2p",
action="store_true",
help="Disable grapheme to phoneme guesser",
)
parser.add_argument(
"--no-punctuation",
Expand All @@ -259,7 +268,9 @@ def get_args() -> argparse.Namespace:
help="Disable post-processing of sentences (e.g., liasons)",
)
parser.add_argument(
"--no-fail", action="store_true", help="Skip lines that result in errors",
"--no-fail",
action="store_true",
help="Skip lines that result in errors",
)

# Miscellaneous
Expand Down
5 changes: 4 additions & 1 deletion gruut/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,10 @@ class PostProcessSentence:
"""Post-process each sentence node after tokenization/phonemization"""

def __call__(
self, graph: GraphType, sentence_node: SentenceNode, settings: typing.Any,
self,
graph: GraphType,
sentence_node: SentenceNode,
settings: typing.Any,
):
pass

Expand Down
Loading

0 comments on commit 4586838

Please sign in to comment.