Package org.apache.stanbol.entityhub.servicesapi.model

Examples of org.apache.stanbol.entityhub.servicesapi.model.Representation.addReference()


    }

    @Test(expected = IllegalArgumentException.class)
    public void testNullFieldAddReference() {
        Representation rep = createRepresentation(null);
        rep.addReference(null, "urn:test");
    }

    @Test(expected = IllegalArgumentException.class)
    public void testNullFieldGet() {
        Representation rep = createRepresentation(null);
View Full Code Here


        String field = "urn:the.field:used.for.this.Test";
        Set<String> refs = new HashSet<String>(Arrays.asList("http://www.test.org/test1",
            "urn:test.org:test.1"));
        Representation rep = createRepresentation(null);
        for (String ref : refs) {
            rep.addReference(field, ref);
        }
        Iterator<Reference> refIterator = rep.getReferences(field);
        assertNotNull(refIterator);
        while (refIterator.hasNext()) {
            Reference ref = refIterator.next();
View Full Code Here

    public void testRemoveAllNaturalLanguageValues() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // add a reference to ensure that only texts (and strings) are removed
        String testReference = "http://www.test.org/test";
        rep.addReference(field, testReference);
        // test removal of all natural language values by parsing no languages
        rep.removeAllNaturalText(field);
        Iterator<Text> texts = rep.get(field, (String[]) null);
        assertFalse(texts.hasNext()); // not texts any more
        assertTrue(rep.get(field).hasNext()); // but still a reference!
View Full Code Here

    public void testRemoveAllNaturalLanguageValuesByParsingAnEmptyArray() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // add a reference to ensure that only texts (and strings) are removed
        String testReference = "http://www.test.org/test";
        rep.addReference(field, testReference);
        // test removal of all natural language values by parsing an empty language array
        rep.removeAllNaturalText(field, new String[] {});
        Iterator<Text> texts = rep.get(field, (String[]) null);
        assertFalse(texts.hasNext());
        assertTrue(rep.get(field).hasNext()); // text of the added reference is still present
View Full Code Here

    public void testRemoveAllNaturalLanguageValuesByParsingNullAsLanguageArray() {
        String field = "urn:the.field:used.for.this.Test";
        Representation rep = initNaturalLanguageTest(field);
        // add a reference to ensure that only texts (and strings) are removed
        String testReference = "http://www.test.org/test";
        rep.addReference(field, testReference);
        // test removal of all natural language values by parsing only a single argument
        rep.removeAllNaturalText(field);
        Iterator<Text> texts = rep.get(field, (String[]) null);
        assertFalse(texts.hasNext());
        assertTrue(rep.get(field).hasNext()); // text of the added reference is still present
View Full Code Here

            NodeTransformer fieldTransformer = program.getField(entry.getKey()).getTransformer();
            if(fieldTransformer == null || fieldTransformer instanceof IdentityTransformer<?>){
                //we need to convert the RDFBackend Node to an Representation object
                for(Object value : entry.getValue()){
                    if(backend.isURI(value)){
                        result.addReference(entry.getKey(), backend.stringValue(value));
                    } else if(backend.isLiteral(value)){ //literal
                        Locale lang = backend.getLiteralLanguage(value);
                        if(lang != null){ //text with language
                            result.addNaturalText(entry.getKey(), backend.stringValue(value), lang.getLanguage());
                        } else { // no language
View Full Code Here

        openNLP = new OpenNLP(new ClasspathDataFileProvider("DUMMY_SYMBOLIC_NAME"));
        searcher = new TestSearcherImpl(NAME,SimpleTokenizer.INSTANCE);
        //add some terms to the searcher
        Representation rep = factory.createRepresentation("urn:test:PatrickMarshall");
        rep.addNaturalText(NAME, "Patrick Marshall");
        rep.addReference(TYPE, OntologicalClasses.DBPEDIA_PERSON.getUnicodeString());
        searcher.addEntity(rep);
        rep = factory.createRepresentation("urn:test:Geologist");
        rep.addNaturalText(NAME, "Geologist");
        rep.addReference(TYPE, NamespaceEnum.skos+"Concept");
        rep.addReference(REDIRECT, "urn:test:redirect:Geologist");
View Full Code Here

        rep.addNaturalText(NAME, "Patrick Marshall");
        rep.addReference(TYPE, OntologicalClasses.DBPEDIA_PERSON.getUnicodeString());
        searcher.addEntity(rep);
        rep = factory.createRepresentation("urn:test:Geologist");
        rep.addNaturalText(NAME, "Geologist");
        rep.addReference(TYPE, NamespaceEnum.skos+"Concept");
        rep.addReference(REDIRECT, "urn:test:redirect:Geologist");
        searcher.addEntity(rep);
        //a redirect
        rep = factory.createRepresentation("urn:test:redirect:Geologist");
        rep.addNaturalText(NAME, "Geologe (redirect)");
View Full Code Here

        rep.addReference(TYPE, OntologicalClasses.DBPEDIA_PERSON.getUnicodeString());
        searcher.addEntity(rep);
        rep = factory.createRepresentation("urn:test:Geologist");
        rep.addNaturalText(NAME, "Geologist");
        rep.addReference(TYPE, NamespaceEnum.skos+"Concept");
        rep.addReference(REDIRECT, "urn:test:redirect:Geologist");
        searcher.addEntity(rep);
        //a redirect
        rep = factory.createRepresentation("urn:test:redirect:Geologist");
        rep.addNaturalText(NAME, "Geologe (redirect)");
        rep.addReference(TYPE, NamespaceEnum.skos+"Concept");
View Full Code Here

        rep.addReference(REDIRECT, "urn:test:redirect:Geologist");
        searcher.addEntity(rep);
        //a redirect
        rep = factory.createRepresentation("urn:test:redirect:Geologist");
        rep.addNaturalText(NAME, "Geologe (redirect)");
        rep.addReference(TYPE, NamespaceEnum.skos+"Concept");
        searcher.addEntity(rep);
        rep = factory.createRepresentation("urn:test:NewZealand");
        rep.addNaturalText(NAME, "New Zealand");
        rep.addReference(TYPE, OntologicalClasses.DBPEDIA_PLACE.getUnicodeString());
        searcher.addEntity(rep);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.