当前位置: 首页>>代码示例>>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;未经允许,请勿转载。