@Test public void testSingleTokeNameAtSentenceStart() { String sentence = "Max a b c d"; SimpleTokenizer tokenizer = SimpleTokenizer.INSTANCE; String[] tokens = tokenizer.tokenize(sentence); Span[] names = mNameFinder.find(tokens); Assert.assertTrue(names.length == 1); Assert.assertTrue(names[0].getStart() == 0 && names[0].getEnd() == 1); }
public Span[] find(String[] textTokenized) { List<Span> namesFound = new LinkedList<>(); for (int offsetFrom = 0; offsetFrom < textTokenized.length; offsetFrom++) { Span nameFound = null; String[] tokensSearching; for (int offsetTo = offsetFrom; offsetTo < textTokenized.length; offsetTo++) { int lengthSearching = offsetTo - offsetFrom + 1; if (lengthSearching > mDictionary.getMaxTokenCount()) { break; } else { tokensSearching = new String[lengthSearching]; System.arraycopy(textTokenized, offsetFrom, tokensSearching, 0, lengthSearching); StringList entryForSearch = new StringList(tokensSearching); if (mDictionary.contains(entryForSearch)) { nameFound = new Span(offsetFrom, offsetTo + 1, type); } } } if (nameFound != null) { namesFound.add(nameFound); offsetFrom += nameFound.length() - 1; } } return namesFound.toArray(new Span[namesFound.size()]); }
DictionaryNameFinder implements TokenNameFinder { public Span[] find(String[] textTokenized) { List<Span> namesFound = new LinkedList<>(); for (int offsetFrom = 0; offsetFrom < textTokenized.length; offsetFrom++) { Span nameFound = null; String[] tokensSearching; for (int offsetTo = offsetFrom; offsetTo < textTokenized.length; offsetTo++) { int lengthSearching = offsetTo - offsetFrom + 1; if (lengthSearching > mDictionary.getMaxTokenCount()) { break; } else { tokensSearching = new String[lengthSearching]; System.arraycopy(textTokenized, offsetFrom, tokensSearching, 0, lengthSearching); StringList entryForSearch = new StringList(tokensSearching); if (mDictionary.contains(entryForSearch)) { nameFound = new Span(offsetFrom, offsetTo + 1, type); } } } if (nameFound != null) { namesFound.add(nameFound); offsetFrom += nameFound.length() - 1; } } return namesFound.toArray(new Span[namesFound.size()]); } }
DictionaryNameFinder implements TokenNameFinder { public Span[] find(String[] textTokenized) { List<Span> namesFound = new LinkedList<>(); for (int offsetFrom = 0; offsetFrom < textTokenized.length; offsetFrom++) { Span nameFound = null; String[] tokensSearching; for (int offsetTo = offsetFrom; offsetTo < textTokenized.length; offsetTo++) { int lengthSearching = offsetTo - offsetFrom + 1; if (lengthSearching > mDictionary.getMaxTokenCount()) { break; } else { tokensSearching = new String[lengthSearching]; System.arraycopy(textTokenized, offsetFrom, tokensSearching, 0, lengthSearching); StringList entryForSearch = new StringList(tokensSearching); if (mDictionary.contains(entryForSearch)) { nameFound = new Span(offsetFrom, offsetTo + 1, type); } } } if (nameFound != null) { namesFound.add(nameFound); offsetFrom += nameFound.length() - 1; } } return namesFound.toArray(new Span[namesFound.size()]); } DictionaryNameFinder(Dictionary dictionary, String type);  DictionaryNameFinder(Dictionary dictionary); }
DictionaryNameFinder implements TokenNameFinder { public Span[] find(String[] textTokenized) { List<Span> namesFound = new LinkedList<>(); for (int offsetFrom = 0; offsetFrom < textTokenized.length; offsetFrom++) { Span nameFound = null; String[] tokensSearching; for (int offsetTo = offsetFrom; offsetTo < textTokenized.length; offsetTo++) { int lengthSearching = offsetTo - offsetFrom + 1; if (lengthSearching > mDictionary.getMaxTokenCount()) { break; } else { tokensSearching = new String[lengthSearching]; System.arraycopy(textTokenized, offsetFrom, tokensSearching, 0, lengthSearching); StringList entryForSearch = new StringList(tokensSearching); if (mDictionary.contains(entryForSearch)) { nameFound = new Span(offsetFrom, offsetTo + 1, type); } } } if (nameFound != null) { namesFound.add(nameFound); offsetFrom += nameFound.length() - 1; } } return namesFound.toArray(new Span[namesFound.size()]); } DictionaryNameFinder(Dictionary dictionary, String type);  DictionaryNameFinder(Dictionary dictionary); Span[] find(String[] textTokenized); void clearAdaptiveData(); }
DictionaryNameFinder implements TokenNameFinder { public Span[] find(String[] textTokenized) { List<Span> namesFound = new LinkedList<>(); for (int offsetFrom = 0; offsetFrom < textTokenized.length; offsetFrom++) { Span nameFound = null; String[] tokensSearching; for (int offsetTo = offsetFrom; offsetTo < textTokenized.length; offsetTo++) { int lengthSearching = offsetTo - offsetFrom + 1; if (lengthSearching > mDictionary.getMaxTokenCount()) { break; } else { tokensSearching = new String[lengthSearching]; System.arraycopy(textTokenized, offsetFrom, tokensSearching, 0, lengthSearching); StringList entryForSearch = new StringList(tokensSearching); if (mDictionary.contains(entryForSearch)) { nameFound = new Span(offsetFrom, offsetTo + 1, type); } } } if (nameFound != null) { namesFound.add(nameFound); offsetFrom += nameFound.length() - 1; } } return namesFound.toArray(new Span[namesFound.size()]); } DictionaryNameFinder(Dictionary dictionary, String type);  DictionaryNameFinder(Dictionary dictionary); Span[] find(String[] textTokenized); void clearAdaptiveData();  }