Package org.apache.clerezza.rdf.core

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


        Entry<UriRef,Blob> textBlob = getBlob(contentItem, supportedMimeTypes);
        if(textBlob == null){
            return;
        }
        String language = EnhancementEngineHelper.getLanguage(contentItem);
        Language lang = language == null ? null : new Language(language);
        String text;
        try {
             text = ContentItemHelper.getText(textBlob.getValue());
        } catch (IOException e) {
            throw new EngineException(this, contentItem, "Unable to read Plain Text Blob", e);
View Full Code Here


        }
        if(writeTextAnnotations){
            Iterator<Span> spans = at.getEnclosed(EnumSet.of(SpanTypeEnum.Sentence,SpanTypeEnum.Chunk));
            Sentence context = null;
            MGraph metadata = ci.getMetadata();
            Language lang = new Language(language);
            LiteralFactory lf = LiteralFactory.getInstance();
            ci.getLock().writeLock().lock();
            try { //write TextAnnotations for Named Entities
                while(spans.hasNext()){
                    Span span = spans.next();
View Full Code Here

        }
        //finally write the NER annotations to the metadata of the ContentItem
        final MGraph metadata = ci.getMetadata();
        ci.getLock().writeLock().lock();
        try {
            Language lang = new Language("ja");
            for(NerData nerData : nerList){
                UriRef ta = EnhancementEngineHelper.createTextEnhancement(ci, this);
                metadata.add(new TripleImpl(ta, ENHANCER_SELECTED_TEXT, new PlainLiteralImpl(
                    at.getSpan().substring(nerData.start, nerData.end),lang)));
                metadata.add(new TripleImpl(ta, DC_TYPE, nerData.tag.getType()));
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);
        }
        Set<UriRef> dereferencedEntitis = new HashSet<UriRef>();
       
        MGraph metadata = ci.getMetadata();
        for(LinkedEntity linkedEntity : linkedEntities){
View Full Code Here

        }
    }

    private void writeComentions(ContentItem ci,Collection<LinkedEntity> comentions, String language,
            Set<UriRef> textAnnotations) {
        Language languageObject = null;
        if(language != null && !language.isEmpty()){
            languageObject = new Language(language);
        }
       
        MGraph metadata = ci.getMetadata();
        //we MUST adjust the confidence level of existing annotations only once
        //se we need to keep track of those
View Full Code Here

            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())){
                    //found label in that language that exactly matches the
                    //label used to match the text
View Full Code Here

   *
   * @param ci
   *            the {@link ContentItem}
   */
  public void computeEnhancements(ContentItem ci) throws EngineException {
    Language language = SpotlightEngineUtils.getContentLanguage(ci);
    String text = SpotlightEngineUtils.getPlainContent(ci);

    Collection<Annotation> dbpslGraph = doPostRequest(text,ci.getUri());
    Map<SurfaceForm,UriRef> surfaceForm2TextAnnotation = new HashMap<SurfaceForm,UriRef>();
    if (dbpslGraph != null) {
View Full Code Here

   *
   * @param ci
   *            the {@link ContentItem}
   */
  public void computeEnhancements(ContentItem ci) throws EngineException {
    Language language = SpotlightEngineUtils.getContentLanguage(ci);
    String text = SpotlightEngineUtils.getPlainContent(ci);

    Collection<SurfaceForm> dbpslGraph = doPostRequest(text,ci.getUri());
    if (dbpslGraph != null) {
      // Acquire a write lock on the ContentItem when adding the
View Full Code Here

      element.put("type", "uri");
      element.put("value", UriRef.class.cast(resource).getUnicodeString());
    } else if (resource instanceof PlainLiteral) {
      element.put("type", "literal");
      element.put("value", PlainLiteral.class.cast(resource).getLexicalForm());
      Language lang = PlainLiteral.class.cast(resource).getLanguage();
      if (lang != null) {
        element.put("xml:lang", lang.toString());
      }
    } else if (resource instanceof TypedLiteral) {
      element.put("type", "typed-literal");
      element.put("datatype", TypedLiteral.class.cast(resource).getDataType().getUnicodeString());
      element.put("value", TypedLiteral.class.cast(resource).getLexicalForm());
View Full Code Here

          .getDataType().getUnicodeString()));
    } else if (resource instanceof PlainLiteral) {
      value = doc.createElement("literal");
      value.appendChild(doc.createTextNode(((PlainLiteral) resource)
          .getLexicalForm()));
      Language lang = ((PlainLiteral) resource).getLanguage();
      if (lang != null) {
        value.setAttribute("xml:lang", (lang.toString()));
      }
    } else {
      value = doc.createElement("bnode");
      value.appendChild(doc.createTextNode("/"));
    }
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.