Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.Resource


    private static Set<String> getRdfTypes(MGraph graph, UriRef node) {
        Iterator<Triple> typeStatements = graph.filter(node, Properties.RDF_TYPE, null);
        Set<String> typeStrings = new HashSet<String>();
        while(typeStatements.hasNext()){
            Resource type = typeStatements.next().getObject();
            assertTrue(type instanceof UriRef);
            typeStrings.add(((UriRef)type).getUnicodeString());
        }
        return typeStrings;
    }
View Full Code Here


        //create the content Item with the HTML content
        MGraph rdfData = parseRdfData(parser,"metadata.rdf.zip");
        UriRef contentItemId = null;
        Iterator<Triple> it = rdfData.filter(null, Properties.ENHANCER_EXTRACTED_FROM, null);
        while(it.hasNext()){
            Resource r = it.next().getObject();
            if(contentItemId == null){
                if(r instanceof UriRef){
                    contentItemId = (UriRef)r;
                }
            } else {
View Full Code Here

    public void testContent() throws LDPathParseException {
        Collection<Resource> result = ldpath.pathQuery(ci.getUri(), "fn:content(\"text/plain\")", null);
        assertNotNull(result);
        assertFalse(result.isEmpty());
        assertTrue(result.size() == 1);
        Resource r = result.iterator().next();
        assertTrue(r instanceof Literal);
        String content = ((Literal)r).getLexicalForm();
        assertEquals(content, textContent);
       
        result = ldpath.pathQuery(ci.getUri(), "fn:content(\"text/html\")", null);
View Full Code Here

        path = "fn:textAnnotation(.)[dc:type is dbpedia-ont:Person]/fise:selected-text";
        result = ldpath.pathQuery(ci.getUri(), path, null);
        assertNotNull(result);
        assertFalse(result.isEmpty());
        assertTrue(result.size() == 1);
        Resource r = result.iterator().next();
        assertTrue(r instanceof Literal);
        assertEquals(((Literal)r).getLexicalForm(), "Bob Marley");

    }
View Full Code Here

        path = "fn:enhancement(.)/dc:language";
        result = ldpath.pathQuery(ci.getUri(), path, null);
        assertNotNull(result);
        assertFalse(result.isEmpty());
        assertTrue(result.size() == 1);
        Resource r = result.iterator().next();
        assertTrue(r instanceof Literal);
        assertEquals("en",((Literal)r).getLexicalForm());
    }
View Full Code Here

        //create the content Item with the HTML content
        MGraph rdfData = parseRdfData(parser,"example.rdf.zip");
        UriRef contentItemId = null;
        Iterator<Triple> it = rdfData.filter(null, Properties.ENHANCER_EXTRACTED_FROM, null);
        while(it.hasNext()){
            Resource r = it.next().getObject();
            if(contentItemId == null){
                if(r instanceof UriRef){
                    contentItemId = (UriRef)r;
                }
            } else {
View Full Code Here

            // traverse selected text assertions
            MGraph queryTermMetadata = ci.getMetadata();
            Iterator<Triple> textAnnotations = queryTermMetadata.filter(null,
                Properties.ENHANCER_SELECTED_TEXT, null);
            while (textAnnotations.hasNext()) {
                Resource r = textAnnotations.next().getObject();
                String selectedText = "";
                if (r instanceof Literal) {
                    selectedText = ((Literal) r).getLexicalForm();
                } else {
                    selectedText = r.toString();
                }

                tokenizedTerms.add(selectedText);
            }

            // get language of the query term
            String language = "en";
            Iterator<Triple> lanIt = queryTermMetadata.filter(null, Properties.DC_LANGUAGE, null);
            if (lanIt.hasNext()) {
                Resource r = lanIt.next().getObject();
                if (r instanceof Literal) {
                    language = ((Literal) r).getLexicalForm();
                } else {
                    language = r.toString();
                }
            }
            /*
             * If there is no stopword list for the language detected, it is highly possible that the default
             * language is detected is false. As English is the most common language, it is set as default.
View Full Code Here

     * @throws IOException
     */
    @Test
    public void testUploadWithMetadata() throws IOException {
        //create the metadata
        Resource user = new PlainLiteralImpl("Rupert Westenthaler");
        final UriRef contentItemId = new UriRef("http://www.example.com/test.html");
        MGraph metadata = new SimpleMGraph();
        addTagAsTextAnnotation(metadata, contentItemId,
            "Germany",DBPEDIA_PLACE, user);
        addTagAsTextAnnotation(metadata, contentItemId,
View Full Code Here

        doc.addField(SolrFieldName.TITLE.toString(), title);
        try {
            Iterator<Triple> it = ci.getMetadata().filter(null, Properties.ENHANCER_ENTITY_REFERENCE, null);
            Set<String> contexts = new HashSet<String>();
            while (it.hasNext()) {
                Resource r = it.next().getObject();
                if (r instanceof UriRef) {
                    contexts.add(((UriRef) r).getUnicodeString());
                }
            }
            Map<String,Collection<?>> results = semanticIndexManager.executeProgram(ldProgramName, contexts,
View Full Code Here

        ResultSet result = tcManager.executeSparqlQuery(query, ci.getMetadata());
        List<String> values = new ArrayList<String>();
        while (result.hasNext()) {
            SolutionMapping sol = result.next();
            Resource res = sol.get(fieldName.toString());
            if (res == null) continue;
            String value = res.toString();
            if (res instanceof Literal) {
                value = ((Literal) res).getLexicalForm();
            }
            value = value.replaceAll("_", " ");
            values.add(value);
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.Resource

Copyright © 2018 www.massapicom. 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.