Examples of PlainLiteral


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

        Collection<PlainLiteral> defaultLabels = new ArrayList<PlainLiteral>();
        boolean matchedLangLabel = false;
        //avoid matching multiple labels with the exact same lexical.
        Set<String> matchedLabels = new HashSet<String>();
        while(labels.hasNext()){
            PlainLiteral label = labels.next();
            //numLabels++;
            String lang = label.getLanguage() != null ? label.getLanguage().toString() : null;
            String text = label.getLexicalForm();
            //if case-insensitive matching ... compare lower case versions
            if(!linkerConfig.isCaseSensitiveMatching()){
                text = text.toLowerCase(Locale.ROOT);
            }
            if((lang == null && curLang == null) ||
View Full Code Here

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

            log.debug(" > register {}",entity);
        }
        entities.put(entity.getUri(), entity);
        Iterator<PlainLiteral> labels = entity.getText(nameField);
        while(labels.hasNext()){
            PlainLiteral label = labels.next();
            String lang = label.getLanguage() == null ? null : label.getLanguage().toString();
            if(indexLanguages.contains(lang)){
                for(String token : tokenizer.tokenize(label.getLexicalForm(),null)){
                    token = token.toLowerCase(Locale.ROOT);
                    Collection<Entity> values = index.get(token);
                    if(values == null){
                        values = new ArrayList<Entity>();
                        index.put(token, values);
View Full Code Here

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

        boolean containsNull = languageSet.contains(null);
        List<String> results = new ArrayList<String>();
        while (literals.hasNext()) {
            Literal act = literals.next();
            if (act instanceof PlainLiteral) {
                PlainLiteral pl = (PlainLiteral) act;
                if (languageSet.contains(pl.getLanguage())) {
                    results.add(0, pl.getLexicalForm()); //add to front
                }
            } else if (containsNull) { //add also all types Literals, because the do not define an language!
                results.add(act.getLexicalForm()); //append to the end
            }
        }
View Full Code Here

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

     * {@link Representation#get(String, String...)}).
     */
    @Test
    public void testPlainLiteralToTextConversion(){
        String field = "urn:test.RdfRepresentation:test.field";
        PlainLiteral noLangLiteral = new PlainLiteralImpl("A plain literal without Language");
        PlainLiteral enLiteral = new PlainLiteralImpl("An english literal",new Language("en"));
        PlainLiteral deLiteral = new PlainLiteralImpl("Ein Deutsches Literal",new Language("de"));
        PlainLiteral deATLiteral = new PlainLiteralImpl("Ein Topfen Verband hilft bei Zerrungen",new Language("de-AT"));
        Collection<PlainLiteral> plainLiterals = Arrays.asList(noLangLiteral,enLiteral,deLiteral,deATLiteral);
        Representation rep = createRepresentation(null);
        rep.add(field, plainLiterals);
        //now test, that the Plain Literals are available as natural language
        //tests via the Representation Interface!
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

                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

        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

    @Override
    public boolean equals(Object otherObj) {
        if (!(otherObj instanceof PlainLiteral)) {
            return false;
        }
        PlainLiteral other = (PlainLiteral) otherObj;
        if (!lexicalForm.equals(other.getLexicalForm())) {
            return false;
        }
        if (language != null) {
            return language.equals(other.getLanguage());
        }
        if (other.getLanguage() != null) {
            return false;
        }
        return true;
    }
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.ontoware.rdf2go.model.node.PlainLiteral

    // relations
    URI hasName = model.createURI("http://xmlns.com/foaf/0.1/#term_name");
    URI hasAge = model.createURI("http://example.com/relations#age");
    hasTag = model.createURI("http://example.com/relations#hasTag");
    // tags
    PlainLiteral tagJava = model.createPlainLiteral("Java");
    PlainLiteral tagPython = model.createPlainLiteral("Python");
    PlainLiteral tagComputers = model.createPlainLiteral("Computers");
   
    // adding statements
    // naming
    model.addStatement(max, hasName, "Max Völkel");
    model.addStatement(konrad, hasName, "Konrad Völkel");
    model.addStatement(guido, hasName, "Guido van Rossum");
    model.addStatement(james, hasName, "James Gosling");
   
    // a typed property, age
    model.addStatement(konrad, hasAge, model.createDatatypeLiteral("19", XSD._integer));
    model.addStatement(max, hasAge, model.createDatatypeLiteral("29", XSD._integer));
   
    // tagging
    tag(max, tagJava);
    tag(james, tagJava);
    tag(konrad, tagJava);
    tag(konrad, tagPython);
    tag(guido, tagPython);
   
    // simple SPARQL ASK
    System.out.println("Query 1:");
    // ask if max is subject or object of any statement
    String queryString = "ASK { { "+max.toSPARQL()+" ?p ?o } UNION { ?s ?p "+max.toSPARQL()+" } }";
    boolean result = model.sparqlAsk(queryString);
    if(result) {
      System.out.println(max+" is in the graph");
    }
   
    // another SPARQL ASK
    System.out.println("Query 2:");
    // ask if any resource is tagged with tagComputers
    queryString = "ASK { ?resource <"+hasTag+"> "+tagComputers.toSPARQL()+" }";
    if(!model.sparqlAsk(queryString)) {
      System.out.println("nothing is tagged with "+tagComputers);
    }

  }
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.