Package org.apache.clerezza.rdf.core

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


            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


                String bs = bt == 0 ? ((UriRef)b).getUnicodeString() :
                    ((Literal)b).getLexicalForm();
                int sc = as.compareTo(bs);
                if(sc == 0 && at == 1){ //same string value and Literals
                    //check if the language and types are the same
                    Language al = a instanceof PlainLiteral ? ((PlainLiteral)a).getLanguage() : null;
                    Language bl = b instanceof PlainLiteral ? ((PlainLiteral)b).getLanguage() : null;
                    //first try to sort by language
                    if(al == null){
                        sc = bl == null ? 0 : -1;
                    } else if(bl == null){
                        sc = 1;
                    } else {
                        sc = al.toString().compareTo(bl.toString());
                    }
                    if(sc == 0){
                        //if still equals look at the dataType
                        UriRef adt = a instanceof TypedLiteral ? ((TypedLiteral)a).getDataType() : null;
                        UriRef bdt = b instanceof TypedLiteral ? ((TypedLiteral)b).getDataType() : null;
View Full Code Here

        predicateList.add(FOAF.nick);
        predicateList.add(FOAF.homepage);
        predicateList.add(FOAF.age);
        predicateList.add(FOAF.depiction);
        String URI_PREFIX = "http://www.test.org/bigGraph/ref";
        Language DE = new Language("de");
        Language EN = new Language("en");
        Iterator<UriRef> predicates = predicateList.iterator();
        List<BNode> bNodes = new ArrayList<BNode>();
        bNodes.add(new BNode());
        for (int count = 0; tc.size() < triples; count++) {
            random = rnd.nextDouble() * 3;
 
View Full Code Here

   
   
    @Test
    public void testTextAnnotationNewModel(){
        String content = "The Stanbol Enhancer can extract Entities form parsed Text.";
        Language lang = new Language("en");
        int start = content.indexOf("Stanbol");
        int end = start+"Stanbol Enhancer".length();
        UriRef ciUri = new UriRef("http://www.example.org/contentItem#1");
        MGraph metadata = new IndexedMGraph();
        UriRef ta = EnhancementEngineHelper.createTextEnhancement(metadata, dummyEngine, ciUri);
View Full Code Here

     * @param ci
     * @param linkedEntities
     * @param language
     */
    private void writeEnhancements(ContentItem ci, Collection<LinkedEntity> linkedEntities, String language) {
        Language languageObject = null;
        if(language != null && !language.isEmpty()){
            languageObject = new Language(language);
        }
        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()){
                UriRef textAnnotation = EnhancementEngineHelper.createTextEnhancement(ci, this);
                textAnnotations.add(textAnnotation);
                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_START,
                    literalFactory.createTypedLiteral(occurrence.getStart())));
                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_END,
                    literalFactory.createTypedLiteral(occurrence.getEnd())));
                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_SELECTION_CONTEXT,
                    new PlainLiteralImpl(occurrence.getContext(),languageObject)));
                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_SELECTED_TEXT,
                    new PlainLiteralImpl(occurrence.getSelectedText(),languageObject)));
                metadata.add(new TripleImpl(textAnnotation,
                    Properties.ENHANCER_CONFIDENCE,
                    literalFactory.createTypedLiteral(linkedEntity.getScore())));
                for(UriRef dcType : linkedEntity.getTypes()){
                    metadata.add(new TripleImpl(
                        textAnnotation, Properties.DC_TYPE, dcType));
                }
            }
            //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
                Text label = suggestion.getBestLabel(linkerConfig.getNameField(),language);
                metadata.add(new TripleImpl(entityAnnotation,
                    Properties.ENHANCER_ENTITY_LABEL,
                    label.getLanguage() == null ?
                            new PlainLiteralImpl(label.getText()) :
                                new PlainLiteralImpl(label.getText(),
                                    new Language(label.getLanguage()))));
                metadata.add(new TripleImpl(entityAnnotation,
                    Properties.ENHANCER_ENTITY_REFERENCE,
                    new UriRef(suggestion.getRepresentation().getId())));
                Iterator<Reference> suggestionTypes = suggestion.getRepresentation().getReferences(linkerConfig.getTypeField());
                while(suggestionTypes.hasNext()){
View Full Code Here

        List<SentimentPhrase> sentiments = extractSentiments(at, language);
        String detectedLang = EnhancementEngineHelper.getLanguage(ci);
        ci.getLock().writeLock().lock();
        try {
            writeSentimentEnhancements(ci,sentiments,at,
                detectedLang == null ? null : new Language(detectedLang));
        } finally {
            ci.getLock().writeLock().unlock();
        }
       
    }
View Full Code Here

    }
        String language = EnhancementEngineHelper.getLanguage(ci);
        if (language == null) {
            throw new IllegalStateException("Unable to extract Language for " + "ContentItem " + ci.getUri() + ": This is also checked in the canEnhance " + "method! -> This indicated an Bug in the implementation of the " + "EnhancementJobManager!");
        }
        Language lang = new Language(language); //used for the palin literals in TextAnnotations
    try {
      List<NamedEntity> lista = this.client.extractEntities(text, language);
      LiteralFactory literalFactory = LiteralFactory.getInstance();

      MGraph g = ci.getMetadata();
View Full Code Here

            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

            + ci.getUri() + " is not supported by this Engine: "
            + "This is also checked in the canEnhance method! -> This "
          + "indicated an Bug in the implementation of the "
          + "EnhancementJobManager!");
    } else {
      return lang == null || lang.isEmpty() ? null : new Language(lang);
    }
  }
View Full Code Here

      EnhancementEngine engine, ContentItem ci, UriRef textAnnotation) {
    UriRef entityAnnotation = EnhancementEngineHelper
        .createEntityEnhancement(ci, engine);
    MGraph model = ci.getMetadata();
    Literal label = new PlainLiteralImpl(resource.label,
        new Language("en"));
    model.add(new TripleImpl(entityAnnotation, DC_RELATION,
        textAnnotation));
    model.add(new TripleImpl(entityAnnotation,
        ENHANCER_ENTITY_LABEL, label));
    model.add(new TripleImpl(entityAnnotation,
View Full Code Here

TOP

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

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.