Search in sources :

Example 6 with FindQueryTestCase

use of org.apache.stanbol.entityhub.test.query.FindQueryTestCase in project stanbol by apache.

the class DbpediaQueryTest method testFindWildcards.

@Test
public void testFindWildcards() throws IOException, JSONException {
    //first a search without wildcards
    FindQueryTestCase test = new FindQueryTestCase("cia", Arrays.asList("http://dbpedia.org/resource/Central_Intelligence_Agency", "http://dbpedia.org/resource/The_World_Factbook"), Arrays.asList("http://dbpedia.org/resource/Ciara"));
    test.setField("http://dbpedia.org/ontology/surfaceForm");
    test.setLanguage("en");
    //there are a lot of those
    test.setLimit(5);
    executeQuery(test);
    //now the same search with wildcards
    test = new FindQueryTestCase("cia*", Arrays.asList("http://dbpedia.org/resource/Central_Intelligence_Agency", //CiarraĆ­ (county)
    "http://dbpedia.org/resource/County_Kerry", //Ciamin
    "http://dbpedia.org/resource/Vitamin_C", "http://dbpedia.org/resource/Ciara", //CIA World Factbook
    "http://dbpedia.org/resource/The_World_Factbook"));
    test.setField("http://dbpedia.org/ontology/surfaceForm");
    test.setLanguage("en");
    //there are a lot of those
    test.setLimit(10);
    executeQuery(test);
    test = new FindQueryTestCase("proto*", Arrays.asList("http://dbpedia.org/resource/Prototype", "http://dbpedia.org/resource/Proton", "http://dbpedia.org/resource/Hypertext_Transfer_Protocol", "http://dbpedia.org/resource/File_Transfer_Protocol"), Arrays.asList("http://dbpedia.org/resource/Pretoria"));
    test.setLanguage("en");
    //there a a lot of those
    test.setLimit(100);
    executeQuery(test);
    //now the same search with wildcards
    test = new FindQueryTestCase("pr?to*", Arrays.asList("http://dbpedia.org/resource/Pretoria", "http://dbpedia.org/resource/Prototype", "http://dbpedia.org/resource/Proton", "http://dbpedia.org/resource/Program_and_System_Information_Protocol", "http://dbpedia.org/resource/Hypertext_Transfer_Protocol"));
    test.setLanguage("en");
    //there a a lot of those
    test.setLimit(100);
    executeQuery(test);
}
Also used : FindQueryTestCase(org.apache.stanbol.entityhub.test.query.FindQueryTestCase) SitesManagerTest(org.apache.stanbol.entityhub.it.SitesManagerTest) Test(org.junit.Test) ReferencedSiteTest(org.apache.stanbol.entityhub.it.ReferencedSiteTest)

Example 7 with FindQueryTestCase

use of org.apache.stanbol.entityhub.test.query.FindQueryTestCase in project stanbol by apache.

the class DbpediaQueryTest method testFindLimitAndOffsetQuery.

@Test
public void testFindLimitAndOffsetQuery() throws IOException, JSONException {
    //expected:
    // Paris: 16.905037
    // University_of_Paris: 10.565648
    // Paris_Hilton, Salon_(Paris), Paris_M%C3%A9tro, Paris_Opera, 
    //    Paris_Saint-Germain_F.C., Paris_Commune, Paris_Masters: 8.452518
    //only the first result
    FindQueryTestCase test = new FindQueryTestCase("Paris", Arrays.asList("http://dbpedia.org/resource/Paris"), Arrays.asList("http://dbpedia.org/resource/University_of_Paris", "http://dbpedia.org/resource/Paris_Hilton", "http://dbpedia.org/resource/Paris_Saint-Germain_F.C."));
    test.setLanguage("en");
    test.setLimit(1);
    executeQuery(test);
    //the second result
    test = new FindQueryTestCase("Paris", Arrays.asList("http://dbpedia.org/resource/University_of_Paris"), Arrays.asList("http://dbpedia.org/resource/Paris", "http://dbpedia.org/resource/Paris_Hilton", "http://dbpedia.org/resource/Paris_Saint-Germain_F.C."));
    test.setLanguage("en");
    test.setLimit(1);
    test.setOffset(1);
    executeQuery(test);
    //the second and third
    test = new FindQueryTestCase("Paris", Arrays.asList("http://dbpedia.org/resource/Paris_Saint-Germain_F.C.", "http://dbpedia.org/resource/Paris_Hilton"), Arrays.asList("http://dbpedia.org/resource/University_of_Paris", "http://dbpedia.org/resource/Paris"));
    test.setLanguage("en");
    test.setLimit(10);
    test.setOffset(2);
    executeQuery(test);
}
Also used : FindQueryTestCase(org.apache.stanbol.entityhub.test.query.FindQueryTestCase) SitesManagerTest(org.apache.stanbol.entityhub.it.SitesManagerTest) Test(org.junit.Test) ReferencedSiteTest(org.apache.stanbol.entityhub.it.ReferencedSiteTest)

Aggregations

FindQueryTestCase (org.apache.stanbol.entityhub.test.query.FindQueryTestCase)7 ReferencedSiteTest (org.apache.stanbol.entityhub.it.ReferencedSiteTest)4 SitesManagerTest (org.apache.stanbol.entityhub.it.SitesManagerTest)4 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)1 RequestExecutor (org.apache.stanbol.commons.testing.http.RequestExecutor)1