Skip to content

Commit

Permalink
Merge branch 'master' of origin
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa authored and Stanford NLP committed Jun 11, 2014
1 parent 07355d5 commit b759bcd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions commonbuildjsp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
</fileset>
<pathelement location="${build.path}"/>
<pathelement location="${project.core}/lib/commons-logging.jar"/>
<pathelement location="${project.core}/lib/javax.servlet.jar"/>
</path>

<target name="jsp" depends="classpath,compile">
Expand Down
15 changes: 14 additions & 1 deletion src/edu/stanford/nlp/ie/machinereading/structure/Span.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,20 @@ public static Span fromValues(int val1, int val2) {
return new Span(val2, val1);
}
}


public static Span fromValues(Object... values) {
if (values.length != 2) { throw new IllegalArgumentException("fromValues() must take an array with 2 elements"); }
int val1;
if (values[0] instanceof Number) { val1 = ((Number) values[0]).intValue(); }
else if (values[0] instanceof String) { val1 = Integer.parseInt((String) values[0]); }
else { throw new IllegalArgumentException("Unknown value for span: " + values[0]); }
int val2;
if (values[1] instanceof Number) { val2 = ((Number) values[1]).intValue(); }
else if (values[0] instanceof String) { val2 = Integer.parseInt((String) values[1]); }
else { throw new IllegalArgumentException("Unknown value for span: " + values[1]); }
return fromValues(val1, val2);
}

public int start() { return start; }
public int end() { return end; }

Expand Down
11 changes: 11 additions & 0 deletions src/edu/stanford/nlp/util/Characters.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,15 @@ public static boolean isPunctuation(char c) {
cType == Character.INITIAL_QUOTE_PUNCTUATION ||
cType == Character.FINAL_QUOTE_PUNCTUATION);
}

/**
* Returns true if a character is a control character, and
* false otherwise.
*
* @param c
* @return
*/
public static boolean isControl(char c) {
return Character.getType(c) == Character.CONTROL;
}
}

0 comments on commit b759bcd

Please sign in to comment.