@Test public void testForNullPointerException() { String[] sentence = new String[]{"The","dogs","were","running","and","barking","down","the","street"}; String[] sentencePOS = new String[]{"DT","NNS","VBD","VBG","CC","VBG","RP","DT","NN"}; String[] expectedLemma = new String[]{"the","dog","is","run","and","bark","down","the","street"}; String[] actualLemma = dictionaryLemmatizer.lemmatize(sentence, sentencePOS); for (int i = 0;i < sentence.length;i++) { if (!actualLemma[i].equals("O")) Assert.assertEquals(expectedLemma[i], actualLemma[i]); } }
public String[] lemmatize(final String[] tokens, final String[] postags) { List<String> lemmas = new ArrayList<>(); for (int i = 0; i < tokens.length; i++) { lemmas.add(this.lemmatize(tokens[i], postags[i])); } return lemmas.toArray(new String[lemmas.size()]); }
DictionaryLemmatizer implements Lemmatizer { public String[] lemmatize(final String[] tokens, final String[] postags) { List<String> lemmas = new ArrayList<>(); for (int i = 0; i < tokens.length; i++) { lemmas.add(this.lemmatize(tokens[i], postags[i])); } return lemmas.toArray(new String[lemmas.size()]); } }
DictionaryLemmatizer implements Lemmatizer { public String[] lemmatize(final String[] tokens, final String[] postags) { List<String> lemmas = new ArrayList<>(); for (int i = 0; i < tokens.length; i++) { lemmas.add(this.lemmatize(tokens[i], postags[i])); } return lemmas.toArray(new String[lemmas.size()]); } DictionaryLemmatizer(final InputStream dictionary);  DictionaryLemmatizer(File dictionaryFile);  DictionaryLemmatizer(Path dictionaryFile); }
DictionaryLemmatizer implements Lemmatizer { public String[] lemmatize(final String[] tokens, final String[] postags) { List<String> lemmas = new ArrayList<>(); for (int i = 0; i < tokens.length; i++) { lemmas.add(this.lemmatize(tokens[i], postags[i])); } return lemmas.toArray(new String[lemmas.size()]); } DictionaryLemmatizer(final InputStream dictionary);  DictionaryLemmatizer(File dictionaryFile);  DictionaryLemmatizer(Path dictionaryFile); Map<List<String>, List<String>> getDictMap(); String[] lemmatize(final String[] tokens, final String[] postags); List<List<String>> lemmatize(final List<String> tokens, final List<String> posTags); }
DictionaryLemmatizer implements Lemmatizer { public String[] lemmatize(final String[] tokens, final String[] postags) { List<String> lemmas = new ArrayList<>(); for (int i = 0; i < tokens.length; i++) { lemmas.add(this.lemmatize(tokens[i], postags[i])); } return lemmas.toArray(new String[lemmas.size()]); } DictionaryLemmatizer(final InputStream dictionary);  DictionaryLemmatizer(File dictionaryFile);  DictionaryLemmatizer(Path dictionaryFile); Map<List<String>, List<String>> getDictMap(); String[] lemmatize(final String[] tokens, final String[] postags); List<List<String>> lemmatize(final List<String> tokens, final List<String> posTags);  }