Minor Corrrection
This commit is contained in:
parent
450b6fa153
commit
b25b133242
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="15" project-jdk-type="JavaSDK" />
|
||||
</project>
|
|
@ -277,6 +277,17 @@ public class StanfordCoreNLPServer implements Runnable {
|
|||
// TODO(AngledLuffa): this must be a constant somewhere, but I couldn't find it
|
||||
static final String URL_ENCODED = "application/x-www-form-urlencoded";
|
||||
|
||||
public static String replacer(String data) {
|
||||
try {
|
||||
data = data.replaceAll("%(?![0-9a-fA-F]{2})", "%25");
|
||||
data = data.replaceAll("\\+", "%2B");
|
||||
data = URLDecoder.decode(data, "utf-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the POST contents of the request and parses it into an Annotation object, ready to be annotated.
|
||||
* This method can also read a serialized document, if the input format is set to be serialized.
|
||||
|
@ -327,7 +338,7 @@ public class StanfordCoreNLPServer implements Runnable {
|
|||
|
||||
String text = IOUtils.slurpReader(IOUtils.encodedInputStreamReader(httpExchange.getRequestBody(), encoding));
|
||||
if (contentType.equals(URL_ENCODED)) {
|
||||
text = URLDecoder.decode(text, encoding);
|
||||
text = URLDecoder.decode(replacer(text), encoding);
|
||||
}
|
||||
// We use to trim. But now we don't. It seems like doing that is illegitimate. text = text.trim();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package edu.stanford.nlp.time;
|
|||
import java.io.Serializable;
|
||||
import java.util.Calendar;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
import java.uTIMtil.regex.Pattern;
|
||||
|
||||
import edu.stanford.nlp.util.Pair;
|
||||
import org.w3c.dom.Element;
|
||||
|
|
Loading…
Reference in New Issue