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

Java Following类代码示例

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

本文整理汇总了Java中org.cleartk.ml.feature.extractor.CleartkExtractor.Following的典型用法代码示例。如果您正苦于以下问题:Java Following类的具体用法?Java Following怎么用?Java Following使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Following类属于org.cleartk.ml.feature.extractor.CleartkExtractor包,在下文中一共展示了Following类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
	super.initialize(context);

	// the token feature extractor: text, char pattern (uppercase, digits,
	// etc.), and part-of-speech
	this.extractor = new CombinedExtractor1<Token>(new CoveredTextExtractor<Token>(),
			new FeatureFunctionExtractor<Token>(new CoveredTextExtractor<Token>(),
					new CharacterCategoryPatternFunction<Token>(
							CharacterCategoryPatternFunction.PatternType.REPEATS_MERGED))
	/* , new TypePathExtractor(Token.class, "pos") */);

	// the context feature extractor: the features above for the 3 preceding
	// and 3 following tokens
	this.contextExtractor = new CleartkExtractor<Token, Token>(Token.class, this.extractor, new Preceding(3),
			new Following(3));

	// the chunking definition: Tokens will be combined to form Reason annotation
	this.chunking = new BioChunking<Token, Reason>(Token.class, Reason.class, null);
}
 
开发者ID:IE4OpenData,项目名称:Octroy,代码行数:21,代码来源:ReasonAnnotator.java


示例2: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
	super.initialize(context);

	// the token feature extractor: text, char pattern (uppercase, digits,
	// etc.), and part-of-speech
	this.extractor = new CombinedExtractor1<Token>(

			new FeatureFunctionExtractor<Token>(new CoveredTextExtractor<Token>(),
					new CharacterCategoryPatternFunction<Token>(PatternType.REPEATS_MERGED)),
			new TypePathExtractor<Token>(Token.class, "pos/PosValue"));

	// the context feature extractor: the features above for the 3 preceding
	// and 3 following tokens
	this.contextExtractor = new CleartkExtractor<Token, Token>(Token.class, this.extractor, new Preceding(2),
			new Following(1));

	// the chunking definition: Tokens will be combined to form
	// NamedEntityMentions, with labels
	// from the "mentionType" attribute so that we get B-location, I-person,
	// etc.
	this.chunking = new BioChunking<Token, FigureMention>(Token.class, FigureMention.class);
}
 
开发者ID:quadrama,项目名称:DramaNLP,代码行数:24,代码来源:ClearTkMentionAnnotator.java


示例3: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);

  // a feature extractor that creates features corresponding to the word, the word lower cased
  // the capitalization of the word, the numeric characterization of the word, and character ngram
  // suffixes of length 2 and 3.
  this.tokenFeatureExtractor = new FeatureFunctionExtractor<Token>(
      new CoveredTextExtractor<Token>(),
      new LowerCaseFeatureFunction(),
      new CapitalTypeFeatureFunction(),
      new NumericTypeFeatureFunction(),
      new CharacterNgramFeatureFunction(Orientation.RIGHT_TO_LEFT, 0, 2),
      new CharacterNgramFeatureFunction(Orientation.RIGHT_TO_LEFT, 0, 3));

  // a feature extractor that extracts the surrounding token texts (within the same sentence)
  this.contextFeatureExtractor = new CleartkExtractor<Token, Token>(
      Token.class,
      new CoveredTextExtractor<Token>(),
      new Preceding(2),
      new Following(2));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:22,代码来源:ExamplePosAnnotator.java


示例4: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);

  // the token feature extractor: text, char pattern (uppercase, digits, etc.), and part-of-speech
  this.extractor = new CombinedExtractor1<Token>(
      new FeatureFunctionExtractor<Token>(
          new CoveredTextExtractor<Token>(),
          new CharacterCategoryPatternFunction<Token>(PatternType.REPEATS_MERGED)),
      new TypePathExtractor<Token>(Token.class, "pos"));

  // the context feature extractor: the features above for the 3 preceding and 3 following tokens
  this.contextExtractor = new CleartkExtractor<Token, Token>(
      Token.class,
      this.extractor,
      new Preceding(3),
      new Following(3));

  // the chunking definition: Tokens will be combined to form NamedEntityMentions, with labels
  // from the "mentionType" attribute so that we get B-location, I-person, etc.
  this.chunking = new BioChunking<Token, NamedEntityMention>(
      Token.class,
      NamedEntityMention.class,
      "mentionType");
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:26,代码来源:NamedEntityChunker.java


示例5: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);

  // define chunking type
  this.chunking = new BioChunking<Token, Time>(Token.class, Time.class);

  // add features: word, character pattern, stem, pos
  this.tokenFeatureExtractors = Lists.newArrayList();
  this.tokenFeatureExtractors.add(new CoveredTextExtractor<Token>());
  NamedFeatureExtractor1<Token> ex = CharacterCategoryPatternFunction.createExtractor();
  this.tokenFeatureExtractors.add(ex);
  this.tokenFeatureExtractors.add(new TimeWordsExtractor<Token>());
  this.tokenFeatureExtractors.add(new TypePathExtractor<Token>(Token.class, "stem"));
  this.tokenFeatureExtractors.add(new TypePathExtractor<Token>(Token.class, "pos"));
      
  // add window of features before and after
  this.contextFeatureExtractors = Lists.newArrayList();
  for (FeatureExtractor1<Token> extractor : this.tokenFeatureExtractors) {
    this.contextFeatureExtractors.add(new CleartkExtractor<Token, Token>(Token.class, extractor, new Preceding(
        3), new Following(3)));
  }
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:24,代码来源:TimeAnnotator.java


示例6: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);

  // add features: word, stem, pos
  this.tokenFeatureExtractors = Lists.newArrayList();
  this.tokenFeatureExtractors.add(new CoveredTextExtractor<Token>());
  this.tokenFeatureExtractors.add(new TypePathExtractor<Token>(Token.class, "stem"));
  this.tokenFeatureExtractors.add(new TypePathExtractor<Token>(Token.class, "pos"));
  this.tokenFeatureExtractors.add(new ParentNodeFeaturesExtractor());

  // add window of features before and after
  this.contextExtractors = Lists.newArrayList();
  this.contextExtractors.add(new CleartkExtractor<Token, Token>(
      Token.class,
      new CoveredTextExtractor<Token>(),
      new Preceding(3),
      new Following(3)));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:20,代码来源:EventAnnotator.java


示例7: testCleartkExtractor2

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Test
public void testCleartkExtractor2() throws Exception {
  CleartkExtractor<Chunk, Token> extractor = new CleartkExtractor<Chunk, Token>(
      Token.class,
      new TypePathExtractor<Token>(Token.class, "pos"),
      new Following(3));

  this.tokenBuilder.buildTokens(
      this.jCas,
      "The quick brown fox jumped over the lazy dog.",
      "The quick brown fox jumped over the lazy dog .",
      "DT JJ JJ NN VBD IN DT JJ NN .");

  Chunk chunk = new Chunk(this.jCas, 20, 31);
  chunk.addToIndexes();
  Assert.assertEquals("jumped over", chunk.getCoveredText());

  List<Feature> features = extractor.extract(this.jCas, chunk);
  assertEquals(3, features.size());

  assertFeature("Following_0_3_0_TypePath(Pos)", "DT", features.get(0));
  assertFeature("Following_0_3_1_TypePath(Pos)", "JJ", features.get(1));
  assertFeature("Following_0_3_2_TypePath(Pos)", "NN", features.get(2));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:25,代码来源:FeatureExtractionTutorialTest.java


示例8: createXStream

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
public static XStream createXStream() {
	//define alias so the xml file can be read easier
	XStream xstream = new XStream();
	// org.cleartk.classifier.feature.*
	xstream.alias("TypePathExtractor", TypePathExtractor.class);
	xstream.alias("FeatureCollection", FeatureCollection.class);

	// org.cleartk.ml.feature.extractor.*
	xstream.alias("CleartkExtractor", CleartkExtractor.class);
	xstream.alias("CombinedExtractor1", CombinedExtractor1.class);
	xstream.alias("CoveredTextExtractor", CoveredTextExtractor.class);
	xstream.alias("DirectedDistanceExtractor", DirectedDistanceExtractor.class);
       xstream.alias("DistanceExtractor", DistanceExtractor.class);
       xstream.alias("FeatureExtractor1", FeatureExtractor1.class);
       xstream.alias("FeatureExtractor2", FeatureExtractor2.class);
       xstream.alias("NamedFeatureExtractor1", NamedFeatureExtractor1.class);
       xstream.alias("NamingExtractor1", NamingExtractor1.class);
       xstream.alias("RelativePositionExtractor", RelativePositionExtractor.class);
       xstream.alias("WhiteSpaceExtractor", WhiteSpaceExtractor.class);


	// within CleartkExtractor
	xstream.alias("Bag", Bag.class);
	xstream.alias("Preceding", Preceding.class);
	xstream.alias("Following", Following.class);
	xstream.alias("Covered", Covered.class);
	xstream.alias("FirstCovered", FirstCovered.class);
	xstream.alias("LastCovered", LastCovered.class);
	xstream.alias("Ngram", Ngram.class);

	xstream.alias("list", ArrayList.class);
	return xstream;
}
 
开发者ID:floschne,项目名称:NLP_ProjectNER,代码行数:34,代码来源:XStreamFactory.java


示例9: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);
  headWordExtractor = new HeadWordExtractor<Sentence>();
  shapeExtractor = new ShapeExtractor<Token>();
  whWordExtractor = new WHWordExtractor<Sentence>();
  ngramExtractor = new CleartkExtractor<Token, Token>(Token.class, new TypePathExtractor<Token>(Token.class, "lemma"),
      new Ngram(new Preceding(1), new Focus(), new Following(1)));
}
 
开发者ID:utk4rsh,项目名称:question-classifier,代码行数:10,代码来源:QuestionCategoryAnnotator.java


示例10: createXStream

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
public static XStream createXStream()
{
    // define alias so the xml file can be read easier
    XStream xstream = new XStream();
    xstream.alias("list", ArrayList.class);

    xstream.alias("TypePathExtractor", TypePathExtractor.class);
    xstream.alias("FeatureCollection", FeatureCollection.class);


    xstream.alias("Bag", Bag.class);
    xstream.alias("Preceding", Preceding.class);
    xstream.alias("Following", Following.class);
    xstream.alias("Covered", Covered.class);
    xstream.alias("FirstCovered", FirstCovered.class);
    xstream.alias("LastCovered", LastCovered.class);
    xstream.alias("Ngram", Ngram.class);

    xstream.alias("CleartkExtractor", CleartkExtractor.class);
    xstream.alias("Covered", Covered.class);
    xstream.alias("Following", Following.class);
    xstream.alias("Preceding", Preceding.class);
    xstream.alias("CoveredTextExtractor", CoveredTextExtractor.class);
    xstream.alias("FeatureExtractor1", FeatureExtractor1.class);
    xstream.alias("TypePathExtractor", TypePathExtractor.class);
    xstream.alias("CapitalTypeFeatureFunction", CapitalTypeFeatureFunction.class);
    xstream.alias("CharacterNgramFeatureFunction", CharacterNgramFeatureFunction.class);
    xstream.alias("FeatureFunctionExtractor", FeatureFunctionExtractor.class);
    xstream.alias("LowerCaseFeatureFunction", LowerCaseFeatureFunction.class);
    xstream.alias("NumericTypeFeatureFunction", NumericTypeFeatureFunction.class);

    return xstream;
}
 
开发者ID:tudarmstadt-lt,项目名称:GermaNER,代码行数:34,代码来源:XStreamFactory.java


示例11: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
public void initialize(UimaContext context) throws ResourceInitializationException {
  simpleExtractors = Lists.newArrayList();

  FeatureExtractor1<Token> wordExtractor = new CoveredTextExtractor<Token>();

  CharacterNgramFeatureFunction.Orientation fromLeft = CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT;
  CharacterNgramFeatureFunction.Orientation fromRight = CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT;
  simpleExtractors.add(new FeatureFunctionExtractor<Token>(
      wordExtractor,
      new LowerCaseFeatureFunction(),
      new CapitalTypeFeatureFunction(),
      new NumericTypeFeatureFunction(),
      new CharacterNgramFeatureFunction(fromLeft, 0, 1),
      new CharacterNgramFeatureFunction(fromLeft, 0, 2),
      new CharacterNgramFeatureFunction(fromLeft, 0, 3),
      new CharacterNgramFeatureFunction(fromRight, 0, 1),
      new CharacterNgramFeatureFunction(fromRight, 0, 2),
      new CharacterNgramFeatureFunction(fromRight, 0, 3),
      new CharacterNgramFeatureFunction(fromRight, 0, 4),
      new CharacterNgramFeatureFunction(fromRight, 0, 5),
      new CharacterNgramFeatureFunction(fromRight, 0, 6)));

  windowExtractors = Lists.newArrayList();
  windowExtractors.add(new CleartkExtractor<Token, Token>(
      Token.class,
      wordExtractor,
      new Preceding(2),
      new Following(2)));

  windowNGramExtractors = Lists.newArrayList();
  windowNGramExtractors.add(new CleartkExtractor<Token, Token>(Token.class, wordExtractor, new Ngram(
      new Preceding(2)), new Ngram(new Following(2))));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:34,代码来源:DefaultFeatureExtractor.java


示例12: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);

  // a list of feature extractors that require only the token
  this.tokenFeatureExtractors = Lists.newArrayList();

  // a list of feature extractors that require the token and the sentence
  this.tokenSentenceFeatureExtractors = Lists.newArrayList();

  // basic feature extractors for word, stem and part-of-speech
  FeatureExtractor1<Token> wordExtractor, stemExtractor;
  wordExtractor = new CoveredTextExtractor<Token>();
  stemExtractor = new TypePathExtractor<Token>(Token.class, "stem");

  // aliases for NGram feature parameters
  CharacterNgramFeatureFunction.Orientation fromRight = CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT;

  // add the feature extractor for the word itself
  // also add proliferators which create new features from the word text
  this.tokenFeatureExtractors.add(new FeatureFunctionExtractor<Token>(
      wordExtractor,
      new LowerCaseFeatureFunction(),
      new CapitalTypeFeatureFunction(),
      new NumericTypeFeatureFunction(),
      new CharacterNgramFeatureFunction(fromRight, 0, 2),
      new CharacterNgramFeatureFunction(fromRight, 0, 3)));

  // add the feature extractors for the stem and part of speech
  this.tokenFeatureExtractors.add(stemExtractor);

  // add 2 stems to the left and right
  this.tokenSentenceFeatureExtractors.add(new CleartkExtractor<Token, Token>(
      Token.class,
      stemExtractor,
      new Preceding(2),
      new Following(2)));

}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:39,代码来源:NonSequenceExamplePosAnnotator.java


示例13: testNgrams

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Test
public void testNgrams() throws Exception {
  CleartkExtractor<Chunk, Token> extractor = new CleartkExtractor<Chunk, Token>(
      Token.class,
      new CoveredTextExtractor<Token>(),
      new Ngrams(2, new Preceding(3)),
      new Ngrams(2, new Following(3)),
      new Ngrams(4, new Preceding(3), new Following(3)),
      new Ngrams(3, new Preceding(1, 5)),
      new Ngrams(2, new Covered()),
      new Ngrams(3, new Covered()));

  this.tokenBuilder.buildTokens(
      this.jCas,
      "The quick brown fox jumped over the lazy dog.",
      "The quick brown fox jumped over the lazy dog .",
      "DT JJ JJ NN VBD IN DT JJ NN .");
  Chunk chunk = new Chunk(this.jCas, 20, 31);
  chunk.addToIndexes();
  Assert.assertEquals("jumped over", chunk.getCoveredText());

  List<Feature> features = extractor.extract(this.jCas, chunk);
  Assert.assertEquals(10, features.size());
  Iterator<Feature> iter = features.iterator();
  this.assertFeature("2grams_Preceding_0_3", "quick_brown", iter.next());
  this.assertFeature("2grams_Preceding_0_3", "brown_fox", iter.next());
  this.assertFeature("2grams_Following_0_3", "the_lazy", iter.next());
  this.assertFeature("2grams_Following_0_3", "lazy_dog", iter.next());
  this.assertFeature("4grams_Preceding_0_3_Following_0_3", "quick_brown_fox_the", iter.next());
  this.assertFeature("4grams_Preceding_0_3_Following_0_3", "brown_fox_the_lazy", iter.next());
  this.assertFeature("4grams_Preceding_0_3_Following_0_3", "fox_the_lazy_dog", iter.next());
  this.assertFeature("3grams_Preceding_1_5", "OOB1_The_quick", iter.next());
  this.assertFeature("3grams_Preceding_1_5", "The_quick_brown", iter.next());
  this.assertFeature("2grams_Covered", "jumped_over", iter.next());
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:36,代码来源:CleartkExtractorTest.java


示例14: testFocus

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Test
public void testFocus() throws Exception {
  CleartkExtractor<Token, Token> extractor = new CleartkExtractor<Token, Token>(
      Token.class,
      new CoveredTextExtractor<Token>(),
      new Focus(),
      new Bag(new Preceding(1), new Focus()),
      new Ngram(new Following(2), new Focus()));

  this.tokenBuilder.buildTokens(
      this.jCas,
      "The quick brown fox jumped over the lazy dog.",
      "The quick brown fox jumped over the lazy dog .",
      "DT JJ JJ NN VBD IN DT JJ NN .");
  Token jumped = JCasUtil.selectByIndex(this.jCas, Token.class, 4);
  Assert.assertEquals("jumped", jumped.getCoveredText());

  List<Feature> features = extractor.extract(this.jCas, jumped);
  Assert.assertEquals(4, features.size());
  Iterator<Feature> iter = features.iterator();
  this.assertFeature("Focus", "jumped", iter.next());
  this.assertFeature("Bag_Preceding_0_1_Focus", "fox", iter.next());
  this.assertFeature("Bag_Preceding_0_1_Focus", "jumped", iter.next());
  this.assertFeature("Ngram_Following_0_2_Focus", "over_the_jumped", iter.next());

  CleartkExtractor<Token, Chunk> chunkExtractor = new CleartkExtractor<Token, Chunk>(
      Chunk.class,
      new CoveredTextExtractor<Chunk>(),
      new Focus());
  try {
    chunkExtractor.extract(this.jCas, jumped);
    Assert.fail("Expected exception from Focus of wrong type");
  } catch (ClassCastException e) {
  }
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:36,代码来源:CleartkExtractorTest.java


示例15: testExtractBetween

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Test
public void testExtractBetween() throws Exception {
  CleartkExtractor<Chunk, Token> extractor = new CleartkExtractor<Chunk, Token>(
      Token.class,
      new CoveredTextExtractor<Token>(),
      new Bag(new Preceding(2)),
      new Covered(),
      new Ngram(new Following(3)));

  this.tokenBuilder.buildTokens(
      this.jCas,
      "She bought milk.\nHe sold oranges.",
      "She bought milk .\nHe sold oranges .");
  Chunk boughMilk = new Chunk(this.jCas, 4, 15);
  boughMilk.addToIndexes();
  Assert.assertEquals("bought milk", boughMilk.getCoveredText());
  Chunk soldOranges = new Chunk(this.jCas, 20, 32);
  soldOranges.addToIndexes();
  Assert.assertEquals("sold oranges", soldOranges.getCoveredText());

  List<Feature> features = extractor.extractBetween(this.jCas, boughMilk, soldOranges);
  Assert.assertEquals(5, features.size());
  Iterator<Feature> iter = features.iterator();
  this.assertFeature("Bag_Preceding_0_2", "bought", iter.next());
  this.assertFeature("Bag_Preceding_0_2", "milk", iter.next());
  this.assertFeature("Covered_0", ".", iter.next());
  this.assertFeature("Covered_1", "He", iter.next());
  this.assertFeature("Ngram_Following_0_3", "sold_oranges_.", iter.next());
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:30,代码来源:CleartkExtractorTest.java


示例16: testNestedNames

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Test
public void testNestedNames() throws Exception {
  CleartkExtractor<Chunk, Token> extractor = new CleartkExtractor<Chunk, Token>(
      Token.class,
      new TypePathExtractor<Token>(Token.class, "pos"),
      new Count(new Preceding(1, 5), new Covered()),
      new Bag(new Preceding(3)),
      new Ngram(new Following(2)),
      new Ngrams(3, new Following(1, 6)));

  this.tokenBuilder.buildTokens(
      this.jCas,
      "The quick brown fox jumped over the lazy dog.",
      "The quick brown fox jumped over the lazy dog .",
      "DT JJ JJ NN VBD IN DT JJ NN .");
  Chunk chunk = new Chunk(this.jCas, 20, 31);
  chunk.addToIndexes();
  Assert.assertEquals("jumped over", chunk.getCoveredText());

  List<Feature> features = extractor.extract(this.jCas, chunk);
  Iterator<Feature> iter = features.iterator();
  this.assertFeature("Count_Preceding_1_5_Covered_TypePath(Pos)_OOB1", 1, iter.next());
  this.assertFeature("Count_Preceding_1_5_Covered_TypePath(Pos)_DT", 1, iter.next());
  this.assertFeature("Count_Preceding_1_5_Covered_TypePath(Pos)_JJ", 2, iter.next());
  this.assertFeature("Count_Preceding_1_5_Covered_TypePath(Pos)_VBD", 1, iter.next());
  this.assertFeature("Count_Preceding_1_5_Covered_TypePath(Pos)_IN", 1, iter.next());
  this.assertFeature("Bag_Preceding_0_3_TypePath(Pos)", "JJ", iter.next());
  this.assertFeature("Bag_Preceding_0_3_TypePath(Pos)", "JJ", iter.next());
  this.assertFeature("Bag_Preceding_0_3_TypePath(Pos)", "NN", iter.next());
  this.assertFeature("Ngram_Following_0_2_TypePath(Pos)", "DT_JJ", iter.next());
  this.assertFeature("3grams_Following_1_6_TypePath(Pos)", "JJ_NN_.", iter.next());
  this.assertFeature("3grams_Following_1_6_TypePath(Pos)", "NN_._OOB1", iter.next());
  this.assertFeature("3grams_Following_1_6_TypePath(Pos)", "._OOB1_OOB2", iter.next());
  Assert.assertFalse(iter.hasNext());
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:36,代码来源:CleartkExtractorTest.java


示例17: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Override
public void initialize(UimaContext context)
        throws ResourceInitializationException {
    super.initialize(context);

    featureExtractors = new ArrayList<>();

    featureExtractors.add(new FeatureFunctionExtractor(new TypePathExtractor(Token.class, "pos/PosValue")));


    //featureExtractors.add(new FeatureFunctionExtractor(new TypePathExtractor(Token.class, "lemma")));

    //featureExtractors.add(new CleartkExtractor(Token.class,
      //      new FeatureFunctionExtractor(new TypePathExtractor(Token.class, "pos/PosValue")),
        //    new Preceding(2), new Following(2)));

    //featureExtractors.add(new CleartkExtractor(Token.class,
    //        new FeatureFunctionExtractor(new TypePathExtractor(Token.class, "lemma")),
    //        new Preceding(2), new Following(2)));

    //featureExtractors.add(new CleartkExtractor(Token.class,
      //      new FeatureFunctionExtractor(new TypePathExtractor(Token.class, "lemma")),
        //    new Preceding(3), new Following(3)));

    featureExtractors.add(new FeatureFunctionExtractor(
            new CoveredTextExtractor(), new LowerCaseFeatureFunction(), new CapitalTypeFeatureFunction(),
            new NumericTypeFeatureFunction(), new CharacterCategoryPatternFunction<Token>(), new ContainsHyphenFeatureFunction(),
            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT, 0, 2),
            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT, 0, 3),
            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT, 0, 4),
            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT, 0, 5),
            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT, 0, 2),
            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT, 0, 3),
            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT, 0, 4),
            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT, 0, 5)
    ));


    featureExtractors.add(
            new CleartkExtractor(Token.class,
                    new FeatureFunctionExtractor(new CoveredTextExtractor(), new LowerCaseFeatureFunction(), new CapitalTypeFeatureFunction(),
                            new NumericTypeFeatureFunction(), new CharacterCategoryPatternFunction<Token>(), new ContainsHyphenFeatureFunction(),
                            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT, 0, 2),
                            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT, 0, 3),
                            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT, 0, 4),
                            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.RIGHT_TO_LEFT, 0, 5),
                            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT, 0, 2),
                            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT, 0, 3),
                            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT, 0, 4),
                            new CharacterNgramFeatureFunction(CharacterNgramFeatureFunction.Orientation.LEFT_TO_RIGHT, 0, 5)),
                    new Preceding(2),
                    new Following(2)));


}
 
开发者ID:uhh-lt,项目名称:LT-ABSA,代码行数:56,代码来源:AspectAnnotator.java


示例18: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Override
  public void initialize(UimaContext context) throws ResourceInitializationException {
    super.initialize(context);

    final FeatureExtractor1<Token> prepOrVerbExtractor = new FilteringExtractor<Token>(
        Token.class,
        new CoveredTextExtractor<Token>()) {
      @Override
      protected boolean accept(Token token) {
        return token.getPos().equals("TO") || token.getPos().equals("IN")
            || token.getPos().startsWith("VB");
      }
    };

    
    List<FeatureExtractor1<Event>> srcExtractors = Lists.newArrayList();
    srcExtractors.add(new TypePathExtractor<Event>(Event.class, "tense"));
    srcExtractors.add(new TypePathExtractor<Event>(Event.class, "eventClass"));
    srcExtractors.add(new CleartkExtractor<Event, Token>(Token.class, prepOrVerbExtractor, new Ngram(new Following(5))));
    this.setSourceExtractors(srcExtractors);
    
    List<FeatureExtractor1<Time>> tgtExtractors = Lists.newArrayList();
    tgtExtractors.add(new CleartkExtractor<Time, Token>(Token.class, new CoveredTextExtractor<Token>(), new Bag(new Covered())));
    tgtExtractors.add(new TypePathExtractor<Time>(Time.class, "timeType"));
    tgtExtractors.add(new TypePathExtractor<Time>(Time.class, "value"));
    tgtExtractors.add(new CleartkExtractor<Time, Token>(Token.class, prepOrVerbExtractor, new Ngram(new Preceding(5))));
    this.setTargetExtractors(tgtExtractors);

//    this.setTargetExtractors(Arrays.asList(
//        new CleartkExtractor<Time, Token>(Token.class, new CoveredTextExtractor(), new Bag(new Covered())),
//        new TypePathExtractor<Time>(Time.class, "timeType"),
//        new TypePathExtractor<Time>(Time.class, "value"),
//        new CleartkExtractor<Time, Token>(Token.class, prepOrVerbExtractor, new Ngram(new Preceding(5)))));

    // this will probably only extract when the source (Event) precedes the target (Time)
    
    List<FeatureExtractor2<Anchor, Anchor>> btweenExtractors = Lists.newArrayList();
    btweenExtractors.add(new CleartkExtractor<Anchor, Token>(
        Token.class,
        prepOrVerbExtractor,
        new Bag(new Covered())));
  }
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:43,代码来源:TemporalLinkEventToSameSentenceTimeAnnotator.java


示例19: testBasic

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Test
public void testBasic() throws Exception {
  CleartkExtractor<Chunk, Token> extractor = new CleartkExtractor<Chunk, Token>(
      Token.class,
      new CoveredTextExtractor<Token>(),
      new Preceding(2),
      new Preceding(3, 6),
      new Covered(),
      new FirstCovered(1),
      new FirstCovered(1, 3),
      new LastCovered(1),
      new LastCovered(1, 3),
      new Following(1, 3),
      new Following(3, 5),
      new Preceding(5, 6),
      new Following(5, 6));

  this.tokenBuilder.buildTokens(
      this.jCas,
      "The quick brown fox jumped over the lazy dog.",
      "The quick brown fox jumped over the lazy dog .",
      "DT JJ JJ NN VBD IN DT JJ NN .");
  Chunk chunk = new Chunk(this.jCas, 20, 31);
  chunk.addToIndexes();
  Assert.assertEquals("jumped over", chunk.getCoveredText());

  List<Feature> features = extractor.extract(this.jCas, chunk);
  Assert.assertEquals(19, features.size());
  Iterator<Feature> iter = features.iterator();
  this.assertFeature("Preceding_0_2_1", "brown", iter.next());
  this.assertFeature("Preceding_0_2_0", "fox", iter.next());
  this.assertFeature("Preceding_3_6_5", "OOB2", iter.next());
  this.assertFeature("Preceding_3_6_4", "OOB1", iter.next());
  this.assertFeature("Preceding_3_6_3", "The", iter.next());
  this.assertFeature("Covered_0", "jumped", iter.next());
  this.assertFeature("Covered_1", "over", iter.next());
  this.assertFeature("FirstCovered_0_1_0", "jumped", iter.next());
  this.assertFeature("FirstCovered_1_3_1", "over", iter.next());
  this.assertFeature("FirstCovered_1_3_2", "OOB1", iter.next());
  this.assertFeature("LastCovered_0_1_0", "over", iter.next());
  this.assertFeature("LastCovered_1_3_2", "OOB1", iter.next());
  this.assertFeature("LastCovered_1_3_1", "jumped", iter.next());
  this.assertFeature("Following_1_3_1", "lazy", iter.next());
  this.assertFeature("Following_1_3_2", "dog", iter.next());
  this.assertFeature("Following_3_5_3", ".", iter.next());
  this.assertFeature("Following_3_5_4", "OOB1", iter.next());
  this.assertFeature("Preceding_5_6_5", "OOB2", iter.next());
  this.assertFeature("Following_5_6_5", "OOB2", iter.next());
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:50,代码来源:CleartkExtractorTest.java


示例20: testBag

import org.cleartk.ml.feature.extractor.CleartkExtractor.Following; //导入依赖的package包/类
@Test
public void testBag() throws Exception {
  CleartkExtractor<Chunk, Token> extractor = new CleartkExtractor<Chunk, Token>(
      Token.class,
      new TypePathExtractor<Token>(Token.class, "pos"),
      new Bag(new Preceding(2)),
      new Bag(new Preceding(3, 6)),
      new Bag(new FirstCovered(1), new LastCovered(1)),
      new Bag(new Following(1, 3)),
      new Bag(new Following(3, 5)),
      new Bag(new Preceding(1), new Following(1)),
      new Bag(new Bag(new Bag(new Following(1, 3)))));

  this.tokenBuilder.buildTokens(
      this.jCas,
      "The quick brown fox jumped over the lazy dog.",
      "The quick brown fox jumped over the lazy dog .",
      "DT JJ JJ NN VBD IN DT JJ NN .");
  Chunk chunk = new Chunk(this.jCas, 20, 31);
  chunk.addToIndexes();
  Assert.assertEquals("jumped over", chunk.getCoveredText());

  List<Feature> features = extractor.extract(this.jCas, chunk);
  Assert.assertEquals(15, features.size());
  Iterator<Feature> iter = features.iterator();
  this.assertFeature("Bag_Preceding_0_2_TypePath(Pos)", "JJ", iter.next());
  this.assertFeature("Bag_Preceding_0_2_TypePath(Pos)", "NN", iter.next());
  this.assertFeature("Bag_Preceding_3_6_TypePath(Pos)", "OOB2", iter.next());
  this.assertFeature("Bag_Preceding_3_6_TypePath(Pos)", "OOB1", iter.next());
  this.assertFeature("Bag_Preceding_3_6_TypePath(Pos)", "DT", iter.next());
  this.assertFeature("Bag_FirstCovered_0_1_LastCovered_0_1_TypePath(Pos)", "VBD", iter.next());
  this.assertFeature("Bag_FirstCovered_0_1_LastCovered_0_1_TypePath(Pos)", "IN", iter.next());
  this.assertFeature("Bag_Following_1_3_TypePath(Pos)", "JJ", iter.next());
  this.assertFeature("Bag_Following_1_3_TypePath(Pos)", "NN", iter.next());
  this.assertFeature("Bag_Following_3_5_TypePath(Pos)", ".", iter.next());
  this.assertFeature("Bag_Following_3_5_TypePath(Pos)", "OOB1", iter.next());
  this.assertFeature("Bag_Preceding_0_1_Following_0_1_TypePath(Pos)", "NN", iter.next());
  this.assertFeature("Bag_Preceding_0_1_Following_0_1_TypePath(Pos)", "DT", iter.next());
  this.assertFeature("Bag_Bag_Bag_Following_1_3_TypePath(Pos)", "JJ", iter.next());
  this.assertFeature("Bag_Bag_Bag_Following_1_3_TypePath(Pos)", "NN", iter.next());
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:42,代码来源:CleartkExtractorTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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