Package org.apache.clerezza.rdf.core

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


    @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

        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

                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

public class PlainLiteralImplTest {

   
    @Test public void plainLiteralEquality() {
        String stringValue = "some text";
        PlainLiteral literal1 = new PlainLiteralImpl(stringValue);
        PlainLiteral literal2 = new PlainLiteralImpl(stringValue);       
        Assert.assertEquals(literal1, literal2);
        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
        PlainLiteral literal3 = new PlainLiteralImpl("something else");
        Assert.assertFalse(literal1.equals(literal3));
    }
View Full Code Here

    }
   
    @Test public void languageLiteralEquality() {
        String stringValue = "some text";
        Language lang = new Language("en-ca");
        PlainLiteral literal1 = new PlainLiteralImpl(stringValue, lang);
        PlainLiteral literal2 = new PlainLiteralImpl(stringValue, lang);       
        Assert.assertEquals(literal1, literal2);
        Assert.assertEquals(literal1.hashCode(), literal2.hashCode());
        Language lang2 = new Language("de");
        PlainLiteral literal3 = new PlainLiteralImpl(stringValue, lang2);
        Assert.assertFalse(literal1.equals(literal3));
        PlainLiteral literal4 = new PlainLiteralImpl(stringValue, null);
        Assert.assertFalse(literal3.equals(literal4));
        Assert.assertFalse(literal4.equals(literal3));
    }
View Full Code Here

     * hashCode of the lexical form plus the hashCode of the locale
     */
    @Test public void checkHashCode() {
        String stringValue = "some text";
        Language language = new Language("en");
        PlainLiteral literal = new PlainLiteralImpl(stringValue, language);
        Assert.assertEquals(stringValue.hashCode() + language.hashCode(), literal.hashCode());
    }
View Full Code Here

                   
                    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

            //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

     */
    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

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

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.