Package opennlp.tools.namefind

Examples of opennlp.tools.namefind.NameSample


      for (int i = 0; i < tokenArray.length; i++) {
        tokenArray[i] = tokenList.get(i).getCoveredText();
      }

      NameSample trainingSentence = new NameSample(tokenArray, names, null, isClearAdaptiveData);

      if (trainingSentence.getSentence().length != 0) {
        nameFinderSamples.add(trainingSentence);
       
        if (isClearAdaptiveData) {
          isClearAdaptiveData = false;
        }
View Full Code Here


     
      // if one span remains, create it here
      if (beginIndex != -1)
        names.add(new Span(beginIndex, endIndex, tags.get(beginIndex).substring(2)));
     
      return new NameSample(sentence.toArray(new String[sentence.size()]), names.toArray(new Span[names.size()]), isClearAdaptiveData);
    }
    else if (line != null) {
      // Just filter out empty events, if two lines in a row are empty
      return read();
    }
View Full Code Here

     
      // if one span remains, create it here
      if (beginIndex != -1)
        names.add(extract(beginIndex, endIndex, tags.get(beginIndex)));
     
      return new NameSample(sentence.toArray(new String[sentence.size()]), names.toArray(new Span[names.size()]), isClearAdaptiveData);
    }
    else if (line != null) {
      // Just filter out empty events, if two lines in a row are empty
      return read();
    }
View Full Code Here

      // if one span remains, create it here
      if (beginIndex != -1)
        names.add(extract(beginIndex, endIndex, tags.get(beginIndex)));

      return new NameSample(sentence.toArray(new String[sentence.size()]), names.toArray(new Span[names.size()]), isClearAdaptiveData);
    }
    else if (line != null) {
      // Just filter out empty events, if two lines in a row are empty
      return read();
    }
View Full Code Here

        // Simple way to drop intersecting spans, otherwise the
        // NameSample is invalid
        Span reducedNames[] = NameFinderME.dropOverlappingSpans(
            names.toArray(new Span[names.size()]));
       
        NameSample nameSample = new NameSample(whitespaceTokenizerLine,
            reducedNames, false);
       
        System.out.println(nameSample.toString());
       
        perfMon.incrementCounter();
      }
    }
    catch (IOException e) {
View Full Code Here

  @Test
  public void testParsingEnglishSample() throws IOException {

    ObjectStream<NameSample> sampleStream = openData(LANGUAGE.EN, ENGLISH_SAMPLE);

    NameSample personName = sampleStream.read();
    assertNotNull(personName);

    assertEquals(9, personName.getSentence().length);
    assertEquals(0, personName.getNames().length);
    assertEquals(true, personName.isClearAdaptiveDataSet());

    personName = sampleStream.read();

    assertNotNull(personName);

    assertEquals(2, personName.getSentence().length);
    assertEquals(1, personName.getNames().length);
    assertEquals(false, personName.isClearAdaptiveDataSet());

    Span nameSpan = personName.getNames()[0];
    assertEquals(0, nameSpan.getStart());
    assertEquals(2, nameSpan.getEnd());

    assertNull(sampleStream.read());
  }
View Full Code Here

  @Test
  public void testParsingGermanSample() throws IOException {

    ObjectStream<NameSample> sampleStream = openData(LANGUAGE.DE, GERMAN_SAMPLE);
   
    NameSample personName = sampleStream.read();
    assertNotNull(personName);
   
    assertEquals(5, personName.getSentence().length);
    assertEquals(0, personName.getNames().length);
    assertEquals(true, personName.isClearAdaptiveDataSet());
  }
View Full Code Here

  @Test
  public void testParsingSpanishSample() throws IOException {
   
    ObjectStream<NameSample> sampleStream = openData(LANGUAGE.ES, "conll2002-es.sample");
   
    NameSample personName = sampleStream.read();
   
    assertNotNull(personName);
   
    assertEquals(5, personName.getSentence().length);
    assertEquals(1, personName.getNames().length);
    assertEquals(true, personName.isClearAdaptiveDataSet());
   
    Span nameSpan = personName.getNames()[0];
    assertEquals(0, nameSpan.getStart());
    assertEquals(4, nameSpan.getEnd());
    assertEquals(true, personName.isClearAdaptiveDataSet());
   
    assertEquals(0, sampleStream.read().getNames().length);
   
    assertNull(sampleStream.read());
  }
View Full Code Here

 
  @Test
  public void testParsingDutchSample() throws IOException {
    ObjectStream<NameSample> sampleStream = openData(LANGUAGE.NL, "conll2002-nl.sample");
   
    NameSample personName = sampleStream.read();
   
    assertEquals(0, personName.getNames().length);
    assertTrue(personName.isClearAdaptiveDataSet());
   
    personName = sampleStream.read();
   
    assertFalse(personName.isClearAdaptiveDataSet());
   
    assertNull(sampleStream.read());
  }
View Full Code Here

      for (int i = 0; i < tokenArray.length; i++) {
        tokenArray[i] = ((AnnotationFS) tokenList.get(i))
            .getCoveredText();
      }
     
      NameSample traingSentence = new NameSample(tokenArray, names, null, false);
     
      if (traingSentence.getSentence().length != 0) {
        nameFinderSamples.add(traingSentence);
      }
      else {
        if (logger.isLoggable(Level.INFO)) {
          logger.log(Level.INFO, "Sentence without tokens: " +
View Full Code Here

TOP

Related Classes of opennlp.tools.namefind.NameSample

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.