Exemplo n.º 1
0
 def transform(self, X, y=None):
     X = label_linker(X,
                      column=self.column,
                      new_attribute_name=self.new_attribute_name,
                      progress=self.progress,
                      endpoint=self.endpoint,
                      result_filter=self.result_filter,
                      language=self.language,
                      max_hits=self.max_hits,
                      label_property=self.label_property,
                      prefix_lookup=self.prefix_lookup,
                      caching=self.caching)
     return X
Exemplo n.º 2
0
    def test3_dbpedia_de_gu(self):

        df = pd.DataFrame({
            "state": ["Baden-Württemberg", "Bayern", "Sachsen"]
        })

        expected_result_df = pd.DataFrame({
            "state": ["Baden-Württemberg", "Bayern", "Sachsen"],
            "new_link_1": ["http://dbpedia.org/resource/Baden-Württemberg", "http://dbpedia.org/resource/Bavaria", "http://dbpedia.org/resource/Saxony"]
        })

        result = label_linker(df, "state", endpoint=DBpedia,
                              language="de", graph_uri="http://dbpedia.org")

        pd.testing.assert_frame_equal(result, expected_result_df)
Exemplo n.º 3
0
    def test2_dbpedia_en(self):

        df = pd.DataFrame({
            "state": ["Baden-Württemberg", "Bayern", "Sachsen"]
        })

        expected_result_df = pd.DataFrame({
            "state": ["Baden-Württemberg", "Bayern", "Sachsen"],
            "new_link_1": ["http://dbpedia.org/resource/Baden-Württemberg", "http://dbpedia.org/resource/Bayern", "http://dbpedia.org/resource/Sachsen"],
            "new_link_2": ["http://www.wikidata.org/entity/Q985", "http://www.wikidata.org/entity/Q255654", "http://www.wikidata.org/entity/Q16882470"],
            "new_link_3": ["http://www.wikidata.org/entity/Q20825585", "http://www.wikidata.org/entity/Q4874432", np.nan],
            "new_link_4": [np.nan, "http://www.wikidata.org/entity/Q18148056", np.nan]
        })

        result = label_linker(df, "state", endpoint=DBpedia, language="en")

        pd.testing.assert_frame_equal(result, expected_result_df)
Exemplo n.º 4
0
    def test4_dbpedia_de(self):

        df = pd.DataFrame({
            "state": ["Baden-Württemberg", "Bayern", "Sachsen"]
        })

        expected_result_df = pd.DataFrame({
            "state": ["Baden-Württemberg", "Bayern", "Sachsen"],
            "new_link_1": ["http://dbpedia.org/resource/Baden-Württemberg", "http://www.wikidata.org/entity/Q980", "http://dbpedia.org/resource/Saxony"],
            "new_link_2": ["http://www.wikidata.org/entity/Q985", "http://dbpedia.org/resource/Bavaria", "http://www.wikidata.org/entity/Q467095"],
            "new_link_3": ["http://www.wikidata.org/entity/Q21036291", "http://www.wikidata.org/entity/Q255654", "http://www.wikidata.org/entity/Q1202"],
            "new_link_4": [np.nan, "http://www.wikidata.org/entity/Q4874432", "http://www.wikidata.org/entity/Q101985"],
            "new_link_5": [np.nan, "http://www.wikidata.org/entity/Q18148056", "http://www.wikidata.org/entity/Q3873416"],
            "new_link_6": [np.nan, np.nan, "http://www.wikidata.org/entity/Q27505"],
            "new_link_7": [np.nan, np.nan, "http://www.wikidata.org/entity/Q16882470"],
            "new_link_8": [np.nan, np.nan, "http://www.wikidata.org/entity/Q1325543"],
            "new_link_9": [np.nan, np.nan, "http://www.wikidata.org/entity/Q1435378"],
            "new_link_10": [np.nan, np.nan, "http://www.wikidata.org/entity/Q1537344"],
            "new_link_11": [np.nan, np.nan, "http://www.wikidata.org/entity/Q1365112"]
        })

        result = label_linker(df, "state", endpoint=DBpedia, language="de")

        pd.testing.assert_frame_equal(result, expected_result_df)