de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(12.7k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS.<init>()方法的一些代码示例,展示了POS.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。POS.<init>()方法的具体详情如下:
包路径:de.tudarmstadt.ukp.dkpro.core.api.lexmorph.type.pos.POS
类名称:POS
方法名:<init>

POS.<init>介绍

[英]Never called. Disable default constructor
[中]从没打过电话。禁用默认构造函数

代码示例

代码示例来源:origin: de.tudarmstadt.ukp.clarin.webanno/webanno-io-tsv

POS outPos = new POS(aJCas, outToken.getBegin(), outToken.getEnd());
outPos.setPosValue(pos.get(i));
outPos.addToIndexes();

代码示例来源:origin: webanno/webanno

@Test
public void thatRelationAttachmentBehaviorOnCreateWorks() throws Exception
{
  TokenBuilder<Token, Sentence> builder = new TokenBuilder<>(Token.class, Sentence.class);
  builder.buildTokens(jcas, "This is a test .");
  for (Token t : select(jcas, Token.class)) {
    POS pos = new POS(jcas, t.getBegin(), t.getEnd());
    t.setPos(pos);
    pos.addToIndexes();
  }
  RelationAdapter sut = new RelationAdapter(featureSupportRegistry, null, depLayer,
      FEAT_REL_TARGET, FEAT_REL_SOURCE,
      asList(dependencyLayerGovernor, dependencyLayerDependent), behaviors);
  List<POS> posAnnotations = new ArrayList<>(select(jcas, POS.class));
  List<Token> tokens = new ArrayList<>(select(jcas, Token.class));
  POS source = posAnnotations.get(0);
  POS target = posAnnotations.get(1);
  AnnotationFS dep = sut.add(document, username, source, target, jcas, 0,
      jcas.getDocumentText().length());
  assertThat(FSUtil.getFeature(dep, FEAT_REL_SOURCE, Token.class)).isEqualTo(tokens.get(0));
  assertThat(FSUtil.getFeature(dep, FEAT_REL_TARGET, Token.class)).isEqualTo(tokens.get(1));
}

代码示例来源:origin: webanno/webanno

@Test
public void thatRelationStackingBehaviorOnCreateDoesNotThrowException() throws Exception
{
  TokenBuilder<Token, Sentence> builder = new TokenBuilder<>(Token.class, Sentence.class);
  builder.buildTokens(jcas, "This is a test .\nThis is sentence two .");
  for (Token t : select(jcas, Token.class)) {
    POS pos = new POS(jcas, t.getBegin(), t.getEnd());
    t.setPos(pos);
    pos.addToIndexes();
  }
  RelationAdapter sut = new RelationAdapter(featureSupportRegistry, null, depLayer,
      FEAT_REL_TARGET, FEAT_REL_SOURCE,
      asList(dependencyLayerGovernor, dependencyLayerDependent), behaviors);
  List<POS> posAnnotations = new ArrayList<>(select(jcas, POS.class));
  List<Token> tokens = new ArrayList<>(select(jcas, Token.class));
  POS source = posAnnotations.get(0);
  POS target = posAnnotations.get(1);
  depLayer.setAllowStacking(true);
  AnnotationFS dep1 = sut.add(document, username, source, target, jcas, 0,
      jcas.getDocumentText().length());
  AnnotationFS dep2 = sut.add(document, username, source, target, jcas, 0,
      jcas.getDocumentText().length());
  
  assertThat(FSUtil.getFeature(dep1, FEAT_REL_SOURCE, Token.class)).isEqualTo(tokens.get(0));
  assertThat(FSUtil.getFeature(dep1, FEAT_REL_TARGET, Token.class)).isEqualTo(tokens.get(1));
  assertThat(FSUtil.getFeature(dep2, FEAT_REL_SOURCE, Token.class)).isEqualTo(tokens.get(0));
  assertThat(FSUtil.getFeature(dep2, FEAT_REL_TARGET, Token.class)).isEqualTo(tokens.get(1));
}

代码示例来源: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.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: webanno/webanno

POS pos3 = new POS(user3, 0, 4);
pos3.addToIndexes();

代码示例来源: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

@Test
public void thatRelationCrossSentenceBehaviorOnCreateThrowsException() throws Exception
{
  depLayer.setCrossSentence(false);
  
  TokenBuilder<Token, Sentence> builder = new TokenBuilder<>(Token.class, Sentence.class);
  builder.buildTokens(jcas, "This is a test .\nThis is sentence two .");
  for (Token t : select(jcas, Token.class)) {
    POS pos = new POS(jcas, t.getBegin(), t.getEnd());
    t.setPos(pos);
    pos.addToIndexes();
  }
  RelationAdapter sut = new RelationAdapter(featureSupportRegistry, null, depLayer,
      FEAT_REL_TARGET, FEAT_REL_SOURCE,
      asList(dependencyLayerGovernor, dependencyLayerDependent), behaviors);
  List<POS> posAnnotations = new ArrayList<>(select(jcas, POS.class));
  POS source = posAnnotations.get(0);
  POS target = posAnnotations.get(posAnnotations.size() - 1);
  assertThatExceptionOfType(MultipleSentenceCoveredException.class)
      .isThrownBy(() -> sut.add(document, username, source, target, jcas, 0, 
          jcas.getDocumentText().length()))
      .withMessageContaining("multiple sentences");
}

代码示例来源:origin: webanno/webanno

@Test
public void thatRelationCrossSentenceBehaviorOnValidateGeneratesErrors() throws Exception
{
  TokenBuilder<Token, Sentence> builder = new TokenBuilder<>(Token.class, Sentence.class);
  builder.buildTokens(jcas, "This is a test .\nThis is sentence two .");
  for (Token t : select(jcas, Token.class)) {
    POS pos = new POS(jcas, t.getBegin(), t.getEnd());
    t.setPos(pos);
    pos.addToIndexes();
  }
  RelationAdapter sut = new RelationAdapter(featureSupportRegistry, null, depLayer,
      FEAT_REL_TARGET, FEAT_REL_SOURCE,
      asList(dependencyLayerGovernor, dependencyLayerDependent), behaviors);
  List<POS> posAnnotations = new ArrayList<>(select(jcas, POS.class));
  POS source = posAnnotations.get(0);
  POS target = posAnnotations.get(posAnnotations.size() - 1);
  depLayer.setCrossSentence(true);
  sut.add(document, username, source, target, jcas, 0, jcas.getDocumentText().length());
  
  depLayer.setCrossSentence(false);
  assertThat(sut.validate(jcas))
      .extracting(Pair::getLeft)
      .usingElementComparatorIgnoringFields("source", "message")
      .containsExactly(LogMessage.error(null, ""));
}

代码示例来源:origin: webanno/webanno

POS pos = new POS(jcas, 8, 9);
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: webanno/webanno

@Test
public void thatRelationStackingBehaviorOnCreateThrowsException() throws Exception
{
  depLayer.setAllowStacking(false);
  
  TokenBuilder<Token, Sentence> builder = new TokenBuilder<>(Token.class, Sentence.class);
  builder.buildTokens(jcas, "This is a test .\nThis is sentence two .");
  for (Token t : select(jcas, Token.class)) {
    POS pos = new POS(jcas, t.getBegin(), t.getEnd());
    t.setPos(pos);
    pos.addToIndexes();
  }
  RelationAdapter sut = new RelationAdapter(featureSupportRegistry, null, depLayer,
      FEAT_REL_TARGET, FEAT_REL_SOURCE,
      asList(dependencyLayerGovernor, dependencyLayerDependent), behaviors);
  List<POS> posAnnotations = new ArrayList<>(select(jcas, POS.class));
  POS source = posAnnotations.get(0);
  POS target = posAnnotations.get(1);
  // First annotation should work
  sut.add(document, username, source, target, jcas, 0, jcas.getDocumentText().length());
  
  // Second one at the same location should cause an error
  assertThatExceptionOfType(AnnotationException.class)
      .isThrownBy(() -> sut.add(document, username, source, target, jcas, 0, 
          jcas.getDocumentText().length()))
      .withMessageContaining("stacking is not enabled");
}

代码示例来源:origin: webanno/webanno

POS pos = new POS(jcas, t.getBegin(), t.getEnd());
t.setPos(pos);
pos.addToIndexes();

代码示例来源:origin: webanno/webanno

POS pos = new POS(jcas, t.getBegin(), t.getEnd());
t.setPos(pos);
pos.addToIndexes();

代码示例来源: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

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();

代码示例来源:origin: webanno/webanno

t1.setMorph(m1);
POS p1 = new POS(jcas, t1.getBegin(), t1.getEnd());
p1.setPosValue("pos1");
p1.addToIndexes();

相关文章