Package edu.stanford.nlp.process

Source Code of edu.stanford.nlp.process.MorphologyTest

package edu.stanford.nlp.process;

import junit.framework.TestCase;

import edu.stanford.nlp.ling.*;
import static edu.stanford.nlp.process.Morphology.*;


public class MorphologyTest extends TestCase {

  private String[] exWords = {"brethren", "ducks", "saw", "saw",
                              "running", "making", "makking",
                              "stopped", "xopped",
                              "cleaner", "cleaner", "took", "bought",
                              "am", "were", "did", "n't", "wo",
                              "'s", "'s", "ca", "her", "her", "their",
                              "Books", "light-weight", "cease-fire",
                              "John_William_Smith", "Dogs",
                              "were", "AM", "'d", "'s", "'s", "ai",
                              "sha", "them", "US",
                              "Am", "AM", "ARE", "Was", "WERE", "was",
                              "played", "PLAYED",
                              "<br>", "-0800", "an", "out-rode", "viii",
                              "b-",
  };

  private String[] exTags = {"NNS", "NNS", "VBD", "NN",
                             "VBG", "VBG", "VBG",
                             "VBD", "VBD",
                             "NN", "JJR", "VBD", "VBD",
                             "VBP", "VBD", "VBD", "RB", "MD",
                             "VBZ", "POS", "MD", "PRP", "PRP$", "PRP$",
                             "NNPS", "JJ", "NN",
                             "NNP", "NNS",
                             "VBD", "VBP", "MD", "VBZ", "POS", "VBP",
                             "MD", "PRP", "PRP",
                             "VBP", "VBP", "VBP", "VBD", "VBD", "VBD",
                             "VBD", "VBD",
                             "SYM", "CD", "DT", "VBD", "FW",
                             "AFX",
  };

  private String[] exAnswers = {"brethren", "duck", "see", "saw",
                                "run", "make", "makk",
                                "stop", "xopp",
                                "cleaner", "cleaner", "take", "buy",
                                "be", "be", "do", "not", "will",
                                "be", "'s", "can", "she", "she", "they",
                                "Books", "light-weight", "cease-fire",
                                "John_William_Smith", "dog",
                                "be", "be", "would", "be", "'s", "be",
                                "shall", "they", "we",
                                "be", "be", "be", "be", "be", "be",
                                "play", "play",
                                "<br>", "-0800", "a", "out-ride", "viii",
                                "b-",
  };

  public void testMorph() {
    assert(exWords.length == exTags.length);
    assert(exWords.length == exAnswers.length);
    for (int i = 0; i < exWords.length; i++) {
      WordLemmaTag ans = lemmatizeStatic(new WordTag(exWords[i], exTags[i]));
      assertEquals("Stemmed " + exWords[i] + "/" + exTags[i] + " to lemma " +
                   ans.lemma() + " versus " + exAnswers[i],
                   ans.lemma(), exAnswers[i]);
    }
  }

  public void testStem() {
    assertEquals("John", stemStatic(new WordTag("John", "NNP")).word());
    assertEquals("Corporations", stemStatic(new WordTag("Corporations", "NNPS")).word());
    WordTag hunt = new WordTag("hunting", "V");
    assertEquals("hunt", stemStatic(hunt).word());
    assertEquals("hunt", lemmatizeStatic(hunt).lemma());
  }

  public void testDash() {
    Morphology morpha = new Morphology();
    morpha.stem("b-");
  }
}
TOP

Related Classes of edu.stanford.nlp.process.MorphologyTest

TOP
Copyright © 2018 www.massapi.com. 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.