List of usage examples for opennlp.tools.postag POSDictionary put
public String[] put(String word, String... tags)
From source file:es.ehu.si.ixa.pipe.convert.Convert.java
/** * Aggregates {@code POSDictionary} from a list of words and its postag. * /* w w w . ja v a 2 s . c o m*/ * @param inputLines * the list of words and postag per line * @param tagDict * the POSDictionary to which the lemma dictionary will be added */ private void addPOSTaggerDict(List<String> inputLines, POSDictionary tagDict) { ListMultimap<String, String> dictMultiMap = ArrayListMultimap.create(); for (String line : inputLines) { String[] lineArray = line.split(" "); if (lineArray.length == 2) { dictMultiMap.put(lineArray[0], lineArray[1]); } } for (String token : dictMultiMap.keySet()) { List<String> tags = dictMultiMap.get(token); if (tags.size() == 1) { tagDict.put(token, tags.toArray(new String[tags.size()])); } } }
From source file:es.ehu.si.ixa.pipe.convert.Convert.java
/** * Generates {@code POSDictionary} from a list of monosemic words and its postag. * form\tab\lemma\tabpostag//w w w . j a va 2s . c o m * * @param inputLines * the list of words and postag per line * @return the POSDictionary */ private POSDictionary getPOSTaggerDict(List<String> inputLines) { POSDictionary posTaggerDict = new POSDictionary(); ListMultimap<String, String> dictMultiMap = ArrayListMultimap.create(); for (String line : inputLines) { String[] lineArray = line.split("\t"); if (lineArray.length == 3) { if (!lineArray[0].contains("<")) { dictMultiMap.put(lineArray[0], lineArray[2]); } } } for (String token : dictMultiMap.keySet()) { List<String> tags = dictMultiMap.get(token); //add only monosemic words if (tags.size() == 1) { posTaggerDict.put(token, tags.toArray(new String[tags.size()])); } } return posTaggerDict; }