本文整理汇总了Java中de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS.setPosValue方法的典型用法代码示例。如果您正苦于以下问题:Java POS.setPosValue方法的具体用法?Java POS.setPosValue怎么用?Java POS.setPosValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS
的用法示例。
在下文中一共展示了POS.setPosValue方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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();
}
示例3: 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();
}
示例4: 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;
}
示例5: createToken
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
/**
* Create {@link Token} in the {@link CAS}. If the lemma and pos columns are not empty it will
* create {@link Lemma} and {@link POS} annotations
*/
private void createToken(JCas aJCas, StringBuilder text, Map<Integer, String> tokens,
Map<Integer, String> pos, Map<Integer, String> lemma, Map<String, Token> tokensStored)
{
int tokenBeginPosition = 0;
int tokenEndPosition = 0;
for (int i = 1; i <= tokens.size(); i++) {
tokenBeginPosition = text.indexOf(tokens.get(i), tokenBeginPosition);
Token outToken = new Token(aJCas, tokenBeginPosition, text.indexOf(tokens.get(i),
tokenBeginPosition) + tokens.get(i).length());
tokenEndPosition = text.indexOf(tokens.get(i), tokenBeginPosition)
+ tokens.get(i).length();
tokenBeginPosition = tokenEndPosition;
outToken.addToIndexes();
// Add pos to CAS if exist
if (!pos.get(i).equals("_")) {
POS outPos = new POS(aJCas, outToken.getBegin(), outToken.getEnd());
outPos.setPosValue(pos.get(i));
outPos.addToIndexes();
outToken.setPos(outPos);
}
// Add lemma if exist
if (!lemma.get(i).equals("_")) {
Lemma outLemma = new Lemma(aJCas, outToken.getBegin(), outToken.getEnd());
outLemma.setValue(lemma.get(i));
outLemma.addToIndexes();
outToken.setLemma(outLemma);
}
tokensStored.put("t_" + i, outToken);
}
}
示例6: testTokenAttachedAnnotationsWithValues
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
@Test
public void testTokenAttachedAnnotationsWithValues() throws Exception
{
JCas jcas = makeJCasOneSentence();
List<Token> tokens = new ArrayList<>(select(jcas, Token.class));
Token t1 = tokens.get(0);
Lemma l1 = new Lemma(jcas, t1.getBegin(), t1.getEnd());
l1.setValue("lemma1");
l1.addToIndexes();
t1.setLemma(l1);
MorphologicalFeatures m1 = new MorphologicalFeatures(jcas, t1.getBegin(), t1.getEnd());
m1.setValue("morph");
m1.setTense("tense1");
m1.addToIndexes();
t1.setMorph(m1);
POS p1 = new POS(jcas, t1.getBegin(), t1.getEnd());
p1.setPosValue("pos1");
p1.addToIndexes();
t1.setPos(p1);
Stem s1 = new Stem(jcas, t1.getBegin(), t1.getEnd());
s1.setValue("stem1");
s1.addToIndexes();
t1.setStem(s1);
writeAndAssertEquals(jcas, WebannoTsv3Writer.PARAM_SPAN_LAYERS,
asList(MorphologicalFeatures.class, POS.class, Lemma.class, Stem.class));
}
示例7: testDependencyWithValues
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
@Test
public void testDependencyWithValues() throws Exception
{
JCas jcas = makeJCasOneSentence();
List<Token> tokens = new ArrayList<>(select(jcas, Token.class));
Token t1 = tokens.get(0);
Token t2 = tokens.get(1);
POS p1 = new POS(jcas, t1.getBegin(), t1.getEnd());
p1.setPosValue("POS1");
p1.addToIndexes();
t1.setPos(p1);
POS p2 = new POS(jcas, t2.getBegin(), t2.getEnd());
p2.setPosValue("POS2");
p2.addToIndexes();
t2.setPos(p2);
Dependency dep1 = new Dependency(jcas);
dep1.setGovernor(t1);
dep1.setDependent(t2);
dep1.setBegin(dep1.getDependent().getBegin());
dep1.setEnd(dep1.getDependent().getEnd());
dep1.addToIndexes();
writeAndAssertEquals(jcas,
WebannoTsv3Writer.PARAM_SPAN_LAYERS, asList(POS.class),
WebannoTsv3Writer.PARAM_RELATION_LAYERS, asList(Dependency.class));
}
示例8: testSimpleSymbolicRules
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
@Test
public void testSimpleSymbolicRules()
throws Exception
{
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream(
"src/test/resources/rules/symbolic1.rules"));
Parse p = parser.Parse();
ParsedConstraints constraints = p.accept(new ParserVisitor());
JCas jcas = JCasFactory.createJCas();
CollectionReader reader = createReader(Conll2006Reader.class,
Conll2006Reader.PARAM_SOURCE_LOCATION, "src/test/resources/text/1.conll");
reader.getNext(jcas.getCas());
POS pos = new POS(jcas, 8, 9);
pos.setPosValue("pronoun");
pos.addToIndexes();
Evaluator constraintsEvaluator = new ValuesGenerator();
Lemma lemma = select(jcas, Lemma.class).iterator().next();
List<PossibleValue> possibleValues = constraintsEvaluator.generatePossibleValues(lemma,
"value", constraints);
List<PossibleValue> expectedOutput = new ArrayList<>();
expectedOutput.add(new PossibleValue("good", true));
assertEquals(expectedOutput, possibleValues);
}
示例9: testSimpleSymbolicRules2
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
@Test
public void testSimpleSymbolicRules2()
throws Exception
{
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream(
"src/test/resources/rules/symbolic2.rules"));
Parse p = parser.Parse();
ParsedConstraints constraints = p.accept(new ParserVisitor());
JCas jcas = JCasFactory.createJCas();
CollectionReader reader = createReader(Conll2006Reader.class,
Conll2006Reader.PARAM_SOURCE_LOCATION, "src/test/resources/text/1.conll");
reader.getNext(jcas.getCas());
POS pos = new POS(jcas, 8, 9);
pos.setPosValue("pronoun");
pos.addToIndexes();
Evaluator constraintsEvaluator = new ValuesGenerator();
Lemma lemma = select(jcas, Lemma.class).iterator().next();
List<PossibleValue> possibleValues = constraintsEvaluator.generatePossibleValues(lemma,
"value", constraints);
List<PossibleValue> expectedOutput = new ArrayList<>();
expectedOutput.add(new PossibleValue("good", true));
assertEquals(expectedOutput, possibleValues);
}
示例10: singleNoDifferencesWithAdditionalCas1Test
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
@Test
public void singleNoDifferencesWithAdditionalCas1Test()
throws Exception
{
JCas user1 = JCasFactory.createJCas();
user1.setDocumentText("test");
JCas user2 = JCasFactory.createJCas();
user2.setDocumentText("test");
JCas user3 = JCasFactory.createJCas();
user3.setDocumentText("test");
POS pos3 = new POS(user3, 0, 4);
pos3.setPosValue("test");
pos3.addToIndexes();
Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(user1));
casByUser.put("user2", asList(user2));
casByUser.put("user3", asList(user3));
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);
casByUser.remove("user3");
AgreementResult agreement = AgreementUtils.getAgreement(
ConcreteAgreementMeasure.KRIPPENDORFF_ALPHA_NOMINAL_AGREEMENT, false, result,
entryTypes.get(0), "PosValue", casByUser);
assertEquals(1, agreement.getTotalSetCount());
assertEquals(1, agreement.getIrrelevantSets().size());
assertEquals(0, agreement.getRelevantSetCount());
}
示例11: process
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
@Override
public void process(JCas jcas) throws AnalysisEngineProcessException {
try {
CAS cas = jcas.getCas();
mappingProvider.configure(cas);
for (Sentence sentenceAnno : JCasUtil.select(jcas, Sentence.class)) {
List<Token> tokens = JCasUtil.selectCovered(jcas, Token.class, sentenceAnno);
List<String> tokenStrings = JCasUtil.toText(tokens);
List<PosTaggedToken> taggedTokens;
synchronized (innerTool) {
innerTool.setTokenizedSentence(tokenStrings);
innerTool.process();
taggedTokens = innerTool.getPosTaggedTokens();
}
if (taggedTokens.size() != tokens.size()) {
throw new PosTaggerException("Got pos tagging for " + taggedTokens.size() +
" tokens, should have gotten according to the total number of tokens in the sentence: " + tokens.size());
}
Iterator<Token> tokenIter = tokens.iterator();
for (PosTaggedToken taggedToken : taggedTokens) {
Token tokenAnno = tokenIter.next();
String tagString = taggedToken.getPartOfSpeech().getStringRepresentation();
// Get an annotation with the appropriate UIMA type via the mappingProvider
Type posTag = mappingProvider.getTagType(tagString);
POS posAnnotation = (POS) cas.createAnnotation(posTag, tokenAnno.getBegin(), tokenAnno.getEnd());
posAnnotation.setPosValue(tagString);
posAnnotation.addToIndexes();
tokenAnno.setPos(posAnnotation);
}
}
} catch (PosTaggerException e) {
throw new AnalysisEngineProcessException(AnalysisEngineProcessException.ANNOTATOR_EXCEPTION, null, e);
}
}
示例12: getNext
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
public void getNext(JCas aJCas)
throws IOException, CollectionException
{
DocumentMetaData md = new DocumentMetaData(aJCas);
md.setDocumentTitle("");
md.setDocumentId("" + (instanceId++));
md.setLanguage(language);
md.addToIndexes();
try {
posMappingProvider.configure(aJCas.getCas());
}
catch (AnalysisEngineProcessException e1) {
throw new CollectionException(e1);
}
StringBuilder documentText = new StringBuilder();
int seqStart = 0;
for (int k = 0; k < sequences.size(); k++) {
List<String> sequence = sequences.get(k);
for (int i = 0; i < sequence.size(); i++) {
String pairs = sequence.get(i).replaceAll(" +", " ");
int idxLastSpace = pairs.lastIndexOf(" ");
String token = pairs.substring(0, idxLastSpace);
String tag = pairs.substring(idxLastSpace+1);
int tokenLen = token.length();
if(lowerCase){
token = token.toLowerCase();
}
documentText.append(token);
int tokStart = documentText.length() - tokenLen;
int tokEnd = documentText.length();
Token t = new Token(aJCas, tokStart, tokEnd);
t.addToIndexes();
if (i + 1 < sequence.size()) {
documentText.append(" ");
}
Type posTag = posMappingProvider.getTagType(tag);
POS pos = (POS) aJCas.getCas().createAnnotation(posTag, t.getBegin(),
t.getEnd());
pos.setPosValue(tag);
pos.addToIndexes();
t.setPos(pos);
}
Sentence sentence = new Sentence(aJCas, seqStart, documentText.length());
sentence.addToIndexes();
if (k + 1 < sequences.size()) {
documentText.append(" ");
}
seqStart = documentText.length();
}
aJCas.setDocumentText(documentText.toString());
}
示例13: testSimplePath
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
@Test
public void testSimplePath()
throws Exception
{
ConstraintsGrammar parser = new ConstraintsGrammar(new FileInputStream(
"src/test/resources/rules/10.rules"));
Parse p = parser.Parse();
ParsedConstraints constraints = p.accept(new ParserVisitor());
JCas jcas = JCasFactory.createJCas();
jcas.setDocumentText("The sun.");
// Add token annotations
Token t_the = new Token(jcas, 0, 3);
t_the.addToIndexes();
Token t_sun = new Token(jcas, 0, 3);
t_sun.addToIndexes();
// Add POS annotations and link them to the tokens
POS p_the = new POS(jcas, t_the.getBegin(), t_the.getEnd());
p_the.setPosValue("DET");
p_the.addToIndexes();
t_the.setPos(p_the);
POS p_sun = new POS(jcas, t_sun.getBegin(), t_sun.getEnd());
p_sun.setPosValue("NN");
p_sun.addToIndexes();
t_sun.setPos(p_sun);
// Add dependency annotations
Dependency dep_the_sun = new Dependency(jcas);
dep_the_sun.setGovernor(t_sun);
dep_the_sun.setDependent(t_the);
dep_the_sun.setDependencyType("det");
dep_the_sun.setBegin(dep_the_sun.getGovernor().getBegin());
dep_the_sun.setEnd(dep_the_sun.getGovernor().getEnd());
dep_the_sun.addToIndexes();
Evaluator constraintsEvaluator = new ValuesGenerator();
List<PossibleValue> possibleValues = constraintsEvaluator.generatePossibleValues(
dep_the_sun, "DependencyType", constraints);
List<PossibleValue> expectedOutput = new LinkedList<>();
expectedOutput.add(new PossibleValue("det", false));
assertEquals(expectedOutput, possibleValues);
}
示例14: twoWithoutLabelTest
import de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS; //导入方法依赖的package包/类
@Test
public void twoWithoutLabelTest()
throws Exception
{
JCas user1 = JCasFactory.createJCas();
user1.setDocumentText("test");
new POS(user1, 0, 1).addToIndexes();
new POS(user1, 1, 2).addToIndexes();
POS p1 = new POS(user1, 3, 4);
p1.setPosValue("A");
p1.addToIndexes();
JCas user2 = JCasFactory.createJCas();
user2.setDocumentText("test");
new POS(user2, 0, 1).addToIndexes();
new POS(user2, 2, 3).addToIndexes();
POS p2 = new POS(user2, 3, 4);
p2.setPosValue("B");
p2.addToIndexes();
Map<String, List<JCas>> casByUser = new LinkedHashMap<>();
casByUser.put("user1", asList(user1));
casByUser.put("user2", asList(user2));
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);
AgreementResult agreement = AgreementUtils.getAgreement(
ConcreteAgreementMeasure.KRIPPENDORFF_ALPHA_NOMINAL_AGREEMENT, false, result,
entryTypes.get(0), "PosValue", casByUser);
assertEquals(4, agreement.getTotalSetCount());
assertEquals(0, agreement.getIrrelevantSets().size());
// the following two counts are zero because the incomplete sets are not excluded!
assertEquals(2, agreement.getIncompleteSetsByPosition().size());
assertEquals(0, agreement.getIncompleteSetsByLabel().size());
assertEquals(3, agreement.getSetsWithDifferences().size());
assertEquals(4, agreement.getRelevantSetCount());
assertEquals(0.4, agreement.getAgreement(), 0.01);
ICodingAnnotationItem item1 = agreement.getStudy().getItem(0);
ICodingAnnotationItem item2 = agreement.getStudy().getItem(1);
ICodingAnnotationItem item3 = agreement.getStudy().getItem(2);
assertEquals("", item1.getUnit(0).getCategory());
assertEquals("", item1.getUnit(1).getCategory());
assertEquals("", item2.getUnit(0).getCategory());
assertEquals(null, item2.getUnit(1).getCategory());
assertEquals(null, item3.getUnit(0).getCategory());
assertEquals("", item3.getUnit(1).getCategory());
}