Skip to content

Commit 55a0072

Browse files
manningStanford NLP
authored and
Stanford NLP
committed
Merge remote-tracking branch 'origin/master'
1 parent 80260fb commit 55a0072

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

commonbuildjsp.xml

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
</fileset>
1010
<pathelement location="${build.path}"/>
1111
<pathelement location="${project.core}/lib/commons-logging.jar"/>
12+
<pathelement location="${project.core}/lib/javax.servlet.jar"/>
1213
</path>
1314

1415
<target name="jsp" depends="classpath,compile">

src/edu/stanford/nlp/ie/machinereading/structure/Span.java

+17-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,23 @@ public static Span fromValues(int val1, int val2) {
5353
return new Span(val2, val1);
5454
}
5555
}
56-
56+
57+
public static Span fromValues(Object... values) {
58+
if (values.length == 1) {
59+
return fromValues(values[0], values[0] instanceof Number ? ((Number) values[0]).intValue() + 1 : Integer.parseInt(values[0].toString()) + 1);
60+
}
61+
if (values.length != 2) { throw new IllegalArgumentException("fromValues() must take an array with 2 elements"); }
62+
int val1;
63+
if (values[0] instanceof Number) { val1 = ((Number) values[0]).intValue(); }
64+
else if (values[0] instanceof String) { val1 = Integer.parseInt((String) values[0]); }
65+
else { throw new IllegalArgumentException("Unknown value for span: " + values[0]); }
66+
int val2;
67+
if (values[1] instanceof Number) { val2 = ((Number) values[1]).intValue(); }
68+
else if (values[0] instanceof String) { val2 = Integer.parseInt((String) values[1]); }
69+
else { throw new IllegalArgumentException("Unknown value for span: " + values[1]); }
70+
return fromValues(val1, val2);
71+
}
72+
5773
public int start() { return start; }
5874
public int end() { return end; }
5975

src/edu/stanford/nlp/trees/EnglishGrammaticalRelations.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,8 @@ public static class NounCompoundModifierGRAnnotation extends GrammaticalRelation
10371037
// which is the normal case for such a pattern.
10381038
"WHNP|WHNP-TMP|WHNP-ADV|NP|NP-TMP|NP-ADV < (NP=target !<: CD $- /^,$/ $-- /^(?:WH)?NP/ !$ CC|CONJP)",
10391039
"WHNP|WHNP-TMP|WHNP-ADV|NP|NP-TMP|NP-ADV < (PRN=target < (NP < /^(?:NN|CD)/ $-- /^-LRB-$/ $+ /^-RRB-$/))",
1040-
// Maybe delete '@' in next pattern, since not clearly appositional when NP-ADV or NP-TMP. But then what is it?
1041-
"@WHNP|NP < (@NP=target !<: CD <, /^-LRB-$/ <` /^-RRB-$/ $-- /^(?:WH)?NP/ !$ CC|CONJP)",
1040+
// NP-ADV is a npadvmod, NP-TMP is a tmod
1041+
"@WHNP|NP < (NP=target !<: CD <, /^-LRB-$/ <` /^-RRB-$/ $-- /^(?:WH)?NP/ !$ CC|CONJP)",
10421042
// TODO: next pattern with NNP doesn't work because leftmost NNP is deemed head in a
10431043
// structure like (NP (NNP Norway) (, ,) (NNP Verdens_Gang) (, ,))
10441044
"NP|NP-TMP|NP-ADV < (NNP $+ (/^,$/ $+ NNP=target)) !< CC|CONJP",

src/edu/stanford/nlp/util/Characters.java

+11
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,15 @@ public static boolean isPunctuation(char c) {
6363
cType == Character.INITIAL_QUOTE_PUNCTUATION ||
6464
cType == Character.FINAL_QUOTE_PUNCTUATION);
6565
}
66+
67+
/**
68+
* Returns true if a character is a control character, and
69+
* false otherwise.
70+
*
71+
* @param c
72+
* @return
73+
*/
74+
public static boolean isControl(char c) {
75+
return Character.getType(c) == Character.CONTROL;
76+
}
6677
}

0 commit comments

Comments
 (0)