Exemplo n.º 1
0
 def transform(self, X, y=None):
     X = sameas_linker(X,
                       column=self.column,
                       new_attribute_name=self.new_attribute_name,
                       progress=self.progress,
                       endpoint=self.endpoint,
                       result_filter=self.result_filter,
                       uri_data_model=self.uri_data_model,
                       bundled_mode=self.bundled_mode,
                       prefix_lookup=self.prefix_lookup,
                       caching=self.caching)
     return X
Exemplo n.º 2
0
    def test1_wikidata_bundled(self):

        df = pd.DataFrame({
            "word": ["they", "they", "she", "she", "he"],
            "uri": ["http://www.wikidata.org/entity/L1372", "http://www.wikidata.org/entity/L493", "http://www.wikidata.org/entity/L1370", "http://www.wikidata.org/entity/L496", "http://www.wikidata.org/entity/L1371"]
        })

        expected_result_df = pd.DataFrame({
            "word": ["they", "they", "she", "she", "he"],
            "uri": ["http://www.wikidata.org/entity/L1372", "http://www.wikidata.org/entity/L493", "http://www.wikidata.org/entity/L1370", "http://www.wikidata.org/entity/L496", "http://www.wikidata.org/entity/L1371"],
            "same_as_1": ["http://www.wikidata.org/entity/L371", "http://www.wikidata.org/entity/L371", "http://www.wikidata.org/entity/L484", "http://www.wikidata.org/entity/L484", "http://www.wikidata.org/entity/L485"]
        })

        result = sameas_linker(df, "uri", new_attribute_name="same_as", endpoint=WikiData, bundled_mode=True)

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

        df = pd.DataFrame({
            "label": ["Universität Mannheim", "Universität Bremen"],
            "uri": ["http://dbpedia.org/resource/University_of_Mannheim", "http://dbpedia.org/resource/University_of_Bremen"]
        })

        expected_result_df = pd.DataFrame({
            "label": ["Universität Mannheim", "Universität Bremen"],
            "uri": ["http://dbpedia.org/resource/University_of_Mannheim", "http://dbpedia.org/resource/University_of_Bremen"],
            "same_as_1": ["http://yago-knowledge.org/resource/University_of_Mannheim", "http://yago-knowledge.org/resource/University_of_Bremen"],
            "same_as_2": ["http://rdf.freebase.com/ns/m.0b6dry", "http://rdf.freebase.com/ns/m.04fd75"],
            "same_as_3": ["http://www.wikidata.org/entity/Q317070", "http://www.wikidata.org/entity/Q500692"],
            "same_as_4": ["http://wikidata.dbpedia.org/resource/Q317070", "http://wikidata.dbpedia.org/resource/Q500692"]
        })

        result = sameas_linker(df, "uri", new_attribute_name="same_as", endpoint=DBpedia, result_filter=[
                               "yago", "freebase", "wiki"], bundled_mode=False)

        pd.testing.assert_frame_equal(result, expected_result_df)