Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fixed makefile and added "offsets" output format #2

Merged
merged 1 commit into from

2 participants

@seanlavelle

The makefile had a hardcoded path to servlet-api.jar in /opt/tomcat which is not where my tomcat lives. I committed the jar to the repo instead so it should work for anyone. The makefile also uses pushd and popd which made it fail on my system until I added "SHELL = /bin/bash"

I made it so you can set "outputFormat=offsets" in a post and it will output the results of the classifyToCharacterOffsets() method. This makes it tell you the positions in the document where it finds things, instead of adding markup to the text of the document.

I also made it wrap exceptions when rethrowing so the stacktraces contain as much info as possible (almost always a good idea).

@dat dat merged commit ca65e85 into dat:master
@dat
Owner

Thanks! I've merged your request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 16, 2012
  1. Fix makefile and add "offsets" output format

    seanlavelle authored
This page is out of date. Refresh to see the latest.
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));
Something went wrong with that request. Please try again.