本文整理汇总了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类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例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());
}
示例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;
}
示例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);
}
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}
示例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());
}
示例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());
}
示例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;
}
示例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();
}
示例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();
}