Package org.apache.clerezza.rdf.core

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


        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

        }

        public String getThumbnailSrc() {
            Iterator<Triple> thumbnails = entityProperties.filter(uri, THUMBNAIL, null);
            while (thumbnails.hasNext()) {
                Resource object = thumbnails.next().getObject();
                if (object instanceof UriRef) {
                    return ((UriRef) object).getUnicodeString();
                }
            }
            // if no dbpedia ontology thumbnail was found. try the same with foaf:depiction
            thumbnails = entityProperties.filter(uri, DEPICTION, null);
            while (thumbnails.hasNext()) {
                Resource object = thumbnails.next().getObject();
                if (object instanceof UriRef) {
                    return ((UriRef) object).getUnicodeString();
                }
            }
            return getMissingThumbnailSrc();
View Full Code Here

        }

        public String getSummary() {
            Iterator<Triple> abstracts = entityProperties.filter(uri, SUMMARY, null);
            while (abstracts.hasNext()) {
                Resource object = abstracts.next().getObject();
                if (object instanceof PlainLiteral) {
                    PlainLiteral abstract_ = (PlainLiteral) object;
                    if (new Language("en").equals(abstract_.getLanguage())) {
                        return abstract_.getLexicalForm();
                    }
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

        //the next UriRef. However we are not interested in incoming relations!
        Iterator<Triple> outgoing = source.filter((NonLiteral) node, null, null);
        while (outgoing.hasNext()) {
            Triple triple = outgoing.next();
            target.add(triple);
            Resource object = triple.getObject();
            if(object instanceof BNode){
                //add first and than follow because there might be a triple such as
                // bnode1 <urn:someProperty> bnode1
                visited.add((BNode)object);
                extractRepresentation(source, target, (NonLiteral)object, visited);
View Full Code Here

                     * @return the representation or <code>null</code> if result is
                     * not an UriRef or there is no Representation for the result.
                     */
                    @Override
                    public Representation adapt(SolutionMapping solution, Class<Representation> type) {
                        Resource resource = solution.get(query.getRootVariableName());
                        if(resource instanceof UriRef){
                            try {
                                return getRepresentation((UriRef)resource,false);
                            } catch (IllegalArgumentException e) {
                                log.warn("Unable to create Representation for ID "+resource+"! -> ignore query result");
View Full Code Here

    private void revertObjectName(NonLiteral objectURI, MGraph graph) {
        if (nameResource != null) {
            Iterator<Triple> it = graph.filter(objectURI, CMSAdapterVocabulary.CMS_OBJECT_NAME, null);
            if (it.hasNext()) {
                Triple nameProp = it.next();
                Resource name = nameProp.getObject();
                graph.add(new TripleImpl(objectURI, nameResource, name));
            } else {
                log.warn("Failed to find name property for URI: {}", objectURI);
            }
        }
View Full Code Here

                tracker.failed(request, content, executor);
                return;
            }
            Iterator<Triple> ciIt = graph.filter(null, Properties.ENHANCER_EXTRACTED_FROM, null);
            Assert.assertTrue("Enhancement Results do not caontain a single Enhancement",ciIt.hasNext());
            Resource contentItemUri = ciIt.next().getObject();
            Assert.assertTrue("ContentItem URI is not an UriRef but an instance of "
                    + contentItemUri.getClass().getSimpleName(), contentItemUri instanceof UriRef);
            tracker.succeed(request, (UriRef) contentItemUri, graph, rtt, executor.getContent().length());
        }
View Full Code Here

            StringBuilder stanbolRulesBuilder = new StringBuilder();

            boolean firstIteration = true;
            while (resultSet.hasNext()) {
                SolutionMapping solutionMapping = resultSet.next();
                Resource nameResource = solutionMapping.get("ruleName");
                Resource bodyResource = solutionMapping.get("ruleBody");
                Resource headResource = solutionMapping.get("ruleHead");

                StringBuilder stanbolRuleBuilder = new StringBuilder();
                stanbolRuleBuilder.append(((Literal) nameResource).getLexicalForm());
                stanbolRuleBuilder.append("[");
                stanbolRuleBuilder.append(((Literal) bodyResource).getLexicalForm());
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.