Java Code Examples for org.eclipse.rdf4j.model.vocabulary.RDFS#LABEL

The following examples show how to use org.eclipse.rdf4j.model.vocabulary.RDFS#LABEL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MongoFreeTextIndexerIT.java    From rya with Apache License 2.0 6 votes vote down vote up
@Test
public void testSearch() throws Exception {
    try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = SimpleValueFactory.getInstance();

        final IRI subject = vf.createIRI("foo:subj");
        final IRI predicate = RDFS.LABEL;
        final Value object = vf.createLiteral("this is a new hat");

        final IRI context = vf.createIRI("foo:context");

        final Statement statement = vf.createStatement(subject, predicate, object, context);
        f.storeStatement(RdfToRyaConversions.convertStatement(statement));
        f.flush();

        assertEquals(Sets.newHashSet(), getSet(f.queryText("asdf", EMPTY_CONSTRAINTS)));

        assertEquals(Sets.newHashSet(statement), getSet(f.queryText("new", EMPTY_CONSTRAINTS)));
        assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat new", EMPTY_CONSTRAINTS)));
    }
}
 
Example 2
Source File: MongoFreeTextIndexerIT.java    From rya with Apache License 2.0 4 votes vote down vote up
@Test
public void testDelete() throws Exception {
    try (MongoFreeTextIndexer f = new MongoFreeTextIndexer()) {
        f.setConf(conf);
        f.init();

        final ValueFactory vf = SimpleValueFactory.getInstance();

        final IRI subject1 = vf.createIRI("foo:subj");
        final IRI predicate1 = RDFS.LABEL;
        final Value object1 = vf.createLiteral("this is a new hat");

        final IRI context1 = vf.createIRI("foo:context");

        final Statement statement1 = vf.createStatement(subject1, predicate1, object1, context1);
        f.storeStatement(RdfToRyaConversions.convertStatement(statement1));

        final IRI subject2 = vf.createIRI("foo:subject");
        final IRI predicate2 = RDFS.LABEL;
        final Value object2 = vf.createLiteral("Do you like my new hat?");

        final IRI context2 = vf.createIRI("foo:context");

        final Statement statement2 = vf.createStatement(subject2, predicate2, object2, context2);
        f.storeStatement(RdfToRyaConversions.convertStatement(statement2));

        f.flush();


        f.deleteStatement(RdfToRyaConversions.convertStatement(statement1));
        assertEquals(Sets.newHashSet(statement2), getSet(f.queryText("Do you like my new hat?", EMPTY_CONSTRAINTS)));

        // Check that "new" didn't get deleted from the term table after "this is a new hat"
        // was deleted since "new" is still in "Do you like my new hat?"
        assertEquals(Sets.newHashSet(statement2), getSet(f.queryText("new", EMPTY_CONSTRAINTS)));

        f.deleteStatement(RdfToRyaConversions.convertStatement(statement2));
        assertEquals(Sets.newHashSet(), getSet(f.queryText("this is a new hat", EMPTY_CONSTRAINTS)));
        assertEquals(Sets.newHashSet(), getSet(f.queryText("Do you like my new hat?", EMPTY_CONSTRAINTS)));
    }
}
 
Example 3
Source File: AccumuloFreeTextIndexerTest.java    From rya with Apache License 2.0 4 votes vote down vote up
@Test
public void testSearch() throws Exception {
    try (AccumuloFreeTextIndexer f = new AccumuloFreeTextIndexer()) {
        f.setConf(conf);
        f.setMultiTableBatchWriter(ConfigUtils.createMultitableBatchWriter(conf));
        f.init();

        ValueFactory vf = SimpleValueFactory.getInstance();

        IRI subject = vf.createIRI("foo:subj");
        IRI predicate = RDFS.LABEL;
        Value object = vf.createLiteral("this is a new hat");

        IRI context = vf.createIRI("foo:context");

        Statement statement = vf.createStatement(subject, predicate, object, context);
        f.storeStatement(RdfToRyaConversions.convertStatement(statement));
        f.flush();

        printTables(conf);

        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("asdf", EMPTY_CONSTRAINTS)));

        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("this & !is", EMPTY_CONSTRAINTS)));

        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("this", EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("is", EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("a", EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("new", EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat", EMPTY_CONSTRAINTS)));

        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("ha*", EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("*at", EMPTY_CONSTRAINTS)));

        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("hat & new", EMPTY_CONSTRAINTS)));

        Assert.assertEquals(Sets.newHashSet(statement), getSet(f.queryText("this & hat & new", EMPTY_CONSTRAINTS)));

        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("bat", EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("this & bat", EMPTY_CONSTRAINTS)));
    }
}
 
Example 4
Source File: AccumuloFreeTextIndexerTest.java    From rya with Apache License 2.0 4 votes vote down vote up
@Test
public void testDelete() throws Exception {
    try (AccumuloFreeTextIndexer f = new AccumuloFreeTextIndexer()) {
        f.setConf(conf);
        f.setMultiTableBatchWriter(ConfigUtils.createMultitableBatchWriter(conf));
        f.init();

        ValueFactory vf = SimpleValueFactory.getInstance();

        IRI subject1 = vf.createIRI("foo:subj");
        IRI predicate1 = RDFS.LABEL;
        Value object1 = vf.createLiteral("this is a new hat");

        IRI context1 = vf.createIRI("foo:context");

        Statement statement1 = vf.createStatement(subject1, predicate1, object1, context1);
        f.storeStatement(RdfToRyaConversions.convertStatement(statement1));

        IRI subject2 = vf.createIRI("foo:subject");
        IRI predicate2 = RDFS.LABEL;
        Value object2 = vf.createLiteral("Do you like my new hat?");

        IRI context2 = vf.createIRI("foo:context");

        Statement statement2 = vf.createStatement(subject2, predicate2, object2, context2);
        f.storeStatement(RdfToRyaConversions.convertStatement(statement2));

        f.flush();


        System.out.println("testDelete: BEFORE DELETE");
        printTables(conf);

        f.deleteStatement(RdfToRyaConversions.convertStatement(statement1));
        System.out.println("testDelete: AFTER FIRST DELETION");
        printTables(conf);
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("this is a new hat", EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(statement2), getSet(f.queryText("Do you like my new hat?", EMPTY_CONSTRAINTS)));

        // Check that "new" didn't get deleted from the term table after "this is a new hat"
        // was deleted since "new" is still in "Do you like my new hat?"
        Assert.assertEquals(Sets.newHashSet(statement2), getSet(f.queryText("new", EMPTY_CONSTRAINTS)));

        f.deleteStatement(RdfToRyaConversions.convertStatement(statement2));
        System.out.println("testDelete: AFTER LAST DELETION");
        printTables(conf);

        System.out.println("testDelete: DONE");
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("this is a new hat", EMPTY_CONSTRAINTS)));
        Assert.assertEquals(Sets.newHashSet(), getSet(f.queryText("Do you like my new hat?", EMPTY_CONSTRAINTS)));
    }
}