Repository navigation
Fix Amharic extraction common bugs #846
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
Changes from all commits
c870f5d
9e173d3
34d82ed
90856b4
36af503
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 |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| package org.dbpedia.extraction.dataparser | ||
|
|
||
| import org.dbpedia.extraction.ontology.datatypes.Datatype | ||
| import org.junit.runner.RunWith | ||
| import org.scalatest.junit.JUnitRunner | ||
| import org.scalatest.{FlatSpec, Matchers} | ||
|
|
||
| @RunWith(classOf[JUnitRunner]) | ||
| class EthiopianDateParserTest extends FlatSpec with Matchers { | ||
|
|
||
| private val datatype = new Datatype("xsd:date") | ||
| private val parser = new EthiopianDateParser(datatype, strict = true) | ||
|
|
||
| private def parse(input: String): Option[String] = | ||
| parser.findGeezDate(input).map(_.toString) | ||
|
|
||
| "EthiopianDateParser" should "convert every Ethiopian month to the correct Gregorian year" in { | ||
| val conversions = Seq( | ||
| (2013, 1, 1, "2020-09-11"), | ||
| (2013, 2, 1, "2020-10-11"), | ||
| (2013, 3, 1, "2020-11-10"), | ||
|
Check failure on line 21 in core/src/test/scala/org/dbpedia/extraction/dataparser/EthiopianDateParserTest.scala
|
||
| (2013, 4, 1, "2020-12-10"), | ||
|
Check failure on line 22 in core/src/test/scala/org/dbpedia/extraction/dataparser/EthiopianDateParserTest.scala
|
||
| (2013, 5, 1, "2021-01-09"), | ||
| (2013, 6, 1, "2021-02-08"), | ||
| (2013, 7, 1, "2021-03-10"), | ||
| (2013, 8, 1, "2021-04-09"), | ||
| (2013, 9, 1, "2021-05-09"), | ||
| (2013, 10, 1, "2021-06-08"), | ||
| (2013, 11, 1, "2021-07-08"), | ||
|
Check failure on line 29 in core/src/test/scala/org/dbpedia/extraction/dataparser/EthiopianDateParserTest.scala
|
||
| (2013, 12, 1, "2021-08-07"), | ||
|
Check failure on line 30 in core/src/test/scala/org/dbpedia/extraction/dataparser/EthiopianDateParserTest.scala
|
||
| (2013, 13, 1, "2021-09-06") | ||
| ) | ||
|
|
||
| conversions.foreach { case (year, month, day, expected) => | ||
| parser.geezToGregorianDateConverter(year, month, day, datatype) | ||
| .map(_.toString) should equal(Some(expected)) | ||
| } | ||
| } | ||
|
|
||
| it should "parse the standard Amharic day-marker format as written" in { | ||
| val articleDates = Seq( | ||
| "መስከረም ፳ ቀን ፲፱፻፶፱ ዓ.ም." -> "1966-09-30", | ||
| "ጥቅምት ፪ ቀን ፲፱፻፷፩ ዓ.ም." -> "1968-10-12", | ||
| "ጥር ፲፫ ቀን ፲፱፻፲፩ ዓ.ም." -> "1919-01-21", | ||
| "የካቲት ፲፩ ቀን ፲፱፻፶፯ ዓ.ም." -> "1965-02-18" | ||
| ) | ||
|
|
||
| articleDates.foreach { case (input, expected) => | ||
| parse(input) should equal(Some(expected)) | ||
| } | ||
| } | ||
|
|
||
| it should "recognize supported Ethiopian era markers" in { | ||
| val eraMarkers = Seq("ዓ.ም.", "ዓ.ም", "ዓ/ም", "ዓመተ ምሕረት", "ዓመተ ምኅረት", "አ.ም.") | ||
|
|
||
| eraMarkers.foreach { marker => | ||
| parse(s"መስከረም 1 ቀን 2013 $marker") should equal(Some("2020-09-11")) | ||
| } | ||
| } | ||
|
|
||
| it should "recognize observed Ethiopian month spelling variants" in { | ||
| val monthVariants = Seq( | ||
| "ኅዳር" -> "2020-11-10", | ||
| "ህዳር" -> "2020-11-10", | ||
| "ኀዳር" -> "2020-11-10", | ||
| "ታኅሣሥ" -> "2020-12-10", | ||
| "ታኅሳስ" -> "2020-12-10", | ||
| "ታህሳስ" -> "2020-12-10", | ||
| "ታኅሣስ" -> "2020-12-10", | ||
| "ሚያዚያ" -> "2021-04-09", | ||
| "ሓምሌ" -> "2021-07-08", | ||
| "ሃምሌ" -> "2021-07-08", | ||
| "ኃምሌ" -> "2021-07-08", | ||
| "ነሓሴ" -> "2021-08-07", | ||
| "ነሃሴ" -> "2021-08-07", | ||
| "ጳጉሜን" -> "2021-09-06" | ||
|
Nama21yo marked this conversation as resolved.
Resolved
|
||
| ) | ||
|
|
||
| monthVariants.foreach { case (month, expected) => | ||
| parse(s"$month 1 2013") should equal(Some(expected)) | ||
| } | ||
| } | ||
|
|
||
| it should "parse Arabic and single-digit Geez days in both supported orders" in { | ||
| parse("ጥቅምት 21 2013") should equal(Some("2020-10-31")) | ||
| parse("21 ጥቅምት 2013") should equal(Some("2020-10-31")) | ||
| parse("ታኅሣሥ ፪ ቀን ፲፱፻፶፮ ዓ.ም.") should equal(Some("1963-12-12")) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.dbpedia.extraction.mappings | ||
|
|
||
| import org.dbpedia.extraction.config.mappings.InfoboxExtractorConfig | ||
| import org.junit.runner.RunWith | ||
| import org.scalatest.junit.JUnitRunner | ||
| import org.scalatest.{FlatSpec, Matchers} | ||
|
|
||
| @RunWith(classOf[JUnitRunner]) | ||
| class InfoboxExtractorConfigTest extends FlatSpec with Matchers { | ||
|
|
||
| "InfoboxExtractorConfig" should "combine the baseline and language-specific ignored properties" in { | ||
| InfoboxExtractorConfig.ignoreProperties.foreach { case (wikiCode, languageProperties) => | ||
| val ignored = InfoboxExtractorConfig.ignoredProperties(wikiCode) | ||
| InfoboxExtractorConfig.ignoreProperties("en").subsetOf(ignored) should equal(true) | ||
| languageProperties.subsetOf(ignored) should equal(true) | ||
| } | ||
|
|
||
| val amharicIgnored = InfoboxExtractorConfig.ignoredProperties("am") | ||
| amharicIgnored should contain ("image") | ||
| amharicIgnored should contain ("ሥዕል") | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| package org.dbpedia.extraction.mappings | ||
|
|
||
| import org.dbpedia.extraction.config.provenance.DBpediaDatasets | ||
| import org.dbpedia.extraction.transform.Quad | ||
| import org.dbpedia.extraction.util.Language | ||
| import org.dbpedia.extraction.wikiparser.{TemplateNode, WikiPage, WikiParser, WikiTitle} | ||
| import org.junit.runner.RunWith | ||
| import org.scalatest.junit.JUnitRunner | ||
| import org.scalatest.{FlatSpec, Matchers} | ||
|
|
||
| @RunWith(classOf[JUnitRunner]) | ||
| class MappingExtractorEmptyLiteralTest extends FlatSpec with Matchers { | ||
|
|
||
| "MappingExtractor" should "omit empty literals while preserving non-empty mapping output" in { | ||
| val mapping = new Extractor[TemplateNode] { | ||
| override val datasets = Set(DBpediaDatasets.OntologyPropertiesLiterals) | ||
|
|
||
| override def extract(input: TemplateNode, subjectUri: String): Seq[Quad] = Seq( | ||
| new Quad("am", DBpediaDatasets.OntologyPropertiesLiterals.encoded, subjectUri, | ||
| "http://dbpedia.org/ontology/name", "", input.sourceIri, | ||
| "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"), | ||
| new Quad("am", DBpediaDatasets.OntologyPropertiesLiterals.encoded, subjectUri, | ||
| "http://dbpedia.org/ontology/name", "የሙከራ ስም", input.sourceIri, | ||
| "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString") | ||
| ) | ||
| } | ||
| val context = new { | ||
| def mappings = new Mappings(Map("Test mapping" -> mapping), Nil) | ||
| def redirects = new Redirects(Map.empty) | ||
| } | ||
| val language = Language("am") | ||
| val page = new WikiPage( | ||
| WikiTitle.parse("የሙከራ ገጽ", language), | ||
| "{{Test mapping}}" | ||
| ) | ||
| val pageNode = WikiParser.getInstance()(page).get | ||
|
|
||
| val quads = new MappingExtractor(context).extract(pageNode, page.title.resourceIri) | ||
|
|
||
| quads.map(_.value) should equal(Seq("የሙከራ ስም")) | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.