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

Java Preceding类代码示例

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

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



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

示例1: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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.Preceding; //导入依赖的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.Preceding; //导入依赖的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.Preceding; //导入依赖的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.Preceding; //导入依赖的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.Preceding; //导入依赖的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: createXStream

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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


示例8: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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


示例9: createXStream

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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


示例10: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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


示例11: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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


示例12: VerbClauseTemporalAnnotator

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的package包/类
public VerbClauseTemporalAnnotator() {
  this.eventID = 1;

  FeatureExtractor1<Token> precedingAuxiliaries = new CleartkExtractor<Token, Token>(
      Token.class,
      new TokenTextForSelectedPosExtractor("MD", "TO", "IN", "VB", "RB"),
      new Preceding(3));
  FeatureExtractor1<Token> tokenStemExtractor = new TypePathExtractor<Token>(Token.class, "stem");
  FeatureExtractor1<Token> tokenPOSExtractor = new TypePathExtractor<Token>(Token.class, "pos");

  this.sourceFeatureExtractors = Lists.newArrayList();
  this.sourceFeatureExtractors.add(new NamingExtractor1<Token>("Source", new CoveredTextExtractor<Token>()));
  this.sourceFeatureExtractors.add(new NamingExtractor1<Token>("Source", tokenPOSExtractor));
  this.sourceFeatureExtractors.add(new NamingExtractor1<Token>("Source", tokenStemExtractor));
  this.sourceFeatureExtractors.add(new NamingExtractor1<Token>("Source", precedingAuxiliaries));

  this.targetFeatureExtractors = Lists.newArrayList();
  this.targetFeatureExtractors.add(new NamingExtractor1<Token>("Target", new CoveredTextExtractor<Token>()));
  this.targetFeatureExtractors.add(new NamingExtractor1<Token>("Target", tokenPOSExtractor));
  this.targetFeatureExtractors.add(new NamingExtractor1<Token>("Target", tokenStemExtractor));
  this.targetFeatureExtractors.add(new NamingExtractor1<Token>("Target", precedingAuxiliaries));

  this.betweenAnchorsFeatureExtractors = new ArrayList<FeatureExtractor1<Annotation>>();
  this.betweenAnchorsFeatureExtractors.add(new NamingExtractor1<Annotation>(
      "WordsBetween",
      new CleartkExtractor<Annotation, Token>(Token.class, new CoveredTextExtractor<Token>(), new Bag(new Covered()))));
  this.pathExtractor = new TargetPathExtractor();
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:29,代码来源:VerbClauseTemporalAnnotator.java


示例13: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);
  this.eventFeatureExtractors.add(new CleartkExtractor<Event, Token>(Token.class, new TypePathExtractor<Token>(
      Token.class,
      "pos"), new Bag(new Covered())));

  this.contextExtractors.add(new CleartkExtractor<Event, Token>(
      Token.class,
      new TokenTextForSelectedPosExtractor("VB"),
      new Bag(new Preceding(3))));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:13,代码来源:EventAspectAnnotator.java


示例14: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);
  this.contextExtractors.add(new CleartkExtractor<Event, Token>(
      Token.class,
      new TokenTextForSelectedPosExtractor("RB", "MD", "TO", "IN"),
      new Bag(new Preceding(3))));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:9,代码来源:EventModalityAnnotator.java


示例15: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);
  this.eventFeatureExtractors.add(new TextSliceExtractor<Event>(-2));
  this.eventFeatureExtractors.add(new CleartkExtractor<Event, Token>(Token.class, new TypePathExtractor<Token>(
      Token.class,
      "pos"), new Bag(new Covered())));

  this.contextExtractors.add(new CleartkExtractor<Event, Token>(
      Token.class,
      new TokenTextForSelectedPosExtractor("MD", "TO", "IN", "VB"),
      new Preceding(3)));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:14,代码来源:EventTenseAnnotator.java


示例16: initialize

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的package包/类
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);
  this.contextExtractors.add(new CleartkExtractor<Event, Token>(
      Token.class,
      new TokenTextForSelectedPosExtractor("RB"),
      new Bag(new Preceding(3))));
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:9,代码来源:EventPolarityAnnotator.java


示例17: testNgrams

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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


示例18: testFocus

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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


示例19: testExtractBetween

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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


示例20: testNestedNames

import org.cleartk.ml.feature.extractor.CleartkExtractor.Preceding; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Selection类代码示例发布时间:2022-05-23
下一篇:
Java BitUtil类代码示例发布时间: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