@Test public void testLowercaseMethod() { String text = "The Immune System, I have known as Tumour-Associated Antigens (TAA). Antigens are often Proteins or other Macromolecules (e.g. carbohydrates C544)."; String lctx = "The immune system, I have known as tumour-associated antigens (TAA). antigens are often proteins or other macromolecules (e.g. carbohydrates C544)."; MatchingAnnotator ann = new MatchingAnnotator(MatchingAnnotator.MatchingStrategy.LOWERCASE); assertEquals(lctx, ann.convertToLowercase(text)); }
protected String convertToLowercase(String text) { Matcher m = wordLengthMatcher.matcher(text); StringBuffer sb = new StringBuffer(); while(m.find()) { String match = m.group(); Matcher u = uppercaseMatcher.matcher(match); if(u.matches()) { if(match.length() >= 8) m.appendReplacement(sb, m.group().toLowerCase()); } else { m.appendReplacement(sb, m.group().toLowerCase()); } } m.appendTail(sb); return sb.toString(); }
MatchingAnnotator extends Annotator { protected String convertToLowercase(String text) { Matcher m = wordLengthMatcher.matcher(text); StringBuffer sb = new StringBuffer(); while(m.find()) { String match = m.group(); Matcher u = uppercaseMatcher.matcher(match); if(u.matches()) { if(match.length() >= 8) m.appendReplacement(sb, m.group().toLowerCase()); } else { m.appendReplacement(sb, m.group().toLowerCase()); } } m.appendTail(sb); return sb.toString(); } }
MatchingAnnotator extends Annotator { protected String convertToLowercase(String text) { Matcher m = wordLengthMatcher.matcher(text); StringBuffer sb = new StringBuffer(); while(m.find()) { String match = m.group(); Matcher u = uppercaseMatcher.matcher(match); if(u.matches()) { if(match.length() >= 8) m.appendReplacement(sb, m.group().toLowerCase()); } else { m.appendReplacement(sb, m.group().toLowerCase()); } } m.appendTail(sb); return sb.toString(); } MatchingAnnotator();  MatchingAnnotator(MatchingStrategy matchingStrategy);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source, String type);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source, String type, int minWordLength); }
MatchingAnnotator extends Annotator { protected String convertToLowercase(String text) { Matcher m = wordLengthMatcher.matcher(text); StringBuffer sb = new StringBuffer(); while(m.find()) { String match = m.group(); Matcher u = uppercaseMatcher.matcher(match); if(u.matches()) { if(match.length() >= 8) m.appendReplacement(sb, m.group().toLowerCase()); } else { m.appendReplacement(sb, m.group().toLowerCase()); } } m.appendTail(sb); return sb.toString(); } MatchingAnnotator();  MatchingAnnotator(MatchingStrategy matchingStrategy);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source, String type);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source, String type, int minWordLength); void clearTermsToMatch(); void loadTermsToMatch(Collection<String> terms); void loadTermsToMatch(Stream<String> terms); void loadTermsToMatch(Resource path); void deleteTermsToMatch(Collection<String> terms); void deleteTermsToMatch(Stream<String> terms); void deleteTermsToMatch(Resource path); int countTerms(); @Override void annotate(Collection<Document> docs); void annotate(Iterable<Document> docs, Annotation.Source source); }
MatchingAnnotator extends Annotator { protected String convertToLowercase(String text) { Matcher m = wordLengthMatcher.matcher(text); StringBuffer sb = new StringBuffer(); while(m.find()) { String match = m.group(); Matcher u = uppercaseMatcher.matcher(match); if(u.matches()) { if(match.length() >= 8) m.appendReplacement(sb, m.group().toLowerCase()); } else { m.appendReplacement(sb, m.group().toLowerCase()); } } m.appendTail(sb); return sb.toString(); } MatchingAnnotator();  MatchingAnnotator(MatchingStrategy matchingStrategy);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source, String type);  MatchingAnnotator(MatchingStrategy matchLowercase, Annotation.Source source, String type, int minWordLength); void clearTermsToMatch(); void loadTermsToMatch(Collection<String> terms); void loadTermsToMatch(Stream<String> terms); void loadTermsToMatch(Resource path); void deleteTermsToMatch(Collection<String> terms); void deleteTermsToMatch(Stream<String> terms); void deleteTermsToMatch(Resource path); int countTerms(); @Override void annotate(Collection<Document> docs); void annotate(Iterable<Document> docs, Annotation.Source source);  }