private Parse findFocusNounPhrase(String queryWord, int qwi, Parse[] toks) {
if (queryWord.equals("who")) {
int npStart = movePastCopula(qwi + 1, toks);
if (npStart > qwi + 1) { // check to ensure there is a copula
Parse np = getContainingNounPhrase(toks[npStart]);
if (np != null) {
return (np);
}
}
}
else if (queryWord.equals("what")) {
int npStart = movePastCopula(qwi + 1, toks);
Parse np = getContainingNounPhrase(toks[npStart]);
//removed copula case
if (np != null) {
Parse head = np.getHead();
if (falseHeadsPattern.matcher(head.toString()).matches()) {
npStart += np.getChildren().length;
int np2Start = movePastPrep(npStart, toks);
if (np2Start > npStart) {
Parse snp = getContainingNounPhrase(toks[np2Start]);
if (snp != null) {
return (snp);
}
}
}
return (np);
}
}
else if (queryWord.equals("which")) {
//check for false query words like which VBD
int npStart = movePastCopula(qwi + 1, toks);
if (npStart > qwi + 1) {
return (getContainingNounPhrase(toks[npStart]));
}
else {
npStart = movePastOf(qwi + 1, toks);
return (getContainingNounPhrase(toks[npStart]));
}
}
else if (queryWord.equals("how")) {
if (qwi + 1 < toks.length) {
return (getContainingNounPhrase(toks[qwi + 1]));
}
}
else if (qwi == 0 && queryWord.equals("name")) {
int npStart = qwi + 1;
Parse np = getContainingNounPhrase(toks[npStart]);
if (np != null) {
Parse head = np.getHead();
if (falseHeadsPattern.matcher(head.toString()).matches()) {
npStart += np.getChildren().length;
int np2Start = movePastPrep(npStart, toks);
if (np2Start > npStart) {
Parse snp = getContainingNounPhrase(toks[np2Start]);
if (snp != null) {
return (snp);
}
}
}