Skip to content

Commit

Permalink
Added Duration and Geo Coordinate parser test
Browse files Browse the repository at this point in the history
  • Loading branch information
Meti-Adane committed Jul 31, 2024
1 parent a65c512 commit 208d2e9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ object DurationParserConfig
"ቀን" -> "day",
"ቀናት" -> "day",
"ቀኖች" -> "day",
"ቀናቶች" -> "day",
"month" -> "month",
"months" -> "month",
"ወር" -> "month",
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*/ "ኪሎሜትር በሰዓት")));
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));
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 @@ -137,6 +137,11 @@ class DurationParserTest extends FlatSpec with Matchers
{
parse("en", "Time", "2002-present") should equal (None)
}
// Teset for amharic
"DurationParser" should "return 14400 seconds for ' el greek'" in
{
parse("el", "Time", " 4 ώρες").get should equal (14400.0)
}

/**
* Matcher to test if 2 values are approximately equal.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class GeoCoordinateParserTest extends FlatSpec with Matchers
{
parse("fr", "51º12'00\"N 03º13'00\"E") should equal (Some(51.2,3.216666666666667))
}

"GeoCoordinateParser({{coord|51.2|N|31.2|E}}" should "return (51.2,31.2)) for French" in
{
parse("fr", "{{coord|51.2|N|31.2|E}}") should equal (Some(51.2,31.2))
Expand All @@ -27,7 +28,10 @@ class GeoCoordinateParserTest extends FlatSpec with Matchers
parse("fr", "{{coord|51/12/N|03/13/E}}") should equal (Some(51.2,3.216666666666667))
}


"GeoCoordinateParser (31º12'00\"N 03º13'00\"E)" should "return (31.2,3.216666666666667))" in
{
parse("am", "31º12'00\"N 03º13'00\"E") should equal (Some(31.2,3.216666666666667))
}
private val wikiParser = WikiParser.getInstance()

private def parse(language : String, input : String) : Option[(Double, Double)] =
Expand Down

0 comments on commit 208d2e9

Please sign in to comment.