当前位置: 首页>>代码示例>>Java>>正文


Java LastCovered类代码示例

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


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

示例1: createXStream

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

示例2: createXStream

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

示例3: testBasic

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

示例4: testBag

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

示例5: testNgram

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

  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(6, features.size());
  Iterator<Feature> iter = features.iterator();
  this.assertFeature("Ngram_Preceding_0_2", "brown_fox", iter.next());
  this.assertFeature("Ngram_Preceding_3_6", "OOB2_OOB1_The", iter.next());
  this.assertFeature(
      "Ngram_Preceding_0_1_FirstCovered_0_1_LastCovered_0_1",
      "fox_jumped_over",
      iter.next());
  this.assertFeature("Ngram_Following_1_3", "lazy_dog", iter.next());
  this.assertFeature("Ngram_Following_3_5", "._OOB1", iter.next());
  this.assertFeature("Ngram_Preceding_0_2_Following_1_2", "brown_fox_lazy", iter.next());

  extractor = new CleartkExtractor<Chunk, Token>(
      Token.class,
      new CoveredTextExtractor<Token>(),
      new Ngram(new Preceding(2), new Following(2)));

  jCas = JCasFactory.createJCas();
  this.tokenBuilder.buildTokens(this.jCas, "A B C D E");
  chunk = new Chunk(this.jCas, 4, 5);
  chunk.addToIndexes();
  Assert.assertEquals("C", chunk.getCoveredText());
  features = extractor.extract(this.jCas, chunk);
  Assert.assertEquals(1, features.size());
  this.assertFeature("Ngram_Preceding_0_2_Following_0_2", "A_B_D_E", features.get(0));

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

示例6: testBounds

import org.cleartk.ml.feature.extractor.CleartkExtractor.LastCovered; //导入依赖的package包/类
@Test
public void testBounds() throws Exception {
  CleartkExtractor<Chunk, Token> extractor = new CleartkExtractor<Chunk, Token>(
      Token.class,
      new CoveredTextExtractor<Token>(),
      new Preceding(2),
      new LastCovered(1),
      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());
  Collection<Sentence> sentences = JCasUtil.select(jCas, Sentence.class);
  Assert.assertEquals(2, sentences.size());
  Iterator<Sentence> sentIter = sentences.iterator();
  Sentence sent1 = sentIter.next();
  Sentence sent2 = sentIter.next();

  List<Feature> features = extractor.extractWithin(this.jCas, boughMilk, sent1);
  Assert.assertEquals(6, features.size());
  Iterator<Feature> iter = features.iterator();
  this.assertFeature("Preceding_0_2_1", "OOB1", iter.next());
  this.assertFeature("Preceding_0_2_0", "She", iter.next());
  this.assertFeature("LastCovered_0_1_0", "milk", iter.next());
  this.assertFeature("Following_0_3_0", ".", iter.next());
  this.assertFeature("Following_0_3_1", "OOB1", iter.next());
  this.assertFeature("Following_0_3_2", "OOB2", iter.next());

  features = extractor.extractWithin(this.jCas, boughMilk, sent2);
  Assert.assertEquals(6, features.size());
  iter = features.iterator();
  this.assertFeature("Preceding_0_2_1", "OOB2", iter.next());
  this.assertFeature("Preceding_0_2_0", "OOB1", iter.next());
  this.assertFeature("LastCovered_0_1_0", "OOB1", iter.next());
  this.assertFeature("Following_0_3_0", "OOB1", iter.next());
  this.assertFeature("Following_0_3_1", "He", iter.next());
  this.assertFeature("Following_0_3_2", "sold", iter.next());

  features = extractor.extractWithin(this.jCas, soldOranges, sent2);
  Assert.assertEquals(6, features.size());
  iter = features.iterator();
  this.assertFeature("Preceding_0_2_1", "OOB1", iter.next());
  this.assertFeature("Preceding_0_2_0", "He", iter.next());
  this.assertFeature("LastCovered_0_1_0", "oranges", iter.next());
  this.assertFeature("Following_0_3_0", ".", iter.next());
  this.assertFeature("Following_0_3_1", "OOB1", iter.next());
  this.assertFeature("Following_0_3_2", "OOB2", iter.next());
}
 
开发者ID:ClearTK,项目名称:cleartk,代码行数:56,代码来源:CleartkExtractorTest.java


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