Skip to content
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

[GSOC'24 Amharic chapter] Add Amharic configurations for duration parser #764

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,57 @@ object DurationParserConfig
"years" -> "year",
"yr" -> "year"
),
"am" -> Map(
"second" -> "second",
"s" -> "second",
"sec" -> "second",
"seconds" -> "second",
"secs" -> "second",
"\"" -> "second",
"ሰከንድ" -> "second",
"ሴኮንድ" -> "second",
"ሴኮንዶች" -> "second",
"minute" -> "minute",
"m" -> "minute",
"min" -> "minute",
"minutes" -> "minute",
"min." -> "minute",
"mins" -> "minute",
"minu" -> "minute",
"'" -> "minute",
"ደቂቃ" -> "minute",
"ደቂቃዎች" -> "minute",
"hour" -> "hour",
"h" -> "hour",
"hours" -> "hour",
"hr" -> "hour",
"hr." -> "hour",
"hrs" -> "hour",
"hrs." -> "hour",
"ሰአት" -> "hour",
"ሰዓታት" -> "hour",
"ሰዓት" -> "hour",
"day" -> "day",
"d" -> "day",
"d." -> "day",
"days" -> "day",
"ቀን" -> "day",
"ቀናት" -> "day",
"ቀኖች" -> "day",
"ቀናቶች" -> "day",
"month" -> "month",
"months" -> "month",
"ወር" -> "month",
"ወራት" -> "month",
"ወሮች" -> "month",
"year" -> "year",
"y" -> "year",
"years" -> "year",
"yr" -> "year",
"አመት" -> "year",
"ዓመት" -> "year",
"ዓመታት" -> "year"
),
// For "ar" configuration, rendering right-to-left may seems like a bug, but it's not.
// Don't change this else if you know how it is done.
Meti-Adane marked this conversation as resolved.
Show resolved Hide resolved
"ar" -> Map(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,9 @@ object OntologyDatatypes
types :::= builder.build

builder.addDimension("Speed");
builder.addUnit(new StandardUnitDatatype("kilometrePerHour", Set("km/h","kmh","kilometre per hour",/*el*/ "χιλιόμετρα ανά ώρα")));
builder.addUnit(new StandardUnitDatatype("kilometrePerHour", Set("km/h","kmh","kilometre per hour",/*el*/ "χιλιόμετρα ανά ώρα", /*am*/ "ኪሎሜትር በሰዓት")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kilometer vs kilometre, and plural vs singular vary regionally (not just by language). This might need to be more complicated...

Suggested change
builder.addUnit(new StandardUnitDatatype("kilometrePerHour", Set("km/h","kmh","kilometre per hour",/*el*/ "χιλιόμετρα ανά ώρα", /*am*/ "ኪሎሜትር በሰዓት")));
builder.addUnit(new StandardUnitDatatype("kilometersPerHour", Set("km/h","kmh","kilometers per hour",/*el*/ "χιλιόμετρα ανά ώρα", /*am*/ "ኪሎሜትር በሰዓት")));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could add both versions in the list to accommodate both variations

builder.addUnit(new FactorUnitDatatype("metrePerSecond", Set("m/s","ms","metre per second"), 3.6));
builder.addUnit(new FactorUnitDatatype("kilometrePerSecond", Set("km/s","kilometre per second"), 3600.0));
builder.addUnit(new FactorUnitDatatype("kilometrePerSecond", Set("km/s","kilometre per second", /*am*/ "ኪሎሜትር በሰከንድ"), 3600.0));
builder.addUnit(new FactorUnitDatatype("milePerHour", Set("mph","mi/h","mile per hour"), 1.60934));
builder.addUnit(new FactorUnitDatatype("footPerSecond", Set("ft/s","foot per second"), 0.0003048333333));
builder.addUnit(new FactorUnitDatatype("footPerMinute", Set("ft/min","foot per minute"), 0.01829));
Expand All @@ -469,21 +469,21 @@ object OntologyDatatypes

builder.addDimension("Temperature");
builder.addUnit(new StandardUnitDatatype("kelvin", Set("K","kelvin",/*el*/ "Κ","κέλβιν")));
builder.addUnit(new FactorUnitDatatype("degreeCelsius", Set("°C","degree celsius","C","Celsius",/*el*/ "βαθμοί"), 1.0, 273.15));
builder.addUnit(new FactorUnitDatatype("degreeCelsius", Set("°C","degree celsius","C","Celsius",/*el*/ "βαθμοί", /*am*/ "ሴልሲየስ"), 1.0, 273.15));
builder.addUnit(new FactorUnitDatatype("degreeFahrenheit", Set("°F","F","Fahrenheit","degree fahrenheit"), 5.0 / 9.0, 459.67));
builder.addUnit(new FactorUnitDatatype("degreeRankine", Set("°R","R","degree rankine"), 5.0 / 9.0, 0));
Comment on lines +472 to 474
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
builder.addUnit(new FactorUnitDatatype("degreeCelsius", Set("°C","degree celsius","C","Celsius",/*el*/ "βαθμοί", /*am*/ "ሴልሲየስ"), 1.0, 273.15));
builder.addUnit(new FactorUnitDatatype("degreeFahrenheit", Set("°F","F","Fahrenheit","degree fahrenheit"), 5.0 / 9.0, 459.67));
builder.addUnit(new FactorUnitDatatype("degreeRankine", Set("°R","R","degree rankine"), 5.0 / 9.0, 0));
builder.addUnit(new FactorUnitDatatype("degreesCelsius", Set("°C","degrees celsius","C","Celsius",/*el*/ "βαθμοί", /*am*/ "ሴልሲየስ"), 1.0, 273.15));
builder.addUnit(new FactorUnitDatatype("degreesFahrenheit", Set("°F","F","Fahrenheit","degrees Fahrenheit"), 5.0 / 9.0, 459.67));
builder.addUnit(new FactorUnitDatatype("degreesRankine", Set("°R","R","degrees Rankine"), 5.0 / 9.0, 0));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, using degrees instead of degree is more accurate

types :::= builder.build

builder.addDimension("Time");
builder.addUnit(new StandardUnitDatatype("second", Set("s","sec","secs","second","seconds",/*el*/ "δ","δευτερόλεπτα")));
builder.addUnit(new StandardUnitDatatype("second", Set("s","sec","secs","second","seconds",/*el*/ "δ","δευτερόλεπτα", /*am*/ "ሴኮንድ")));
//Add commonly used fractions of second
builder.addUnit(new FactorUnitDatatype("millisecond", Set("ms","millisecond","milliseconds"), 0.001));
builder.addUnit(new FactorUnitDatatype("microsecond", Set("µs","microsecond","microseconds"), 1.0E-6));
builder.addUnit(new FactorUnitDatatype("nanosecond", Set("ns","nanosecond","nanoseconds"), 1.0E-9));
// end of fractions
builder.addUnit(new FactorUnitDatatype("minute", Set("m","min","min.","mins","minute","minutes",/*el*/ "λ","λεπτά"), 60.0));
builder.addUnit(new FactorUnitDatatype("hour", Set("h","hr","hr.","hour","hours","std",/*el*/ "ω","ώρες","ώρα"), 3600.0));
builder.addUnit(new FactorUnitDatatype("day", Set("d","days","day",/*el*/ "μ","μέρα","μέρες"), 86400.0));
builder.addUnit(new FactorUnitDatatype("minute", Set("m","min","min.","mins","minute","minutes",/*el*/ "λ","λεπτά", /*am*/ "ደቂቃ", "ደቂቃዎች"), 60.0));
builder.addUnit(new FactorUnitDatatype("hour", Set("h","hr","hr.","hour","hours","std",/*el*/ "ω","ώρες","ώρα", /*am*/ "ሰዓት", "ሰዓታት"), 3600.0));
builder.addUnit(new FactorUnitDatatype("day", Set("d","days","day",/*el*/ "μ","μέρα","μέρες", /*am*/ "ቀን", "ቀናት", "ቀኖች", "ቀናቶች"), 86400.0));
types :::= builder.build

builder.addDimension("Torque");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,27 @@ class DurationParserTest extends FlatSpec with Matchers
parse("en", "Time", "2002-present") should equal (None)
}


// Test for Amharic
"DurationParser" should "return 5 seconds for '5 ሴኮንድ'" in
{
parse("am", "Time", "5 ሴኮንድ").get should equal (5.0)
}
"DurationParser" should "return 10 minutes for 'context 10 ደቂቃዎች context'" in
{
parse("am", "Time", "context 10 ደቂቃዎች context").get should equal (600.0)
}
"DurationParser" should "return 14820 seconds for 'context 4 ሰዓት, 7 ደቂቃ context'" in
{
parse("am", "Time", "context 4 ሰዓት, 7 ደቂቃ context").get should equal (14820.0)
}

"DurationParser" should "return 857752817 seconds for '27 ዓመታት, 2 ወራት, 5 ቀናት, 1 ሰዓት 40 ደቂቃ, 17 ሴኮንድ '" in
{
parse("am", "Time", "27 ዓመታት, 2 ወራት, 5 ቀናት, 1 ሰዓት 40 ደቂቃ, 17 ሴኮንድ ").get should be (approximatelyEqualTo(857752817.0))
}


/**
* Matcher to test if 2 values are approximately equal.
*/
Expand Down
Loading