Java Reference
In-Depth Information
if (end.equalsIgnoreCase("present")) {
end = start;
}
list.add(new President(name,
Integer.parseInt(start),
Integer.parseInt(end)));
}
} catch (IOException ex) {
// Handle exceptions
}
return list;
}
A President class holds presidential information, as shown here. The getter methods
have been left out:
public class President {
private String name;
private int start;
private int end;
public President(String name, int start, int end) {
this.name = name;
this.start = start;
this.end = end;
}
...
}
The processWhoQuestion method follows. We use type dependencies again to ex-
tract the ordinal value of the question. If the governor is president and the ad-
jectival modifier is the relation, then the dependent word is the ordinal. This
string is passed to the getOrder method, which returns the ordinal as an integer. We add
1 to it since the list of presidents also started at one:
public void processWhoQuestion(List<TypedDependency> tdl) {
List<President> list = createPresidentList();
for (TypedDependency dependency : tdl) {
if ("president".equalsIgnoreCase(
Search WWH ::




Custom Search