public class Names {
/**
* Facade method: get all place and human names from a text string
*/
public ScoredList[] getProperNames(String [] words) {
ScoredList placeNames = new ScoredList();
ScoredList humanNames = new ScoredList();
ScoredList[] ret = new ScoredList[2];
ret[0] = humanNames; ret[1] = placeNames;
if (words == null) return ret;
for (int i=0; i<words.length; i++) {
// 5 word human names:
if (isHumanName(words, i, 5)) {
String s = words[i] + " " + words[i+1] + " " + words[i+2] + " " + words[i+3] + " " + words[i+4];
humanNames.addValue(s);
i += 4;
continue;
}
// 4 word human names:
if (isHumanName(words, i, 4)) {
String s = words[i] + " " + words[i+1] + " " + words[i+2] + " " + words[i+3];
humanNames.addValue(s);
i += 3;
continue;
}
// 3 word names:
if (isPlaceName(words, i, 3)) {
String s = words[i] + " " + words[i+1] + " " + words[i+2];
placeNames.addValue(s);
i += 2;
continue;
}
if (isHumanName(words, i, 3)) {
String s = words[i] + " " + words[i+1] + " " + words[i+2];
humanNames.addValue(s);
i += 2;
continue;
}
// 2 word names:
if (isPlaceName(words, i, 2)) {
String s = words[i] + " " + words[i+1];
placeNames.addValue(s);
i += 1;
continue;
}
if (isHumanName(words, i, 2)) {
String s = words[i] + " " + words[i+1];
humanNames.addValue(s);
i += 1;
continue;
}
// 1 word names:
if (isPlaceName(words, i, 1)) {