Package opennlp.tools.util

Examples of opennlp.tools.util.Span


        "traditional",
        "meal",
        "."};
   
    NameSample nameSample = new NameSample(sentence,
        new Span[]{new Span(0, 2, "person")}, false);
   
    EventStream eventStream = new NameFinderEventStream(
        ObjectStreamUtils.createObjectStream(nameSample));
   
    assertTrue(eventStream.hasNext());
View Full Code Here


      "considering", "sending", "additional", "American", "forces",
      "to", "Afghanistan", "."};

  private static NameSample createSimpleNameSampleA() {

    Span[] names = { new Span(0, 4, "Location"), new Span(5, 7, "Person"),
        new Span(14, 15, "Location") };

    NameSample nameSample;
    nameSample = new NameSample(sentence, names, false);

    return nameSample;
View Full Code Here

    return nameSample;
  }

  private static NameSample createSimpleNameSampleB() {

    Span[] names = { new Span(0, 4, "Location"), new Span(14, 15, "Location") };

    NameSample nameSample;
    nameSample = new NameSample(sentence, names, false);

    return nameSample;
View Full Code Here

        "a",
        "delicious",
        "traditional",
        "meal."};

    Span names[] = nameFinder.find(sentence);

    assertEquals(1, names.length);
    assertEquals(new Span(0, 1, TYPE), names[0]);

    sentence = new String[] {
        "Hi",
        "Mike",
        ",",
        "it's",
        "Stefanie",
        "Schmidt",
        "."
    };

    names = nameFinder.find(sentence);

    assertEquals(2, names.length);
    assertEquals(new Span(1, 2, TYPE), names[0]);
    assertEquals(new Span(4, 6, TYPE), names[1]);
  }
View Full Code Here

        "Schmidt", "." };

    Span[] names2 = nameFinder.find(sentence2);

    assertEquals(2, names2.length);
    assertEquals(new Span(1, 2, "person"), names2[0]);
    assertEquals(new Span(4, 6, "person"), names2[1]);
    assertEquals("person", names2[0].getType());
    assertEquals("person", names2[1].getType());

    String sentence[] = { "Alisa", "appreciated", "the", "hint", "and",
        "enjoyed", "a", "delicious", "traditional", "meal." };

    Span names[] = nameFinder.find(sentence);

    assertEquals(1, names.length);
    assertEquals(new Span(0, 1, "person"), names[0]);
    assertTrue(hasOtherAsOutcome(nameFinderModel));
  }
View Full Code Here

    String[] sentence = ("Neil Abercrombie Anibal Acevedo-Vila Gary Ackerman " +
        "Robert Aderholt Daniel Akaka Todd Akin Lamar Alexander Rodney Alexander").split("\\s+");

    Span[] names1 = nameFinder.find(sentence);

    assertEquals(new Span(0, 2, TYPE), names1[0]);
    assertEquals(new Span(2, 4, TYPE), names1[1]);
    assertEquals(new Span(4, 6, TYPE), names1[2]);
    assertTrue(!hasOtherAsOutcome(nameFinderModel));
  }
View Full Code Here

    String[] sentence = ("Neil Abercrombie Anibal Acevedo-Vila Gary Ackerman " +
        "Robert Aderholt Daniel Akaka Todd Akin Lamar Alexander Rodney Alexander").split("\\s+");

    Span[] names1 = nameFinder.find(sentence);

    assertEquals(new Span(0, 2, "person"), names1[0]);
    assertEquals(new Span(2, 4, "person"), names1[1]);
    assertEquals(new Span(4, 6, "person"), names1[2]);
    assertEquals("person", names1[2].getType());
   
    assertTrue(!hasOtherAsOutcome(nameFinderModel));
  }
View Full Code Here

    String[] sentence = ("NATO United States Barack Obama").split("\\s+");

    Span[] names1 = nameFinder.find(sentence);

    assertEquals(new Span(0, 1, "location"), names1[0]);
    assertEquals(new Span(1, 3, "person"), names1[1]);
    assertEquals("person", names1[2].getType());
    assertTrue(!hasOtherAsOutcome(nameFinderModel));
  }
View Full Code Here

    return false;
  }
 
  @Test
  public void testDropOverlappingSpans() {
    Span spans[] = new Span[] {new Span(1, 10), new Span(1,11), new Span(1,11), new Span(5, 15)};
    Span remainingSpan[] = NameFinderME.dropOverlappingSpans(spans);
   
    assertEquals(new Span(1, 11), remainingSpan[0]);
  }
View Full Code Here

        "Korea", "move", "toward", "ending", "its", "nuclear", "weapons",
        "programs", "." };

    Span[] names1 = nameFinder.find(sentence);

    assertEquals(new Span(0, 4, "location"), names1[0]);
    assertEquals(new Span(5, 7, "person"), names1[1]);
    assertEquals(new Span(10, 12, "location"), names1[2]);
    assertEquals(new Span(28, 30, "location"), names1[3]);
    assertEquals("location", names1[0].getType());
    assertEquals("person", names1[1].getType());
    assertEquals("location", names1[2].getType());
    assertEquals("location", names1[3].getType());

    sentence = new String[] { "Scott", "Snyder", "is", "the", "director", "of",
        "the", "Center", "for", "U", ".", "S", ".", "Korea", "Policy", "." };
   
    Span[] names2 = nameFinder.find(sentence);
   
    assertEquals(2, names2.length);
    assertEquals(new Span(0, 2, "person"), names2[0]);
    assertEquals(new Span(7, 15, "organization"), names2[1]);
    assertEquals("person", names2[0].getType());
    assertEquals("organization", names2[1].getType());
  }
View Full Code Here

TOP

Related Classes of opennlp.tools.util.Span

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.