Package org.apache.clerezza.rdf.core.impl

Examples of org.apache.clerezza.rdf.core.impl.PlainLiteralImpl


 
  @Test
  public void graphSize() {
    UriRef uri = new UriRef("http://example.org/foo#bar");
    MGraph mGraph = new SimpleMGraph();
    mGraph.add(new TripleImpl(uri, uri, new PlainLiteralImpl("bla bla")));
    com.hp.hpl.jena.graph.Graph graph = new JenaGraph(mGraph);
    Assert.assertEquals(1, graph.size());
  }
View Full Code Here


        } else if (random <= d) {
          mGraph.add(new TripleImpl(subject, predicate, lf.createTypedLiteral(random)));
        } else {
          PlainLiteral text;
          if (random <= i) {
            text = new PlainLiteralImpl("Literal for " + count);
          } else if (random <= d) {
            text = new PlainLiteralImpl("An English literal for " + count, EN);
          } else {
            text = new PlainLiteralImpl("Ein Dutsches Literal für " + count, DE);
          }
          mGraph.add(new TripleImpl(subject, predicate, text));
        }
      } else if (random <= b) { //bnode
        BNode bnode;
View Full Code Here

                    new TypedLiteralImpl(value.toString(),new UriRef(dataType.toString()))));
          } else if (values.containsKey("lang")
              && !values.get("lang").equals("")
              && values.get("lang") != null) {
            mGraph.add(new TripleImpl(subject, new UriRef((String) predicate),
                new PlainLiteralImpl(value, new Language((String) values.get("lang")))));
          } else {
            mGraph.add(new TripleImpl(subject, new UriRef((String) predicate), new PlainLiteralImpl(value)));
          }
        } else if (values.get("type").equals("uri")) {
          mGraph.add(new TripleImpl(subject, new UriRef((String) predicate), new UriRef(value)));
        } else if (values.get("type").equals("bnode")) {
          NonLiteral bNode = bNodeMgr.getBNode(value);
View Full Code Here

      for (SentimentExpression se : lista) {
        try {
          UriRef textAnnotation = EnhancementEngineHelper.createTextEnhancement(ci, this);
          //add selected text as PlainLiteral in the language extracted from the text
          g.add(new TripleImpl(textAnnotation, ENHANCER_SELECTED_TEXT,  new PlainLiteralImpl(se.getSnippetStr(),lang)));
          g.add(new TripleImpl(textAnnotation, DC_TYPE, CeliConstants.SENTIMENT_EXPRESSION));
          if (se.getStartSnippet() != null && se.getEndSnippet() != null) {
            g.add(new TripleImpl(textAnnotation, ENHANCER_START, literalFactory.createTypedLiteral(se.getStartSnippet().intValue())));
            g.add(new TripleImpl(textAnnotation, ENHANCER_END, literalFactory.createTypedLiteral(se.getEndSnippet().intValue())));
            g.add(new TripleImpl(textAnnotation, ENHANCER_SELECTION_CONTEXT,
                  new PlainLiteralImpl(getSelectionContext(text, se.getSnippetStr(), se.getStartSnippet()), lang)));
            g.add(new TripleImpl(textAnnotation, CeliConstants.HAS_SENTIMENT_EXPRESSION_POLARITY, literalFactory.createTypedLiteral(se.getSentimentPolarityAsDoubleValue())));
          }
        } catch (NoConvertorException e) {
          log.error(e.getMessage(), e);
        }
View Full Code Here

        List<CeliMorphoFeatures> mFeatures = this.convertLexicalEntryToMorphFeatures(le, language);
        for (CeliMorphoFeatures feat : mFeatures) {
          // Create a text annotation for each interpretation produced by the morphological analyzer
          UriRef textAnnotation = EnhancementEngineHelper.createTextEnhancement(ci, this);
          g.add(new TripleImpl(textAnnotation, ENHANCER_SELECTED_TEXT, new PlainLiteralImpl(le.getWordForm(), lang)));
          if (le.from >= 0 && le.to > 0) {
            g.add(new TripleImpl(textAnnotation, ENHANCER_START, literalFactory.createTypedLiteral(le.from)));
            g.add(new TripleImpl(textAnnotation, ENHANCER_END, literalFactory.createTypedLiteral(le.to)));
            g.add(new TripleImpl(textAnnotation, ENHANCER_SELECTION_CONTEXT, new PlainLiteralImpl(getSelectionContext(text, le.getWordForm(), le.from), lang)));
          }
          g.addAll(feat.featuresAsTriples(textAnnotation, lang));
        }
      }
    } finally {
View Full Code Here

    }
    // get a write lock before writing the enhancements
    ci.getLock().writeLock().lock();
    try {
      UriRef textEnhancement = EnhancementEngineHelper.createTextEnhancement(ci, this);
      g.add(new TripleImpl(textEnhancement, CeliLemmatizerEnhancementEngine.hasLemmaForm, new PlainLiteralImpl(lemmatizedContents, lang)));
    } finally {
      ci.getLock().writeLock().unlock();
    }
  }
View Full Code Here

                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_END,
                    endLiteral));
                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_SELECTION_CONTEXT,
                    new PlainLiteralImpl(getSelectionContext(text, tag.getAnchor(),
                        tag.getStart()),languageObject)));
                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_SELECTED_TEXT,
                    new PlainLiteralImpl(tag.getAnchor(),languageObject)));
                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_CONFIDENCE,
                    literalFactory.createTypedLiteral(tag.getScore())));
            } else { //if existing add this engine as contributor
                metadata.add(new TripleImpl(textAnnotation, DC_CONTRIBUTOR,
                    new PlainLiteralImpl(this.getClass().getName())));
            }
            //add dc:types (even to existing)
            for(UriRef dcType : getDcTypes(tag.getSuggestions())){
                metadata.add(new TripleImpl(
                    textAnnotation, Properties.DC_TYPE, dcType));
View Full Code Here

        //not create the fise:TopicAnnotations
        for (Concept ne : lista) {
            UriRef topicAnnotation = EnhancementEngineHelper.createTopicEnhancement(ci, this);
              g.add(new TripleImpl(topicAnnotation, ENHANCER_ENTITY_REFERENCE, ne.getUri()));
                g.add(new TripleImpl(topicAnnotation, ENHANCER_ENTITY_LABEL,
                    new PlainLiteralImpl(ne.getLabel())));
                //TODO: currently I use owl:class as entity-type, because that is
                //      what the linked dbpedia ontology resources are.
                g.add(new TripleImpl(topicAnnotation, ENHANCER_ENTITY_TYPE, OWL_CLASS));
                g.add(new TripleImpl(topicAnnotation, ENHANCER_CONFIDENCE,
                    literalFactory.createTypedLiteral(ne.getConfidence())));
View Full Code Here

                //load the ID
                values.put(FieldType.id, doc.get(idField));
                //load the labels
                Set<Literal> labels = new HashSet<Literal>();
                for(String label : doc.getValues(labelField)){
                    labels.add(new PlainLiteralImpl(label, labelLang));
                }
                if(defaultLabelField != null){
                    for(String label : doc.getValues(defaultLabelField)){
                        labels.add(new PlainLiteralImpl(label, defaultLabelLang));
                    }
                }
                values.put(FieldType.label, labels);
                //load the types
                if(typeField != null){
View Full Code Here

     */
    public static UriRef writeSpan(MGraph graph, UriRef base, AnalysedText text, Language language, Span span){
        UriRef segment = getNifOffsetURI(base, span.getStart(), span.getEnd());
        graph.add(new TripleImpl(segment, RDF_TYPE, StringOntology.OffsetBasedString.getUri()));
        graph.add(new TripleImpl(segment, StringOntology.anchorOf.getUri(),
            new PlainLiteralImpl(span.getSpan(),language)));
        graph.add(new TripleImpl(segment, StringOntology.beginIndex.getUri(),
            lf.createTypedLiteral(span.getStart())));
        graph.add(new TripleImpl(segment, StringOntology.endIndex.getUri(),
            lf.createTypedLiteral(span.getEnd())));
        switch (span.getType()) {
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.impl.PlainLiteralImpl

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.