@Override public boolean processLine(String line) throws IOException { List<String> synonyms = newArrayList(Splitter.on(',').trimResults().split(line)); for (String term: synonyms) { for (String synonym: synonyms) { if (!term.equals(synonym)) { builder.add(new CharsRef(term), new CharsRef(synonym), true); } } } return true; }
/** * Add a phrase->phrase synonym mapping. * Phrases are character sequences where words are * separated with character zero (U+0000). Empty words * (two U+0000s in a row) are not allowed in the input nor * the output! * * @param input input phrase * @param output output phrase * @param includeOrig true if the original should be included */ public void add(CharsRef input, CharsRef output, boolean includeOrig) { add(input, countWords(input), output, countWords(output), includeOrig); }
/** * Add a phrase->phrase synonym mapping. * Phrases are character sequences where words are * separated with character zero (\u0000). Empty words * (two \u0000s in a row) are not allowed in the input nor * the output! * * @param input input phrase * @param output output phrase * @param includeOrig true if the original should be included */ public void add(CharsRef input, CharsRef output, boolean includeOrig) { add(input, countWords(input), output, countWords(output), includeOrig); }
public void add(final boolean keepOrig, final String... synonyms) throws IOException { if (synonyms == null || synonyms.length == 1) return; final CharsRef input = getCharsRef(synonyms[0]); for (int i = 1; i < synonyms.length; i++) { final CharsRef output = getCharsRef(synonyms[i]); builder.add(input, output, keepOrig); if (bidirectional) builder.add(output, input, keepOrig); } }
/** * Add a phrase->phrase synonym mapping. * Phrases are character sequences where words are * separated with character zero (U+0000). Empty words * (two U+0000s in a row) are not allowed in the input nor * the output! * * @param input input phrase * @param output output phrase * @param includeOrig true if the original should be included */ public void add(CharsRef input, CharsRef output, boolean includeOrig) { add(input, countWords(input), output, countWords(output), includeOrig); }