added _variants to get_process_pron so that the function can output a…#572
added _variants to get_process_pron so that the function can output a…#572arianacodes wants to merge 1 commit intoCUNY-CL:masterfrom
Conversation
… list or a single string
|
Hi Ariana, thanks for this. You're pretty close here. A bunch of small notes below. TestingI see the
That should at least allow those two tests to clear. You can see on this PR if they're passing or not. If they work for you locally and you check in your changes with those three "verbs", then they ought to work here too. There of course are other tests that will run once these all pass, including unit tests. These steps will also fix some minor style issues; we can address the rest once you have this taken care of. Note that you will probably need to repeat this step later on because subsequent changes you'll make... Typing and designI didn't mention the Here is what I think the simplest possibilty is: you could just lightly redesign the processor interface, on two dimensions:
@staticmethod
def _variants(pron: str) -> List[str]:
# FIXME: put your `variants` function here.
...
def process_pron(self, pron) -> List[str]:
if not self.stress:
pron = re.sub(r"[ˈˌ]", "", pron)
# FIXME: put the other cases here.
...
if self.variants:
return self._variants(pron)
else:
# Just removes parentheses. I moved this here from below...
pron = re.sub(_PARENS_REGEX, "", pron)
return [pron]Note the trick here: if we're not generating variants, we just remove parentheses and make a singleton list!
pron_string = m.group(1)
try:
# All pronunciation processing is done in NFD-space.
pron_string = unicodedata.normalize("NFD", pron_string)
for pron in config.process_pron(pron_string):
if pron:
# The segments package inserts a # in-between spaces.
if not config.skip_spaces_pron:
pron = pron.replace(" #", "")
yield pron
except IndexError:
...Then get rid of I see you modified some of the type signatures in TestingYou can then make sure the You should need to add a unit test under
Last thingMake sure to check changed files every time. Doing so will cause the tests to run again, and once everything is green (i.e., once all tests pass) I can take another look. If you get blocked send me a message. |
|
Oh one other thing: you see in the description of the PR (at the top of the page) where there's a checkbox? Add a brief description of the change being made (just follow the style used there) to the |
… list or a single string
UnreleasedinCHANGELOG.mdto reflect the changes in code or data.