def test_all_facts_en(self): text = """ Country code: BE. Three people check into a hotel room. The manager says the bill is $30, so each guest pays $10. Later the manager realizes the bill should only be $25. To rectify this, he gives the bellhop $5 to return to the guests. """ FactExtractor.ensure_parser_arguments_en(geo_config=EN_GEO_CONFIG) facts = FactExtractor.parse_text(text, FactExtractor.LANGUAGE_EN, ExtractorResultFormat.fmt_class, extract_all=True) self.assertTrue(AnnotationType.money in facts)
def test_one_fact_en(self): text = """ Three people check into a hotel room. The manager says the bill is $30, so each guest pays $10. Later the manager realizes the bill should only be $25. To rectify this, he gives the bellhop $5 to return to the guests. """ facts = FactExtractor.parse_text(text, FactExtractor.LANGUAGE_EN, ExtractorResultFormat.fmt_class, extract_all=False, include_types={AnnotationType.money}) self.assertTrue(AnnotationType.money in facts) facts = facts[AnnotationType.money] self.assertGreater(len(facts), 2)
def test_one_fact_dict_en(self): text = """ Three people check into a hotel room. The manager says the bill is $30, so each guest pays $10. Later the manager realizes the bill should only be $25. To rectify this, he gives the bellhop $5 to return to the guests. """ facts = FactExtractor.parse_text(text, FactExtractor.LANGUAGE_EN, ExtractorResultFormat.fmt_dict, extract_all=False, include_types={AnnotationType.money}) self.assertTrue(AnnotationType.money in facts) facts = facts[AnnotationType.money] facts.sort(key=lambda f: f['attrs']['start']) self.assertEqual(5.0, float(facts[-1]['tags']['Extracted Entity Value']))
def test_one_fact_de(self): text = """ Die neuesten Bevölkerungszahlen basieren auf Daten der Volkszählung von 2011 in Indien. Während des Jahrzehnts 2001–2011 hat sich das jährliche Bevölkerungswachstum in Indien von 2,15 % auf 1,76% verlangsamt. [6] Basierend auf Daten aus zehnjährigen Volkszählungen weisen Dadra und Nagar Haveli die schnellste Wachstumsrate von 55,5 Prozent auf, gefolgt von Daman und Diu (53,5 Prozent), Meghalaya (27,8 Prozent) und Arunachal Pradesh (25,9 Prozent). Nagaland verzeichnete die niedrigste Wachstumsrate von -0,5 Prozent. """ facts = FactExtractor.parse_text(text, FactExtractor.LANGUAGE_DE, ExtractorResultFormat.fmt_class, extract_all=False, include_types={AnnotationType.percent}) self.assertTrue(AnnotationType.percent in facts) facts = facts[AnnotationType.percent] self.assertGreater(len(facts), 2)