Permalink
Browse files

Merge pull request #2 from seanlavelle/master

Fixed makefile and added "offsets" output format
  • Loading branch information...
2 parents f0b7119 + c20f03c commit ca65e85db0007659c8b5348b076b119230a8405e @dat committed Jan 18, 2013
Showing with 13 additions and 7 deletions.
  1. +3 −1 Makefile
  2. +1 −0 extra/index.html
  3. BIN extra/servlet-api.jar
  4. +9 −6 src/com/ntrepid/tartan/NERServlet.java
View
4 Makefile
@@ -8,7 +8,9 @@ JAVAC = javac
JAVAFLAGS = -O
JAVADOC = javadoc
-SERVLET_API = /opt/tomcat/common/lib/servlet-api.jar
+SERVLET_API = extra/servlet-api.jar
+
+SHELL = /bin/bash
all: war
View
1 extra/index.html
@@ -27,6 +27,7 @@
<option value="inlineXML">inlineXML</option>
<option value="xml">xml</option>
<option value="slashTags">slashTags</option>
+ <option value="offsets">offsets</option>
</select>
</td></tr>
<tr><td>
View
BIN extra/servlet-api.jar
Binary file not shown.
View
15 src/com/ntrepid/tartan/NERServlet.java
@@ -63,11 +63,11 @@ public void init() throws ServletException {
}
asc = CRFClassifier.getClassifier(is);
} catch (IOException e) {
- throw new ServletException("IO problem reading classifier.");
+ throw new ServletException("IO problem reading classifier.", e);
} catch (ClassCastException e) {
- throw new ServletException("Classifier class casting problem.");
+ throw new ServletException("Classifier class casting problem.", e);
} catch (ClassNotFoundException e) {
- throw new ServletException("Clasifier class not found problem.");
+ throw new ServletException("Classifier class not found problem.", e);
} finally {
try {
is.close();
@@ -114,9 +114,12 @@ public void doPost(HttpServletRequest req, HttpServletResponse res)
res.addHeader("preserveSpacing", String.valueOf(preserveSpacing));
PrintWriter out = res.getWriter();
- //entire blob of text
- out.print(ners.get(classifier).classifyToString(input, outputFormat, preserveSpacing));
-
+ if(outputFormat.equals("offsets")) {
+ out.print(ners.get(classifier).classifyToCharacterOffsets(input));
+ } else {
+ //entire blob of text
+ out.print(ners.get(classifier).classifyToString(input, outputFormat, preserveSpacing));
+ }
//sentence-by-sentence
/*for (String sentence: input.split("\n")) {
out.println(tagger.classifyToString(sentence, outputFormat, preserveSpacing));

0 comments on commit ca65e85

Please sign in to comment.