-
Notifications
You must be signed in to change notification settings - Fork 125
Hindi ITN: Telephone, Quarterly Measures, Fraction Exceptions, Changes to Date #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Tarushi V <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: Tarushi V <[email protected]>
Signed-off-by: Tarushi V <[email protected]>
Signed-off-by: Tarushi V <[email protected]>
Signed-off-by: Tarushi V <[email protected]>
Signed-off-by: Tarushi V <[email protected]>
३० तीस | ||
३१ इकतीस | ||
३१ इकतिस | ||
३१ इकत्तीस | ||
३१ इकत्तिस |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have the same term multiple times in this tsv? is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, are these mappings any different than cardinals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
We have the same terms in the TSV file because of different spellings and character differences. I kept all the other versions on purpose because inverse text normalization allows many-to-one mapping. Having all the versions makes it work better and more accurately.
-
I added the numbers used for dates in a separate file because the date semiotic class only needs numbers from 1 to 31. For cardinal numbers, we already have two separate files: one for single digits and another called teens and ties for numbers from 10 to 99. So it was easier and cleaner to create a new TSV file just for dates instead of using the existing cardinal number files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there no way to optimize (1) with rules instead of one long tsv file?
let's use the cardinal graph and restrict inputs to 1-31 for (2), that will be cleaner and easier to maintain in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Numbers 0-99 have unique words in Hindi that cannot be represented by grammars.
- I’ve deleted the date_days.tsv file and updated it to use the cardinal graph instead. The inputs are now restricted to 1–31 as suggested. Will push it as soon as all comments on the PR are resolved.
@@ -0,0 +1,596 @@ | |||
११ one one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's implement graphs to process digits instead of having a long tsv file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this completed? if so, let's remove this file
@@ -0,0 +1,2750 @@ | |||
११ एक एक |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's either try to use the cardinals graph or create a graph for this one as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this completed? if so, let's remove this file
@@ -0,0 +1 @@ | |||
९१ nine one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as for std codes
@@ -0,0 +1 @@ | |||
९१ नौ एक |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as for std codes
@@ -0,0 +1,7 @@ | |||
२ दो |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these any different than cardinals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these are also different from cardinals because landline operator digits are specifically only 2, 3, 4, and 6. In India, landline numbers must start with one of these digits to be valid. The cardinal numbers have a single file, digits.tsv, which contains all numbers from 1 to 9. Since we do not need all these digits for landline operators, it made sense to create a separate TSV file specifically for the landline operator digits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can import the carinal graph and restrict inputs -- this is necessary to optimize upkeep in the future
only create new files when the mapping is different
@@ -23,5 +23,6 @@ | |||
२० बीस |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these any different than cardinals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this TSV file for time is separate because time only requires numbers from 1 to 24. For cardinal numbers, we already have two separate files: one for single digits and another called teens and ties for numbers from 10 to 99. Since the cardinal numbers are split across two files, using one and then extracting only the numbers from 10 to 24 from the other seemed more complex. So it was simpler and cleaner to create a dedicated TSV file for time instead of reusing and modifying the existing cardinal files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as for dates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve deleted the hour.tsv file and updated it to use the cardinal graph instead. The inputs are now restricted to 1–24 as suggested. Will push it as soon as all comments on the PR are resolved.
|
||
|
||
def load_column_from_tsv(filepath, column_index=1): | ||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this necessary? doesn't pynini have a function to get the inputs or outputs only?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used load_column_from_tsv because it reads just one column from the TSV file and gives a list of STD codes. This list is needed to build the telephone FST with those codes and landline numbers.
Pynini has functions like string_file that load the whole TSV file as one big FST with all pairs together. You can get inputs or outputs by inverting the FST, but these work on FSTs that are already made, not directly on the file.
When I tried replacing load_column_from_tsv with string_file, I got an error. It was harder to get a list of codes from the big FST than just using load_column_from_tsv, which gives the list straight away.
So, using load_column_from_tsv was easier and simpler, especially with a big database where I needed the full list of STD codes. That’s why I decided to use load_column_from_tsv.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please reimplement with pynini.project
as used here
era_names = pynini.project(era_words, "output") |
९८ निन्यान्बे | ||
९८ निन्यानबे | ||
९८ निन्यानवे | ||
९८ निन्यान्वे |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also either leverage cardinal graph or optimize with rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use the cardinal graph here because the number mapping is completely different for this particular TSV file. Also, numbers 0-99 have unique words in Hindi that cannot be represented by grammars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you saying that the "9" in 93 is a different word than the "9" in 94? what about the "4" in 34 vs the "4" in 74?
@@ -9,6 +9,7 @@ | |||
१७ सत्रह | |||
१७ सतरह |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's also optimize with rules
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Numbers 0-99 have unique words in Hindi that cannot be represented by grammars.
Signed-off-by: Tarushi V <[email protected]>
a328412
to
05f6237
Compare
This PR is stale because it has been open for 14 days with no activity. Remove stale label or comment or update or this will be closed in 7 days. |
This PR was closed because it has been inactive for 7 days since being marked as stale. |
Adds Hindi ITN support for the Telephone semiotic class, mixed/exception fractions, quarterly measures, and century ordinals in the Date class. Includes all updates, test cases, and rebase with the latest upstream changes.
Before your PR is "Ready for review"
Pre checks:
git commit -s
to sign.pytest
or (if your machine does not have GPU)pytest --cpu
from the root folder (given you marked your test cases accordingly@pytest.mark.run_only_on('CPU')
).bash tools/text_processing_deployment/export_grammars.sh --MODE=test ...
pytest
and Sparrowhawk here.__init__.py
for every folder and subfolder, includingdata
folder which has .TSV files?Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
to all newly added Python files?Copyright 2015 and onwards Google, Inc.
. See an example here.try import: ... except: ...
) if not already done.PR Type:
If you haven't finished some of the above items you can still open "Draft" PR.