• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java POS类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS的典型用法代码示例。如果您正苦于以下问题:Java POS类的具体用法?Java POS怎么用?Java POS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



POS类属于de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos包,在下文中一共展示了POS类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setUp

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Before
public void setUp() throws UIMAException {
	jcas = JCasFactory.createJCas();
	DocumentMetaData.create(jcas).setDocumentId("test");
	jcas.setDocumentText(
			"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut");
	AnnotationFactory.createAnnotation(jcas, 0, 5, POS.class);
	AnnotationFactory.createAnnotation(jcas, 6, 11, POS.class);
	AnnotationFactory.createAnnotation(jcas, 12, 17, POS.class);

	view = jcas.createView(viewName);
	view.setDocumentText("dolor sit amet\n\nsadipscing");
	AnnotationFactory.createAnnotation(view, 0, 14, Origin.class).setOffset(12);
	AnnotationFactory.createAnnotation(view, 17, 26, Origin.class).setOffset(39);
	AnnotationFactory.createAnnotation(view, 0, 5, POS.class).setPosValue("1");
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:17,代码来源:TestMapBackFeature.java


示例2: testMapBackFeature

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Test
public void testMapBackFeature() {
	try {
		SimplePipeline.runPipeline(view,
				AnalysisEngineFactory.createEngineDescription(XmiWriter.class, XmiWriter.PARAM_TARGET_LOCATION,
						"target/test", XmiWriter.PARAM_USE_DOCUMENT_ID, true),
				AnalysisEngineFactory.createEngineDescription(MapBackFeature.class,
						MapBackFeature.PARAM_ANNOTATION_TYPE, POS.class, MapBackFeature.PARAM_FEATURE_NAME,
						"PosValue", MapBackFeature.PARAM_VIEW_NAME, viewName));
	} catch (AnalysisEngineProcessException | ResourceInitializationException e) {
		e.printStackTrace();
	}
	POS pos = JCasUtil.selectByIndex(jcas, POS.class, 2);
	assertEquals("1", pos.getPosValue());

}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:17,代码来源:TestMapBackFeature.java


示例3: getDocumentPosNgrams

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
public static FrequencyDistribution<String> getDocumentPosNgrams(JCas jcas, int minN, int maxN, boolean useCanonical)
{
    FrequencyDistribution<String> posNgrams = new FrequencyDistribution<String>();
    for (Sentence s : select(jcas, Sentence.class)) {        
        List<String> postagstrings = new ArrayList<String>();
        for (POS p : JCasUtil.selectCovered(jcas, POS.class, s)) {
            if (useCanonical) {
                postagstrings.add(p.getClass().getSimpleName());
            }
            else {
                postagstrings.add(p.getPosValue());
            }
        }
        String[] posarray = postagstrings.toArray(new String[postagstrings.size()]);

        for (List<String> ngram : new NGramStringListIterable(posarray, minN, maxN)) {
            posNgrams.inc(StringUtils.join(ngram, NGRAM_GLUE));

        }
    }
    return posNgrams;
}
 
开发者ID:UKPLab,项目名称:jlcl2015-pythagoras,代码行数:23,代码来源:NGramUtils.java


示例4: convertPos

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
private void convertPos(JCas aJCas, TextCorpus aCorpusData, Map<String, Token> aTokens)
{
    if (aCorpusData.getPosTagsLayer() == null) {
        return;
    }
    for (int i = 0; i < aCorpusData.getPosTagsLayer().size(); i++) {
        eu.clarin.weblicht.wlfxb.tc.api.Token[] posTokens = aCorpusData.getPosTagsLayer()
                .getTokens(aCorpusData.getPosTagsLayer().getTag(i));
        String value = aCorpusData.getPosTagsLayer().getTag(i).getString();

        POS outPos = new POS(aJCas);

        outPos.setBegin(aTokens.get(posTokens[0].getID()).getBegin());
        outPos.setEnd(aTokens.get(posTokens[0].getID()).getEnd());
        outPos.setPosValue(value);
        outPos.addToIndexes();

        // Set the POS to the token
        aTokens.get(posTokens[0].getID()).setPos(outPos);
    }
}
 
开发者ID:webanno,项目名称:webanno,代码行数:22,代码来源:TcfReader.java


示例5: simpleCopyToEmptyTest

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Test
public void simpleCopyToEmptyTest()
    throws Exception
{
    AnnotatorState state = new AnnotatorStateImpl(Mode.CURATION);
    state.setUser(new User());
    
    JCas jcas = JCasFactory.createJCas();
    Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
    AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);

    JCas mergeCAs = JCasFactory.createJCas();
    createTokenAnno(mergeCAs, 0, 0);

    MergeCas.addSpanAnnotation(state, annotationSchemaService,
            posLayer, mergeCAs, clickedFs, false);

    assertEquals(1, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:CopyAnnotationTest.java


示例6: simpleCopyToSameExistingAnnoTest

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Test
public void simpleCopyToSameExistingAnnoTest()
    throws Exception
{
    JCas jcas = JCasFactory.createJCas();
    Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
    AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);

    JCas mergeCAs = JCasFactory.createJCas();
    AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
    Feature posValue = type.getFeatureByBaseName("PosValue");
    existingFs.setStringValue(posValue, "NN");
    mergeCAs.addFsToIndexes(existingFs);

    exception.expect(AnnotationException.class);
    MergeCas.addSpanAnnotation(new AnnotatorStateImpl(Mode.CURATION), annotationSchemaService,
            posLayer, mergeCAs, clickedFs, false);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:19,代码来源:CopyAnnotationTest.java


示例7: simpleCopyToDiffExistingAnnoWithNoStackingTest

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Test
public void simpleCopyToDiffExistingAnnoWithNoStackingTest()
    throws Exception
{
    JCas jcas = JCasFactory.createJCas();
    Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
    AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);

    JCas mergeCAs = JCasFactory.createJCas();
    AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
    Feature posValue = type.getFeatureByBaseName("PosValue");
    existingFs.setStringValue(posValue, "NE");
    mergeCAs.addFsToIndexes(existingFs);

    MergeCas.addSpanAnnotation(new AnnotatorStateImpl(Mode.CURATION), annotationSchemaService,
            posLayer, mergeCAs, clickedFs, false);

    assertEquals(1, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:CopyAnnotationTest.java


示例8: simpleCopyToDiffExistingAnnoWithStackingTest

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Test
public void simpleCopyToDiffExistingAnnoWithStackingTest()
    throws Exception
{
    AnnotatorState state = new AnnotatorStateImpl(Mode.CURATION);
    state.setUser(new User());
    
    posLayer.setAllowStacking(true);

    JCas jcas = JCasFactory.createJCas();
    Type type = jcas.getTypeSystem().getType(POS.class.getTypeName());
    AnnotationFS clickedFs = createPOSAnno(jcas, type, "NN", 0, 0);

    JCas mergeCAs = JCasFactory.createJCas();
    createTokenAnno(mergeCAs, 0, 0);
    AnnotationFS existingFs = mergeCAs.getCas().createAnnotation(type, 0, 0);
    Feature posValue = type.getFeatureByBaseName("PosValue");
    existingFs.setStringValue(posValue, "NE");
    mergeCAs.addFsToIndexes(existingFs);

    MergeCas.addSpanAnnotation(state, annotationSchemaService, posLayer, mergeCAs, clickedFs,
            true);

    assertEquals(2, CasUtil.selectCovered(mergeCAs.getCas(), type, 0, 0).size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:26,代码来源:CopyAnnotationTest.java


示例9: createPOSLayer

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
private void createPOSLayer(Project aProject, TagSet aPosTagset)
    throws IOException
{
    AnnotationLayer tokenLayer = annotationSchemaService.getLayer(Token.class.getName(),
            aProject);
    
    AnnotationLayer posLayer = new AnnotationLayer(POS.class.getName(), "POS", SPAN_TYPE,
            aProject, true);
    AnnotationFeature tokenPosFeature = createFeature("pos", "pos", aProject, tokenLayer,
            POS.class.getName());
    tokenPosFeature.setVisible(true);
    posLayer.setAttachType(tokenLayer);
    posLayer.setAttachFeature(tokenPosFeature);
    annotationSchemaService.createLayer(posLayer);

    AnnotationFeature posFeature = createFeature("PosValue", "PosValue", "Part-of-speech tag",
            CAS.TYPE_NAME_STRING, aPosTagset, aProject);
    posFeature.setLayer(posLayer);
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:ProjectInitializer.java


示例10: noDifferencesPosTest

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Test
public void noDifferencesPosTest()
    throws Exception
{
    Map<String, List<JCas>> casByUser = DiffUtils.load(
            "casdiff/noDifferences/data.conll",
            "casdiff/noDifferences/data.conll");

    List<String> entryTypes = asList(POS.class.getName());
    
    List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.POS);

    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters,
            LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);
    
    result.print(System.out);
    
    assertEquals(26, result.size());
    assertEquals(0, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());

    AgreementResult agreement = AgreementUtils.getCohenKappaAgreement(result, entryTypes.get(0),
            "PosValue", casByUser);
    assertEquals(1.0d, agreement.getAgreement(), 0.000001d);
    assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:27,代码来源:CasDiff2Test.java


示例11: singleDifferencesTest

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Test
public void singleDifferencesTest()
    throws Exception
{
    Map<String, List<JCas>> casByUser = DiffUtils.load(
            "casdiff/singleSpanDifference/user1.conll",
            "casdiff/singleSpanDifference/user2.conll");

    List<String> entryTypes = asList(POS.class.getName());

    List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.POS);

    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters,
            LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);

    result.print(System.out);
    
    assertEquals(1, result.size());
    assertEquals(1, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());

    AgreementResult agreement = AgreementUtils.getCohenKappaAgreement(result, entryTypes.get(0),
            "PosValue", casByUser);
    assertEquals(0.0d, agreement.getAgreement(), 0.000001d);
    assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:27,代码来源:CasDiff2Test.java


示例12: someDifferencesTest

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Test
public void someDifferencesTest()
    throws Exception
{
    Map<String, List<JCas>> casByUser = DiffUtils.load(
            "casdiff/someDifferences/user1.conll",
            "casdiff/someDifferences/user2.conll");

    List<String> entryTypes = asList(POS.class.getName());

    List<SpanDiffAdapter> diffAdapters = asList(SpanDiffAdapter.POS);

    DiffResult result = CasDiff2.doDiff(entryTypes, diffAdapters,
            LinkCompareBehavior.LINK_TARGET_AS_LABEL, casByUser);

    result.print(System.out);
    
    assertEquals(26, result.size());
    assertEquals(4, result.getDifferingConfigurationSets().size());
    assertEquals(0, result.getIncompleteConfigurationSets().size());
    
    AgreementResult agreement = AgreementUtils.getCohenKappaAgreement(result, entryTypes.get(0),
            "PosValue", casByUser);
    assertEquals(0.836477987d, agreement.getAgreement(), 0.000001d);
    assertEquals(0, agreement.getIncompleteSetsByPosition().size());
}
 
开发者ID:webanno,项目名称:webanno,代码行数:27,代码来源:CasDiff2Test.java


示例13: hasPos

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@SuppressWarnings("unused")
private boolean hasPos(FeatureStructure fs, String posValue)
{
    if (fs instanceof POS) {
        POS pos = (POS) fs;
        if (pos.getPosValue().equals(posValue)) {
            return true;
        }
    }
    else if (fs instanceof Token) {
        Token token = (Token) fs;
        if (token.getPos().getPosValue().equals(posValue)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:webanno,项目名称:webanno,代码行数:18,代码来源:TestCasDiff.java


示例14: getCas1

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@SuppressWarnings("unused")
private void getCas1(JCasBuilder aBuilder, JCas aJCas)
{
    Token token1 = aBuilder.add("Hallo", Token.class);
    POS pos1 = new POS(aJCas, token1.getBegin(), token1.getEnd());
    pos1.setPosValue("I");
    pos1.addToIndexes();
    token1.setPos(pos1);
    Token token2 = aBuilder.add("Welt", Token.class);
    POS pos2 = new POS(aJCas, token2.getBegin(), token2.getEnd());
    pos2.setPosValue("N");
    pos2.addToIndexes();
    token2.setPos(pos2);
    Token token3 = aBuilder.add("!", Token.class);
    POS pos3 = new POS(aJCas, token3.getBegin(), token3.getEnd());
    pos3.setPosValue("SENT");
    token3.setPos(pos3);
    pos3.addToIndexes();
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:TestCasDiff.java


示例15: getCas2

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@SuppressWarnings("unused")
private void getCas2(JCasBuilder aBuilder, JCas aJCas)
{
    Token token1 = aBuilder.add("Hallo", Token.class);
    POS pos1 = new POS(aJCas, token1.getBegin(), token1.getEnd());
    pos1.setPosValue("O");
    pos1.addToIndexes();
    token1.setPos(pos1);
    Token token2 = aBuilder.add("Welt", Token.class);
    POS pos2 = new POS(aJCas, token2.getBegin(), token2.getEnd());
    pos2.setPosValue("N");
    pos2.addToIndexes();
    token2.setPos(pos2);
    Token token3 = aBuilder.add("!", Token.class);
    POS pos3 = new POS(aJCas, token3.getBegin(), token3.getEnd());
    pos3.setPosValue("SENT");
    token3.setPos(pos3);
    pos3.addToIndexes();
}
 
开发者ID:webanno,项目名称:webanno,代码行数:20,代码来源:TestCasDiff.java


示例16: initialize

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
@Override
public void initialize(UimaContext context)
    throws ResourceInitializationException
{
    super.initialize(context);

    posMappingProvider = new MappingProvider();
    posMappingProvider.setDefault(MappingProvider.LOCATION,
            "classpath:/de/tudarmstadt/ukp/dkpro/"
                    + "core/api/lexmorph/tagset/${language}-${tagger.tagset}-pos.map");
    posMappingProvider.setDefault(MappingProvider.BASE_TYPE, POS.class.getName());
    posMappingProvider.setDefault("tagger.tagset", "default");
    posMappingProvider.setOverride(MappingProvider.LOCATION, mappingPosLocation);
    posMappingProvider.setOverride(MappingProvider.LANGUAGE, language);
    posMappingProvider.setOverride("tagger.tagset", posTagset);

    try {
        for (Resource r : getResources()) {
            String name = r.getResource().getFile().getName();
            InputStreamReader is = null;
            if (name.endsWith(".gz")) {
                is = new InputStreamReader(new GZIPInputStream(r.getInputStream()), encoding);
            }
            else {
                is = new InputStreamReader(r.getInputStream(), encoding);
            }
            br = new BufferedReader(is);
            bfs.add(br);
        }
    }
    catch (Exception e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:35,代码来源:LineTokenTagReader.java


示例17: posTag

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
public List<String> posTag(List<String> sentence)
    throws UIMAException
{

    JCas jCas = JCasFactory.createJCas();
    StringBuilder documentText = new StringBuilder();

    int start = 0;
    for (int i = 0; i < sentence.size(); i++) {
        String token = sentence.get(i);
        documentText.append(token);

        Token t = new Token(jCas, start, documentText.length());
        t.addToIndexes();

        if (i + 1 < sentence.size()) {
            documentText.append(" ");
        }
        start = documentText.length();
    }
    jCas.setDocumentText(documentText.toString());
    
    Sentence s = new Sentence(jCas, 0, jCas.getDocumentText().length());
    s.addToIndexes();

    callFlexTag(jCas);

    List<String> posTags = new ArrayList<String>();
    JCasUtil.select(jCas, POS.class).forEach(x -> posTags.add(x.getPosValue()));

    return posTags;
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:33,代码来源:UseModelFlexTag.java


示例18: getTextClassificationOutcome

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
public String getTextClassificationOutcome(JCas jcas, TextClassificationTarget target)
{
    List<POS> posList = JCasUtil.selectCovered(jcas, POS.class, target);

    String outcome = "";
    if (useCoarseGrained) {
        outcome = posList.get(0).getClass().getSimpleName();
    }
    else {
        outcome = posList.get(0).getPosValue();
    }
    return outcome;
}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:14,代码来源:TcPosTaggingWrapper.java


示例19: annotateTaggingResultsLinkToTokens

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
private void annotateTaggingResultsLinkToTokens(JCas aJCas)
{
    List<Token> tokens = getTokens(aJCas);
    List<TextClassificationOutcome> outcomes = getPredictions(aJCas);

    for (int i = 0; i < tokens.size(); i++) {
        Token token = tokens.get(i);
        String outcome = outcomes.get(i).getOutcome();

        POS p = createPartOfSpeechAnnotationFromOutcome(aJCas, token.getBegin(),
                token.getEnd(), outcome);
        token.setPos(p);
    }

}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:16,代码来源:FlexTagUima.java


示例20: createPartOfSpeechAnnotationFromOutcome

import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入依赖的package包/类
private POS createPartOfSpeechAnnotationFromOutcome(JCas aJCas, int begin, int end,
        String aOutcome)
{
    Type posTag = mappingProvider.getTagType(aOutcome);
    POS posAnno = (POS) aJCas.getCas().createAnnotation(posTag, begin, end);
    posAnno.setPosValue(aOutcome);
    posAnno.addToIndexes();

    return posAnno;

}
 
开发者ID:Horsmann,项目名称:FlexTag,代码行数:12,代码来源:FlexTagUima.java



注:本文中的de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UploadCallback类代码示例发布时间:2022-05-22
下一篇:
Java CoreService类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap