Package org.apache.clerezza.rdf.core

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


     * @param graph
     * @param execution
     * @param message An optional message why this execution was skipped
     */
    public static void setExecutionSkipped(MGraph graph,NonLiteral execution,String message){
        Literal dateTime = lf.createTypedLiteral(new Date());
        setStatus(graph, execution,STATUS_SKIPPED);
        graph.add(new TripleImpl(execution, STARTED, dateTime));
        graph.add(new TripleImpl(execution, COMPLETED, dateTime));
        if(message != null){
            graph.add(new TripleImpl(execution, STATUS_MESSAGE, new PlainLiteralImpl(message)));
View Full Code Here


     * the current time
     * @param graph
     * @param execution
     */
    public static void setExecutionInProgress(MGraph graph,NonLiteral execution){
        Literal dateTime = lf.createTypedLiteral(new Date());
        setStatus(graph, execution,STATUS_IN_PROGRESS);
        graph.add(new TripleImpl(execution, STARTED, dateTime));
    }
View Full Code Here

     * @return a collection of all existing/created text annotations for the parsed anchor
     */
    private Collection<NonLiteral> processTextAnnotation(MGraph enhancements, String text, UriRef ciId, String anchor, Double confidence) {
        Collection<NonLiteral> textAnnotations = new ArrayList<NonLiteral>();
        int anchorLength = anchor.length();
        Literal anchorLiteral = new PlainLiteralImpl(anchor);
        //first search for existing TextAnnotations for the anchor
        Map<Integer, Collection<NonLiteral>> existingTextAnnotationsMap = searchExistingTextAnnotations(enhancements, anchorLiteral);

        for (int current = text.indexOf(anchor); current >= 0; current = text.indexOf(anchor, current + 1)) {
            Collection<NonLiteral> existingTextAnnotations = existingTextAnnotationsMap.get(current);
View Full Code Here

        // check if the selected text is added
        assertTrue(selectedTextIterator.hasNext());
        // test if the selected text is part of the TEXT_TO_TEST
        Resource object = selectedTextIterator.next().getObject();
        assertTrue(object instanceof Literal);
        Literal selectedText = (Literal)object;
        object = null;
        assertTrue(SINGLE_SENTENCE.contains(selectedText.getLexicalForm()));
        // test if context is added
        Iterator<Triple> selectionContextIterator = g.filter(textAnnotation,
                ENHANCER_SELECTION_CONTEXT, null);
        assertTrue(selectionContextIterator.hasNext());
        // test if the selected text is part of the TEXT_TO_TEST
        object = selectionContextIterator.next().getObject();
        assertTrue(object instanceof Literal);
        assertTrue(SINGLE_SENTENCE.contains(((Literal) object).getLexicalForm()));
        object = null;
        //test start/end if present
        Iterator<Triple> startPosIterator = g.filter(textAnnotation,
                ENHANCER_START, null);
        Iterator<Triple> endPosIterator = g.filter(textAnnotation,
                ENHANCER_END, null);
        //start end is optional, but if start is present, that also end needs to be set
        if(startPosIterator.hasNext()){
            Resource resource = startPosIterator.next().getObject();
            //only a single start position is supported
            assertTrue(!startPosIterator.hasNext());
            assertTrue(resource instanceof TypedLiteral);
            TypedLiteral startPosLiteral = (TypedLiteral) resource;
            resource = null;
            int start = LiteralFactory.getInstance().createObject(Integer.class, startPosLiteral);
            startPosLiteral = null;
            //now get the end
            //end must be defined if start is present
            assertTrue(endPosIterator.hasNext());
            resource = endPosIterator.next().getObject();
            //only a single end position is supported
            assertTrue(!endPosIterator.hasNext());
            assertTrue(resource instanceof TypedLiteral);
            TypedLiteral endPosLiteral = (TypedLiteral) resource;
            resource = null;
            int end = LiteralFactory.getInstance().createObject(Integer.class, endPosLiteral);
            endPosLiteral = null;
            //check for equality of the selected text and the text on the selected position in the content
            //System.out.println("TA ["+start+"|"+end+"]"+selectedText.getLexicalForm()+"<->"+content.substring(start,end));
            assertEquals(content.substring(start, end), selectedText.getLexicalForm());
        } else {
            //if no start position is present, there must also be no end position defined
            assertTrue(!endPosIterator.hasNext());
        }
    }
View Full Code Here

            }
        }
        if (label == null) {
            return null;
        }
        Literal literal;
        if (label.getLanguage() == null) {
            literal = new PlainLiteralImpl(label.getText());
        } else {
            literal = new PlainLiteralImpl(label.getText(), new Language(label.getLanguage()));
        }
View Full Code Here

        // check if the selected text is added
        assertTrue(selectedTextIterator.hasNext());
        // test if the selected text is part of the TEXT_TO_TEST
        Resource object = selectedTextIterator.next().getObject();
        assertTrue(object instanceof Literal);
        Literal selectedText = (Literal)object;
        object = null;
        assertTrue(content.indexOf(selectedText.getLexicalForm()) >= 0);
        // test if context is added
        //context not present for Zemanta
//        Iterator<Triple> selectionContextIterator = g.filter(textAnnotation,
//                Properties.ENHANCER_SELECTION_CONTEXT, null);
//        assertTrue(selectionContextIterator.hasNext());
//        // test if the selected text is part of the TEXT_TO_TEST
//        object = selectionContextIterator.next().getObject();
//        assertTrue(object instanceof Literal);
//        assertTrue(content.indexOf(((Literal)object).getLexicalForm()) >= 0);
//        object = null;
        //test start/end if present
        Iterator<Triple> startPosIterator = g.filter(textAnnotation,
                ENHANCER_START, null);
        Iterator<Triple> endPosIterator = g.filter(textAnnotation,
                ENHANCER_END, null);
        //start end is optional, but if start is present, that also end needs to be set
        if(startPosIterator.hasNext()){
            Resource resource = startPosIterator.next().getObject();
            //only a single start position is supported
            assertTrue(!startPosIterator.hasNext());
            assertTrue(resource instanceof TypedLiteral);
            TypedLiteral startPosLiteral = (TypedLiteral) resource;
            resource = null;
            int start = LiteralFactory.getInstance().createObject(Integer.class, startPosLiteral);
            startPosLiteral = null;
            //now get the end
            //end must be defined if start is present
            assertTrue(endPosIterator.hasNext());
            resource = endPosIterator.next().getObject();
            //only a single end position is supported
            assertTrue(!endPosIterator.hasNext());
            assertTrue(resource instanceof TypedLiteral);
            TypedLiteral endPosLiteral = (TypedLiteral) resource;
            resource = null;
            int end = LiteralFactory.getInstance().createObject(Integer.class, endPosLiteral);
            endPosLiteral = null;
            //check for equality of the selected text and the text on the selected position in the content
            //System.out.println("TA ["+start+"|"+end+"]"+selectedText.getLexicalForm()+"<->"+content.substring(start,end));
            assertTrue(content.substring(start, end).equals(selectedText.getLexicalForm()));
        } else {
            //if no start position is present, there must also be no end position defined
            assertTrue(!endPosIterator.hasNext());
        }
    }
View Full Code Here

            }
        }
        if (label == null) {
            return null;
        }
        Literal literal;
        if (label.getLanguage() == null) {
            literal = new PlainLiteralImpl(label.getText());
        } else {
            literal = new PlainLiteralImpl(label.getText(), new Language(label.getLanguage()));
        }
View Full Code Here

                }
                target.createGraph((UriRef)graphGN.getNode(), extracted);
            }
        }
        for (Map.Entry<String, TripleCollection> pathTcPair : extractedTc.entrySet()) {
            Literal fileNameLit = LiteralFactory.getInstance().createTypedLiteral(
                        pathTcPair.getKey());
            Iterator<Triple> graphResIterator = metaGraph.filter(null, BACKUP.file, fileNameLit);
        }
    }
View Full Code Here

        MGraph metadata = ci.getMetadata();
        for(LinkedEntity linkedEntity : linkedEntities){
            Collection<UriRef> textAnnotations = new ArrayList<UriRef>(linkedEntity.getOccurrences().size());
            //first create the TextAnnotations for the Occurrences
            for(Occurrence occurrence : linkedEntity.getOccurrences()){
                Literal startLiteral = literalFactory.createTypedLiteral(occurrence.getStart());
                Literal endLiteral = literalFactory.createTypedLiteral(occurrence.getEnd());
                //search for existing text annotation
                Iterator<Triple> it = metadata.filter(null, ENHANCER_START, startLiteral);
                UriRef textAnnotation = null;
                while(it.hasNext()){
                    Triple t = it.next();
View Full Code Here

        UriRef textAnnotation = textAnnotationsMap.get(occ.surfaceForm);
        MGraph model = ci.getMetadata();
        UriRef entityAnnotation = EnhancementEngineHelper
            .createEntityEnhancement(ci, this);
        entityAnnotationMap.put(occ.uri, entityAnnotation);
        Literal label = new PlainLiteralImpl(occ.surfaceForm.name, language);
        model.add(new TripleImpl(entityAnnotation, DC_RELATION,
            textAnnotation));
        model.add(new TripleImpl(entityAnnotation,
            ENHANCER_ENTITY_LABEL, label));
View Full Code Here

TOP

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

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.