本文整理了Java中de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS.setPosValue()
方法的一些代码示例,展示了POS.setPosValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。POS.setPosValue()
方法的具体详情如下:
包路径:de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS
类名称:POS
方法名:setPosValue
[英]setter for PosValue - sets Fine-grained POS tag. This is the tag as produced by a POS tagger or obtained from a reader.
[中]PosValue设置器-设置细粒度POS标记。这是POS标签工制作的标签或从读卡器获取的标签。
代码示例来源:origin: de.unidue.ltl.flextag/flextag-core
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;
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.treetagger-asl
@Override
public void token(Token aToken, String aPos, String aLemma)
{
synchronized (cas) {
// Add the Part of Speech
if (writePos && aPos != null) {
Type posTag = posMappingProvider.getTagType(aPos);
POS posAnno = (POS) cas.createAnnotation(posTag, aToken.getBegin(),
aToken.getEnd());
posAnno.setPosValue(aPos.intern());
POSUtils.assignCoarseValue(posAnno);
aToken.setPos(posAnno);
pos[count.get()] = posAnno;
}
// Add the lemma
if (writeLemma && aLemma != null) {
Lemma lemmaAnno = new Lemma(aJCas, aToken.getBegin(), aToken.getEnd());
lemmaAnno.setValue(aLemma.intern());
aToken.setLemma(lemmaAnno);
lemma[count.get()] = lemmaAnno;
}
count.getAndIncrement();
}
}
});
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.stanfordnlp-gpl
/**
* Creates a new Constituent annotation. Links to parent- and child-annotations are not yet
* created here.
*
* @param aBegin
* start-index of the constituent span
* @param aEnd
* end-index of the constituent span
* @param aPosType
* the constituent type
* @return the annotation
*/
public POS createPOSAnnotation(int aBegin, int aEnd, String aPosType)
{
// get mapping for DKPro-Typesystem
Type type = posMappingProvider.getTagType(aPosType);
// create instance of the desired type
POS anno = (POS) jCas.getCas().createAnnotation(type, aBegin, aEnd);
// save original (unmapped) postype in feature
anno.setPosValue(aPosType);
POSUtils.assignCoarseValue(anno);
return anno;
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.posfilter-asl
newPos.setPosValue(newTag);
POSUtils.assignCoarseValue(newPos);
String newTag = posMap.getProperty(pos.getPosValue());
if (newTag != null) {
pos.setPosValue(newTag);
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.clearnlp-asl
@Override
public void process(JCas aJCas)
throws AnalysisEngineProcessException
{
CAS cas = aJCas.getCas();
dictModelProvider.configure(cas);
posTaggingModelProvider.configure(cas);
posMappingProvider.configure(cas);
for (Sentence sentence : select(aJCas, Sentence.class)) {
List<Token> tokens = selectCovered(aJCas, Token.class, sentence);
List<String> tokenTexts = asList(toText(tokens).toArray(new String[tokens.size()]));
DEPTree tree = NLPGetter.toDEPTree(tokenTexts);
AbstractComponent tagger = posTaggingModelProvider.getResource();
tagger.process(tree);
String[] posTags = tree.getPOSTags();
int i = 0;
for (Token t : tokens) {
String tag = posTags[i + 1];
Type posTag = posMappingProvider.getTagType(tag != null ? tag.intern() : null);
POS posAnno = (POS) cas.createAnnotation(posTag, t.getBegin(), t.getEnd());
posAnno.setPosValue(tag);
POSUtils.assignCoarseValue(posAnno);
posAnno.addToIndexes();
t.setPos(posAnno);
i++;
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.arktools-gpl
@Override
public void process(JCas jCas)
throws AnalysisEngineProcessException
{
modelProvider.configure(jCas.getCas());
mappingProvider.configure(jCas.getCas());
List<Token> tokens = selectCovered(jCas, Token.class, 0, jCas.getDocumentText().length());
List<TaggedToken> taggedTokens = tagTweetTokens(tokens, modelProvider.getResource());
for (TaggedToken taggedToken : taggedTokens) {
Type posType = mappingProvider.getTagType(taggedToken.tag);
POS pos = (POS) jCas.getCas().createAnnotation(posType, taggedToken.getBegin(),
taggedToken.getEnd());
pos.setPosValue(taggedToken.tag.intern());
pos.addToIndexes();
taggedToken.token.setPos(pos);
}
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.io.penntree-asl
private POS createPOS(JCas aJCas, PennTreeNode aPreterminal, int aBegin, int aEnd)
{
POS posAnno;
if (posMappingProvider != null) {
Type posTag = posMappingProvider.getTagType(aPreterminal.getLabel());
posAnno = (POS) aJCas.getCas().createAnnotation(posTag, aBegin, aEnd);
}
else {
posAnno = new POS(aJCas, aBegin, aEnd);
}
posAnno.setPosValue(
internTags && aPreterminal.getLabel() != null ? aPreterminal.getLabel().intern()
: aPreterminal.getLabel());
POSUtils.assignCoarseValue(posAnno);
posAnno.addToIndexes();
return posAnno;
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.io.penntree-asl
private void annotateTokenWithTag(JCas aJCas, String aToken, String aTag, int aCurrPosInText)
{
if (readToken) {
// Token
Token token = new Token(aJCas, aCurrPosInText, aToken.length() + aCurrPosInText);
token.addToIndexes();
if (readPOS) {
// Tag
Type posTag = posMappingProvider.getTagType(aTag);
POS pos = (POS) aJCas.getCas().createAnnotation(posTag, token.getBegin(),
token.getEnd());
pos.setPosValue(aTag);
POSUtils.assignCoarseValue(pos);
pos.addToIndexes();
// Set the POS for the Token
token.setPos(pos);
}
}
}
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-io-tcf
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);
}
}
代码示例来源:origin: webanno/webanno
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);
}
}
代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/de.tudarmstadt.ukp.clarin.webanno.tcf
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);
}
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.io.tcf-asl
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);
POSUtils.assignCoarseValue(outPos);
outPos.addToIndexes();
// Set the POS to the token
aTokens.get(posTokens[0].getID()).setPos(outPos);
}
}
代码示例来源:origin: webanno/webanno
user3.setDocumentText("test");
POS pos3 = new POS(user3, 0, 4);
pos3.setPosValue("test");
pos3.addToIndexes();
代码示例来源:origin: webanno/webanno
pos.setPosValue("pronoun");
pos.addToIndexes();
代码示例来源:origin: webanno/webanno
@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);
}
代码示例来源:origin: de.tudarmstadt.ukp.dkpro.core/de.tudarmstadt.ukp.dkpro.core.tokit-asl
pos.setPosValue(posValue);
pos.setCoarseValue(cposValue);
aToken.setPos(pos);
代码示例来源:origin: webanno/webanno
@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();
}
代码示例来源:origin: webanno/webanno
@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();
}
}
代码示例来源:origin: webanno/webanno
p1.setPosValue("POS1");
p1.addToIndexes();
t1.setPos(p1);
p2.setPosValue("POS2");
p2.addToIndexes();
t2.setPos(p2);
代码示例来源:origin: webanno/webanno
p1.setPosValue("pos1");
p1.addToIndexes();
t1.setPos(p1);
内容来源于网络,如有侵权,请联系作者删除!