當前位置: 首頁>>代碼示例>>Java>>正文


Java TagSet類代碼示例

本文整理匯總了Java中org.apache.stanbol.enhancer.nlp.model.tag.TagSet的典型用法代碼示例。如果您正苦於以下問題:Java TagSet類的具體用法?Java TagSet怎麽用?Java TagSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TagSet類屬於org.apache.stanbol.enhancer.nlp.model.tag包,在下文中一共展示了TagSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addCommonPunctationTags

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
/**
 * Freeling defines common POS tags for Punctiations in the the 
 * <code>common/punct.dat</code> file.<p>
 * Those are used for all/most lanugages. This method adds those mappings
 * to the parsed tagset.
 * @param tagset the {@link TagSet} to add the punctation POS mappings
 */
private static void addCommonPunctationTags(TagSet<PosTag> tagset){
    tagset.addTag(new PosTag("Fp",Pos.Point));
    tagset.addTag(new PosTag("Fs",Pos.SuspensionPoints));
    tagset.addTag(new PosTag("Fd",Pos.Colon));
    tagset.addTag(new PosTag("Fx",Pos.SemiColon));
    tagset.addTag(new PosTag("Ft",Pos.SecondaryPunctuation)); //%
    tagset.addTag(new PosTag("Fg",Pos.Hyphen));
    tagset.addTag(new PosTag("Fe",Pos.Quote));
    tagset.addTag(new PosTag("Fh",Pos.Slash));
    tagset.addTag(new PosTag("Fpa",Pos.OpenBracket));
    tagset.addTag(new PosTag("Fpt",Pos.CloseBracket));
    tagset.addTag(new PosTag("Fia",Pos.InterrogativeQuantifier));
    tagset.addTag(new PosTag("Fit",Pos.QuestionMark));
    tagset.addTag(new PosTag("Faa",Pos.InterrogativeQuantifier));
    tagset.addTag(new PosTag("Fat",Pos.ExclamativePoint));
    tagset.addTag(new PosTag("Fc", Pos.ParentheticalPunctuation));
    tagset.addTag(new PosTag("Fca",Pos.OpenSquareBracket));
    tagset.addTag(new PosTag("Fct",Pos.CloseSquareBracket));
    tagset.addTag(new PosTag("Fla",Pos.OpenCurlyBracket));
    tagset.addTag(new PosTag("Flt",Pos.CloseSquareBracket));
    tagset.addTag(new PosTag("Fra",Pos.OpenAngleBracket));
    tagset.addTag(new PosTag("Frc",Pos.CloseAngleBracket));
    tagset.addTag(new PosTag("Fz",Pos.SecondaryPunctuation)); //other
}
 
開發者ID:insideout10,項目名稱:stanbol-freeling,代碼行數:32,代碼來源:TagSetRegistry.java

示例2: addPosTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
private void addPosTagSet(TagSet<PosTag> model) {
    for(String lang : model.getLanguages()){
        if(posModels.put(lang, model) != null){
            throw new IllegalStateException("Multiple Pos Models for Language '"
                + lang+"'! This is an error in the static confituration of "
                + "this class!");
        }
    }
}
 
開發者ID:westei,項目名稱:stanbol-talismane,代碼行數:10,代碼來源:TagSetRegistry.java

示例3: addNerTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
private void addNerTagSet(TagSet<NerTag> model) {
    for(String lang : model.getLanguages()){
        if(nerModels.put(lang, model) != null){
            throw new IllegalStateException("Multiple NER Models for Language '"
                + lang+"'! This is an error in the static confituration of "
                + "this class!");
        }
    }
}
 
開發者ID:westei,項目名稱:stanbol-stanfordnlp,代碼行數:10,代碼來源:TagSetRegistry.java

示例4: addDependencyTreeTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
private void addDependencyTreeTagSet(TagSet<GrammaticalRelationTag> model) {
    for(String lang : model.getLanguages()) {
        if(gramRelationModels.put(lang, model) != null) {
            throw new IllegalStateException("Multiple Dependency Models for Language '"
                + lang+"'! This is an error in the static configuration of "
                + "this class!");
        }
    }
}
 
開發者ID:westei,項目名稱:stanbol-stanfordnlp,代碼行數:10,代碼來源:TagSetRegistry.java

示例5: getPosTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
/**
 * Getter for the {@link PosTag} {@link TagSet} by language. If no {@link TagSet}
 * is available for an Language this will return <code>null</code>
 * @param language the language
 * @return the AnnotationModel or <code>null</code> if non is defined
 */
public TagSet<PosTag> getPosTagSet(String language){
    for(String lang : parseLanguage(language)){
        TagSet<PosTag> tagset = posModels.get(lang);
        if(tagset != null){
            log.debug("select {} POS tagset for language {}", lang, language);
            return tagset;
        }
    }
    log.debug("No POS tagset registered for language {}", language);
    return null;
}
 
開發者ID:westei,項目名稱:stanbol-stanfordnlp,代碼行數:18,代碼來源:TagSetRegistry.java

示例6: getNerTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
/**
 * Getter for the {@link NerTag} {@link TagSet} by language. If no {@link TagSet}
 * is available for an Language this will return <code>null</code>
 * @param language the language
 * @return the AnnotationModel or <code>null</code> if non is defined
 */
public TagSet<NerTag> getNerTagSet(String language){
    for(String lang : parseLanguage(language)){
        TagSet<NerTag>  tagset = nerModels.get(lang);
        if(tagset != null){
            log.debug("select {} NER tagset for language {}", lang, language);
            return tagset;
        }
    }
    return DEFAULT_NER_TAGSET; //fallback to default 
}
 
開發者ID:westei,項目名稱:stanbol-stanfordnlp,代碼行數:17,代碼來源:TagSetRegistry.java

示例7: getGrammaticalRelationTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
/**
 * Getter for the {@link GrammaticalRelationTag} {@link TagSet} by language. If no {@link TagSet}
 * is available for an Language this will return <code>null</code>
 * @param language the language
 * @return the AnnotationModel or <code>null</code> if non is defined
 */
public TagSet<GrammaticalRelationTag> getGrammaticalRelationTagSet(String language) {
    for(String lang : parseLanguage(language)){
        TagSet<GrammaticalRelationTag> tagset = gramRelationModels.get(language);
        if(tagset != null){
            log.debug("select {} GrammaticalRelationTag tagset for language {}", lang, language);
            return tagset;
        }
    }
    log.debug("No GrammaticalRelationTag tagset registered for language {}", language);
    return null;
}
 
開發者ID:westei,項目名稱:stanbol-stanfordnlp,代碼行數:18,代碼來源:TagSetRegistry.java

示例8: addPhraseTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
private void addPhraseTagSet(TagSet<PhraseTag> model) {
    for(String lang : model.getLanguages()){
        if(phraseModels.put(lang, model) != null){
            throw new IllegalStateException("Multiple Phrase Models for Language '"
                + lang+"'! This is an error in the static confituration of "
                + "this class!");
        }
    }
}
 
開發者ID:insideout10,項目名稱:stanbol-freeling,代碼行數:10,代碼來源:TagSetRegistry.java

示例9: addNerTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
private void addNerTagSet(TagSet<NerTag> model) {
    for(String lang : model.getLanguages()){
        if(nerModels.put(lang, model) != null){
            throw new IllegalStateException("Multiple Ner Models for Language '"
                + lang+"'! This is an error in the static confituration of "
                + "this class. Please report this to the stanbol-dev mailing"
                + "list!");
        }
    }
}
 
開發者ID:insideout10,項目名稱:stanbol-freeling,代碼行數:11,代碼來源:TagSetRegistry.java

示例10: addCommonNumberTags

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
/**
 * Tags assigned by the Quantity Recognition Module
 * @param tagset
 */
private static void addCommonNumberTags(TagSet<PosTag> tagset){
    tagset.addTag(new PosTag("Z", Pos.CardinalNumber));
    //workaround for cutting the first to letters from Z00000 (same as Z)
    tagset.addTag(new PosTag("Z0", Pos.CardinalNumber));
    tagset.addTag(new PosTag("Zu", Pos.CardinalNumber));
    tagset.addTag(new PosTag("Zm", Pos.CardinalNumber));
    tagset.addTag(new PosTag("Zp", Pos.CardinalNumber));
    tagset.addTag(new PosTag("Zd", Pos.CardinalNumber));
}
 
開發者ID:insideout10,項目名稱:stanbol-freeling,代碼行數:14,代碼來源:TagSetRegistry.java

示例11: validateAnalysedText

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
private void validateAnalysedText(String text, AnalysedText at, TagSet<PosTag> tagset){
    Assert.assertNotNull(text);
    Assert.assertNotNull(at);
    //Assert the AnalysedText
    Assert.assertEquals(0, at.getStart());
    Assert.assertEquals(text.length(), at.getEnd());
    Iterator<Span> it = at.getEnclosed(EnumSet.allOf(SpanTypeEnum.class));
    while(it.hasNext()){
        //validate that the span|start|end corresponds with the Text
        Span span = it.next();
        Assert.assertNotNull(span);
        Assert.assertEquals(text.substring(span.getStart(), span.getEnd()), 
            span.getSpan());
        switch (span.getType()) {
            case Token:
                double prevProb = -1;
                List<Value<PosTag>> posTags = span.getAnnotations(POS_ANNOTATION);
                Assert.assertTrue("All Tokens need to have a PosTag (missing for "
                    + span+ ")", posTags != null && !posTags.isEmpty());
                for(Value<PosTag> posTag : posTags){
                    //assert Mapped PosTags
                    Assert.assertTrue("PosTag "+posTag+" used by "+span+" is not present in the PosTagSet",
                        tagset.getTag(posTag.value().getTag()) != null);
                    //assert declining probabilities
                    Assert.assertTrue("Wrong order in "+posTags+" of "+span+"!",
                        prevProb < 0 || posTag.probability() <= prevProb);
                    prevProb = posTag.probability();
                }
                Assert.assertNull("Tokens MUST NOT have Phrase annotations!",
                    span.getAnnotation(PHRASE_ANNOTATION));
                Assert.assertNull("Tokens MUST NOT have NER annotations!",
                    span.getAnnotation(NER_ANNOTATION));
                break;
            case Chunk:
                Assert.assertNull("Chunks MUST NOT have POS annotations!",
                    span.getAnnotation(POS_ANNOTATION));
                prevProb = -1;
                List<Value<NerTag>> nerTags = span.getAnnotations(NER_ANNOTATION);
                boolean hasNerTag = (nerTags != null && !nerTags.isEmpty());
                Assert.assertTrue("All Chunks need to have a NER Tag (missing for "
                        + span+ ")",  hasNerTag);
                for(Value<NerTag> nerTag : nerTags){
                    Assert.assertNotEquals("NER Tags MUST NOT use '0' as Tag",
                        "0",nerTag.value().getTag());
                }
                break;
            default:
                Assert.assertNull(span.getType()+" type Spans MUST NOT have POS annotations!",
                    span.getAnnotation(POS_ANNOTATION));
                Assert.assertNull(span.getType()+" type Spans MUST NOT have Phrase annotations!",
                    span.getAnnotation(PHRASE_ANNOTATION));
                Assert.assertNull(span.getType()+" type Spans MUST NOT have NER annotations!",
                    span.getAnnotation(NER_ANNOTATION));
                break;
        }
    }
}
 
開發者ID:westei,項目名稱:stanbol-stanfordnlp,代碼行數:58,代碼來源:TestNonEnglishConfig.java

示例12: addDependencyRelations

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
/**
 * Add dependency tree annotations to the current token.
 * 
 * @param tokens - the list of {@link CoreLabel}s in the current sentence.
 * @param currentToken - the current {@link Token} to which the dependency relations will
 * be added.
 * @param at
 * @param relationTagSet - tag set containing {@link GrammaticalRelationTag}s.
 * @param dependencies - the {@link SemanticGraph} containing the dependency tree relations.
 */
private void addDependencyRelations(List<CoreLabel> tokens, Token currentToken, AnalysedText at,
        TagSet<GrammaticalRelationTag> relationTagSet, SemanticGraph dependencies, int currentTokenIdx) {
    IndexedWord vertex = dependencies.getNodeByIndexSafe(currentTokenIdx);
    if (vertex == null) {
        // Usually the current token is a punctuation mark in this case.
        return;
    }
    
    List<SemanticGraphEdge> edges = new ArrayList<SemanticGraphEdge>();
    edges.addAll(dependencies.incomingEdgeList(vertex));
    edges.addAll(dependencies.outgoingEdgeList(vertex));
    
    for (SemanticGraphEdge edge : edges) {
        int govIndex = edge.getGovernor().index();
        int depIndex = edge.getDependent().index();
        GrammaticalRelation gramRel = edge.getRelation();
        GrammaticalRelationTag gramRelTag = relationTagSet.getTag(gramRel.getShortName());
        if(gramRelTag != null){
         boolean isDependent = false;
         Span partner = null;
         
         if (govIndex == currentTokenIdx) {
             CoreLabel dependentLabel = tokens.get(depIndex - 1);
             partner = at.addToken(dependentLabel.beginPosition(), dependentLabel.endPosition());
         } else if (depIndex == currentTokenIdx) {
             isDependent = true;
             CoreLabel governorLabel = tokens.get(govIndex - 1);
             partner = at.addToken(governorLabel.beginPosition(), governorLabel.endPosition());
         }
         
         currentToken.addAnnotation(DEPENDENCY_ANNOTATION, 
             Value.value(new DependencyRelation(gramRelTag, isDependent, partner)));
        } else {
        	log.warn("Missing GrammaticalRelationTag for {}!",gramRel.getShortName());
        }
 }
    
    // Finally add the root relation if the word has any.
    Collection<IndexedWord> roots = dependencies.getRoots();
    if (roots.contains(vertex)) {
        GrammaticalRelationTag rootRelTag = relationTagSet.getTag("root");
        currentToken.addAnnotation(DEPENDENCY_ANNOTATION, 
            Value.value(new DependencyRelation(rootRelTag, false, null)));
    }
}
 
開發者ID:westei,項目名稱:stanbol-stanfordnlp,代碼行數:56,代碼來源:StanfordNlpAnalyzer.java

示例13: addCommonNerTags

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
private static void addCommonNerTags(TagSet<PosTag> tagset) {
    tagset.addTag(new PosTag("NP", Pos.ProperNoun));
}
 
開發者ID:insideout10,項目名稱:stanbol-freeling,代碼行數:4,代碼來源:TagSetRegistry.java

示例14: addCommonDateTags

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
private static void addCommonDateTags(TagSet<PosTag> tagset){
    tagset.addTag(new PosTag("W", Pos.Date));
}
 
開發者ID:insideout10,項目名稱:stanbol-freeling,代碼行數:4,代碼來源:TagSetRegistry.java

示例15: getPosTagSet

import org.apache.stanbol.enhancer.nlp.model.tag.TagSet; //導入依賴的package包/類
/**
 * Getter for the {@link PosTag} {@link TagSet} by language. If no {@link TagSet}
 * is available for an Language this will return <code>null</code>
 * @param language the language
 * @return the AnnotationModel or <code>null</code> if non is defined
 */
public TagSet<PosTag> getPosTagSet(String language){
    return posModels.get(language);
}
 
開發者ID:westei,項目名稱:stanbol-talismane,代碼行數:10,代碼來源:TagSetRegistry.java


注:本文中的org.apache.stanbol.enhancer.nlp.model.tag.TagSet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。