Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package it.uniroma2.art.coda.test.ae;
 
 
 
public class CityAnnotator extends JCasAnnotator_ImplBase {
	public static final String CITY_ARRAY = "cityArray";
	private String [] cityArray;
	public void process(JCas aJCasthrows AnalysisEngineProcessException {
		Pattern patter = Pattern.compile("\\b([A-Z]?[a-z]+)\\b");
		String text = aJCas.getDocumentText();
		Matcher matcher = patter.matcher(text);
		if( == null || .==0){
			// the array is null or has no element, so there is no reason to execute the matcher
			return;
		}
		int count = 0;
		while(matcher.find(count)){
			String textFound = matcher.group();
			for(int i=0; i<.; ++i){
				String currentCity = [i].toLowerCase();
				if(currentCity.compareToIgnoreCase(textFound) == 0){
					City cityAnnotation = new City(aJCas);
					cityAnnotation.setBegin(matcher.start());
					cityAnnotation.setEnd(matcher.end());
					cityAnnotation.setName(textFound);
					cityAnnotation.setWord(textFound);
					cityAnnotation.addToIndexes();
					break// the city has been found, so skip to the next word
				}
			}
			count = matcher.end();
		}
	}
New to GrepCode? Check out our FAQ X