Examples of PlainLiteral


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

   */
  @SuppressWarnings("unchecked")
  private JSONObject writeObject(BNodeManager bNodeMgr, Resource object) {
    JSONObject jObject = new JSONObject();
    if (object instanceof PlainLiteral) {
      PlainLiteral plainLiteral = (PlainLiteral) object;
      jObject.put("value", plainLiteral.getLexicalForm());
      jObject.put("type", "literal");
      if (plainLiteral.getLanguage() != null) {
        jObject.put("lang", plainLiteral.getLanguage().toString());
      }
    } else if (object instanceof TypedLiteral) {
      TypedLiteral literal = (TypedLiteral) object;
      jObject.put("value", literal.getLexicalForm());
      jObject.put("type", "literal");
View Full Code Here

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

        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();
                    }
                }
            }
            return "";
        }
View Full Code Here

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

        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();
                    }
                }
            }
            return "";
        }
View Full Code Here

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

                if (random <= i) {
                    tc.add(new TripleImpl(subject, predicate, lf.createTypedLiteral(count)));
                } else if (random <= d) {
                    tc.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 {
View Full Code Here

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

                   
                    String strValue = currentTriple.getObject().toString();
                    JsonLdPropertyValue jldValue = new JsonLdPropertyValue();

                    if (currentTriple.getObject() instanceof PlainLiteral) {
                        PlainLiteral plain = (PlainLiteral) currentTriple.getObject();
                        if (plain.getLanguage() != null) {
                            jldValue.setLanguage(plain.getLanguage().toString());
                        }
                        strValue = plain.getLexicalForm();
                    }
                    else if (currentTriple.getObject() instanceof TypedLiteral) {
                        TypedLiteral typedObject = (TypedLiteral) currentTriple.getObject();
                        String type = typedObject.getDataType().getUnicodeString();
                        jldValue.setType(type);
View Full Code Here

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

        }

        // filter appears to see plain literals and xsd:strings as differerent
        // so not
        // userNode.addPropertyValue(predicate, newValue);
        PlainLiteral newObject = new PlainLiteralImpl(newValue);
        userNode.addProperty(predicate, newObject);

        if (newObject.equals(oldObject)) {
            return;
        }
        systemGraph.removeAll(oldBuffer);
    }
View Full Code Here

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

        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();
                    }
                }
            }
            return "";
        }
View Full Code Here

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

   
    public void addEntity(Entity rep){
        entities.put(rep.getUri(), rep);
        Iterator<PlainLiteral> labels = rep.getText(nameField);
        while(labels.hasNext()){
            PlainLiteral label = labels.next();
            for(String token : tokenizer.tokenize(label.getLexicalForm(),null)){
                Collection<Entity> values = data.get(token);
                if(values == null){
                    values = new ArrayList<Entity>();
                    data.put(label.getLexicalForm(), values);
                }
                values.add(rep);
            }
        }
       
View Full Code Here

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

            //now the EntityAnnotations for the Suggestions
            for(Suggestion suggestion : linkedEntity.getSuggestions()){
                UriRef entityAnnotation = EnhancementEngineHelper.createEntityEnhancement(ci, this);
                //should we use the label used for the match, or search the
                //representation for the best label ... currently its the matched one
                PlainLiteral label = suggestion.getBestLabel(linkerConfig.getNameField(),language);
                Entity entity = suggestion.getEntity();
                metadata.add(new TripleImpl(entityAnnotation, Properties.ENHANCER_ENTITY_LABEL, label));
                metadata.add(new TripleImpl(entityAnnotation,ENHANCER_ENTITY_REFERENCE, entity.getUri()));
                Iterator<UriRef> suggestionTypes = entity.getReferences(linkerConfig.getTypeField());
                while(suggestionTypes.hasNext()){
View Full Code Here

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

     */
    public PlainLiteral getBestLabel(UriRef nameField, String language){
        Entity rep = getEntity();
        //start with the matched label -> so if we do not find a better one
        //we will use the matched!
        PlainLiteral matchedLabel = getMatchedLabel();
        PlainLiteral label = matchedLabel;
        // 1. check if the returned Entity does has a label -> if not return null
        // add labels (set only a single label. Use "en" if available!
        Iterator<PlainLiteral> labels = rep.getText(nameField);
        boolean matchFound = false;
        while (labels.hasNext() && !matchFound) {
            PlainLiteral actLabel = labels.next();
            if(label == null){
                label = actLabel;
            }
            //now we have already a label check the language
            Language actLang = actLabel.getLanguage();
            //use startWith to match also en-GB and en-US ...
            if (actLang != null && actLang.toString().startsWith(language)) {
                //prefer labels with the correct language
                label = actLabel;
                if(matchedLabel != null && matchedLabel.getLexicalForm().equalsIgnoreCase(label.getLexicalForm())){
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.