-
Notifications
You must be signed in to change notification settings - Fork 182
Hi TN: percent (measure class) and time bug fixes #483
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
base: staging/hi_tn_v4
Are you sure you want to change the base?
Changes from all commits
66ee78e
4e60c63
5f4b14e
bc55e56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,4 +142,5 @@ mi/hr मील प्रति घंटा | |
| mi/min मील प्रति मिनट | ||
| ₹/ac रुपए प्रति एकड़ | ||
| x बाई | ||
| * बाई | ||
| * बाई | ||
| % प्रतिशत | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -228,9 +228,21 @@ def __init__(self, cardinal: GraphFst, decimal: GraphFst, ordinal: GraphFst, ser | |
| year_informal = pynini.string_map([("yr", "साल")]) | ||
| year_formal = pynini.string_file(get_abs_path("data/measure/unit_year_formal.tsv")) | ||
|
|
||
| # All units EXCEPT year | ||
| unit_inputs_except_yr = pynini.difference(pynini.project(unit_graph, "input"), pynini.accep("yr")) | ||
| unit_graph_no_year = pynini.compose(unit_inputs_except_yr, unit_graph) | ||
| # All units EXCEPT year and percent | ||
| unit_inputs_regular = pynini.difference( | ||
| pynini.project(unit_graph, "input"), pynini.union(pynini.accep("yr"), pynini.accep("%")) | ||
| ) | ||
| unit_graph_no_year = pynini.compose(unit_inputs_regular, unit_graph) | ||
|
|
||
| percent_graph = pynini.compose(pynini.accep("%"), unit_graph) | ||
|
|
||
| percent_unit = ( | ||
| pynutil.insert(NEMO_SPACE) | ||
| + pynutil.insert("units: \"") | ||
| + percent_graph | ||
| + pynutil.insert("\"") | ||
| + pynutil.insert(NEMO_SPACE) | ||
| ) | ||
|
|
||
| # Load quarterly units from separate files: map (FST) and list (FSA) | ||
| quarterly_units_map = pynini.string_file(get_abs_path("data/measure/quarterly_units_map.tsv")) | ||
|
|
@@ -454,14 +466,37 @@ def __init__(self, cardinal: GraphFst, decimal: GraphFst, ordinal: GraphFst, ser | |
| + pynutil.insert("\"") | ||
| ) | ||
|
|
||
| graph_cardinal_percent = ( | ||
| pynutil.insert("cardinal { ") | ||
| + optional_graph_negative | ||
| + pynutil.insert("integer: \"") | ||
| + cardinal_graph | ||
| + pynutil.insert("\"") | ||
| + pynutil.insert(NEMO_SPACE) | ||
| + pynutil.insert("}") | ||
| + pynini.closure(delete_space, 0, 1) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. delete_space is already a closure, so we might not need this, right? |
||
| + percent_unit | ||
| ) | ||
|
|
||
| graph_decimal_percent = ( | ||
| pynutil.insert("decimal { ") | ||
| + optional_graph_negative | ||
| + decimal_graph | ||
| + pynutil.insert(" }") | ||
| + pynini.closure(delete_space, 0, 1) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| + percent_unit | ||
| ) | ||
|
|
||
| address_graph = self.get_address_graph(cardinal, ordinal, serial, input_case) | ||
| structured_address_graph = self.get_structured_address_graph(cardinal, ordinal, input_case) | ||
|
|
||
| graph = ( | ||
| pynutil.add_weight(graph_decimal, 0.1) | ||
| | pynutil.add_weight(graph_decimal_year_formal, 0.1) | ||
| | pynutil.add_weight(graph_decimal_percent, 0.1) | ||
| | pynutil.add_weight(graph_cardinal, 0.1) | ||
| | pynutil.add_weight(graph_cardinal_year_formal, 0.1) | ||
| | pynutil.add_weight(graph_cardinal_percent, 0.1) | ||
| | pynutil.add_weight(graph_cardinal_year_informal, -0.1) # Higher priority for small numbers | ||
| | pynutil.add_weight(graph_exceptions, 0.1) | ||
| | pynutil.add_weight(graph_dedh_dhai, -0.2) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,4 +66,6 @@ | |
| ५ yr~पाँच साल | ||
| 1.5 yr~डेढ़ साल | ||
| २.५ yr~ढाई साल | ||
| 3.5 yr~साढ़े तीन साल | ||
| 3.5 yr~साढ़े तीन साल | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add |
||
| 100%~एक सौ प्रतिशत | ||
| ५०.५० %~पचास दशमलव पाँच शून्य प्रतिशत | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,4 +15,6 @@ | |
| दोपहर के 3:00~दोपहर के तीन बजे | ||
| रात के १०:४८:५०~रात के दस बजकर अड़तालीस मिनट पचास सेकंड | ||
| रात के 11:50~रात के ग्यारह बजकर पचास मिनट | ||
| रात के ८:००~रात के आठ बजे | ||
| रात के ८:००~रात के आठ बजे | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add test cases to make sure we restrict mixed scripts and malformed times |
||
| आज सुबह ०९:१५ बजे~आज सुबह सवा नौ बजे | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add |
||
| 08:00~आठ बजे | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's add |
||
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 make this a tsv file just in case we want to add in the future