FastMatcher { public List<OffsetPosition> matchCharacterLayoutToken(List<LayoutToken> tokens) { return matchCharacterLayoutToken(tokens, false); } FastMatcher();  FastMatcher(File file);  FastMatcher(File file, org.grobid.core.analyzers.Analyzer analyzer);  FastMatcher(File file, org.grobid.core.analyzers.Analyzer analyzer, boolean caseSensitive);  FastMatcher(InputStream is);  FastMatcher(InputStream is, org.grobid.core.analyzers.Analyzer analyzer);  FastMatcher(InputStream is, org.grobid.core.analyzers.Analyzer analyzer, boolean caseSensitive); int loadTerms(File file); int loadTerms(File file, boolean caseSensitive); int loadTerms(File file, org.grobid.core.analyzers.Analyzer analyzer, boolean caseSensitive); int loadTerms(InputStream is, org.grobid.core.analyzers.Analyzer analyzer, boolean caseSensitive); int loadTerm(String term, org.grobid.core.analyzers.Analyzer analyzer); int loadTerm(String term, org.grobid.core.analyzers.Analyzer analyzer, boolean ignoreDelimiters); int loadTerm(String term, org.grobid.core.analyzers.Analyzer analyzer, boolean ignoreDelimiters, boolean caseSensitive); List<OffsetPosition> matchToken(String text); List<OffsetPosition> matchToken(String text, boolean caseSensitive); List<OffsetPosition> matchLayoutToken(List<LayoutToken> tokens); List<OffsetPosition> matchLayoutToken(List<LayoutToken> tokens, boolean ignoreDelimiters, boolean caseSensitive); List<OffsetPosition> matchCharacter(String text); List<OffsetPosition> matchCharacter(String text, boolean caseSensitive); List<OffsetPosition> matchCharacterLayoutToken(List<LayoutToken> tokens); List<OffsetPosition> matchCharacterLayoutToken(List<LayoutToken> tokens, boolean caseSensitive); List<OffsetPosition> matcherPairs(List<Pair<String, String>> tokens); List<OffsetPosition> matcherPairs(List<Pair<String, String>> tokens, boolean caseSensitive);  }
@Test public void testMatchList_location_1Match() throws Exception { target = new FastMatcher(this.getClass().getResourceAsStream("location.txt")); final String input = "This is Bronx"; List<LayoutToken> tokenisedInput = GrobidAnalyzer.getInstance().tokenizeWithLayoutToken(input); final List<OffsetPosition> offsetPositions = target.matchCharacterLayoutToken(tokenisedInput); assertThat(offsetPositions, hasSize(1)); assertThat(offsetPositions.get(0).start, is(4)); assertThat(offsetPositions.get(0).end, is(4)); }
@Test public void testMatchList_location_2Matches() throws Exception { target = new FastMatcher(this.getClass().getResourceAsStream("location.txt")); final String input = "This is The Bronx"; List<LayoutToken> tokenisedInput = GrobidAnalyzer.getInstance().tokenizeWithLayoutToken(input); final List<OffsetPosition> offsetPositions = target.matchCharacterLayoutToken(tokenisedInput); assertThat(offsetPositions, hasSize(2)); assertThat(offsetPositions.get(0).start, is(4)); assertThat(offsetPositions.get(0).end, is(6)); assertThat(offsetPositions.get(1).start, is(6)); assertThat(offsetPositions.get(1).end, is(6)); }