コード例 #1
0
    def test_rank_scoring_coefficient(self):
        config = load_json_file("10_config.json")
        query = load_json_file("10_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        c = result["SPARQL"]["where"]["clauses"]
        self.assertEqual(c[0]["type"], "City")
コード例 #2
0
    def test_network_expansion(self):
        config = load_json_file("8_config.json")
        query = load_json_file("8_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        w = result["SPARQL"]["where"]
        self.assertEqual(w["clauses"][0]["filters"][0]["type"], "City")
コード例 #3
0
    def test_order_by(self):
        config = load_json_file("9_config.json")
        query = load_json_file("9_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        o = result["SPARQL"]["order-by"]
        self.assertEqual(o["values"][0]["type"], "PostingDate")
コード例 #4
0
    def test_group_by_typing(self):
        config = load_json_file("6_config.json")
        query = load_json_file("6_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        g = result["SPARQL"]["group-by"]
        self.assertEqual(g["variables"][0]["type"], "Ethnicity")
コード例 #5
0
    def test_group_by_typing(self):
        config = load_json_file("6_config.json")
        query = load_json_file("6_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        g = result["SPARQL"]["group-by"]
        self.assertEqual(g["variables"][0]["type"], "Ethnicity")
コード例 #6
0
    def test_sparql_unnesting(self):
        config = load_json_file("5_config.json")
        query = load_json_file("5_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        w = result["SPARQL"]["where"]
        self.assertEqual(w["type"], "Ad")
        self.assertEqual(w["clauses"][0]["type"], "Cluster")
コード例 #7
0
    def test_basic_coarse_preprocessing_with_date_filter(self):
        config = load_json_file("4_config.json")
        query = load_json_file("4_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        f = result["SPARQL"]["where"]["filters"][0]
        self.assertEqual(f["clauses"][0]["type"],
                         "PostingDate")
コード例 #8
0
    def test_basic_coarse_preprocessing_with_no_type_mappings(self):
        config = load_json_file("3_config.json")
        query = load_json_file("3_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        f = result["SPARQL"]["where"]["filters"][0]
        self.assertEqual(f["clauses"][0]["type"],
                         "owl:Thing")
コード例 #9
0
    def test_sparql_unnesting(self):
        config = load_json_file("5_config.json")
        query = load_json_file("5_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        w = result["SPARQL"]["where"]
        self.assertEqual(w["type"], "Ad")
        self.assertEqual(w["clauses"][0]["type"], "Cluster")
コード例 #10
0
    def test_basic_coarse_preprocessing_with_date_filter(self):
        config = load_json_file("4_config.json")
        query = load_json_file("4_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        f = result["SPARQL"]["where"]["filters"][0]
        self.assertEqual(f["clauses"][0]["type"],
                         "PostingDate")
コード例 #11
0
    def test_basic_coarse_preprocessing_with_no_type_mappings(self):
        config = load_json_file("3_config.json")
        query = load_json_file("3_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        f = result["SPARQL"]["where"]["filters"][0]
        self.assertEqual(f["clauses"][0]["type"],
                         "owl:Thing")
コード例 #12
0
    def test_union_and_not_exists(self):
        config = load_json_file("7_config.json")
        query = load_json_file("7_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        c = result["SPARQL"]["where"]["clauses"]
        self.assertEqual(c[0]["clauses"][0]["type"], "Location")
        self.assertEqual(c[0]["clauses"][1]["type"], "Location")
        fs = result["SPARQL"]["where"]["filters"]
        self.assertEqual(fs[0]["clauses"][0]["type"], "PostingDate")
        self.assertEqual(fs[0]["clauses"][1]["clauses"][0]["type"], "Title")
コード例 #13
0
    def test_basic_coarse_preprocessing(self):
        config = load_json_file("1_config.json")
        query = load_json_file("1_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        self.assertEqual(result["SPARQL"]["where"]["clauses"][1]["constraint"],
                         "toronto, ontario")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][1]["isOptional"],
                         True)
        self.assertEqual(result["SPARQL"]["where"]["clauses"][1]["type"],
                         "Location")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][3]["type"],
                         "Title")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][4]["type"],
                         "HairColor")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][4]["constraint"],
                         "blonde")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][5]["constraint"],
                         "straw")
        self.assertEqual(result["SPARQL"]["where"]["filters"][0]["type"],
                         "Title")
        self.assertNotIn("the", result["SPARQL"]["where"]["filters"][0]["constraint"].split(" ") )
        self.assertIn("mistress", result["SPARQL"]["where"]["filters"][0]["constraint"].split(" ") )
コード例 #14
0
    def test_basic_coarse_preprocessing(self):
        config = load_json_file("1_config.json")
        query = load_json_file("1_query.json")
        preprocessor = Preprocessor(config)

        result = preprocessor.preprocess(query)
        self.assertEqual(result["SPARQL"]["where"]["clauses"][1]["constraint"],
                         "toronto, ontario")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][1]["isOptional"],
                         True)
        self.assertEqual(result["SPARQL"]["where"]["clauses"][1]["type"],
                         "Location")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][3]["type"],
                         "Title")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][4]["type"],
                         "HairColor")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][4]["constraint"],
                         "blonde")
        self.assertEqual(result["SPARQL"]["where"]["clauses"][5]["constraint"],
                         "straw")
        self.assertEqual(result["SPARQL"]["where"]["filters"][0]["type"],
                         "Title")
        self.assertNotIn("the", result["SPARQL"]["where"]["filters"][0]["constraint"].split(" ") )
        self.assertIn("mistress", result["SPARQL"]["where"]["filters"][0]["constraint"].split(" ") )