-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eugen Ruppert
committed
Feb 20, 2017
1 parent
a59568d
commit f05f861
Showing
11 changed files
with
442 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
# ba-service-frontend | ||
# ba-service-frontend | ||
|
||
This project contains a web service based on the Spring Boot framework. | ||
It features a RESTful endpoint that can retrieve word expansions. | ||
|
||
- Check out and run the ApplicationController | ||
- default port is 8080 | ||
- for deployment, port can be edited in /resources/application.properties | ||
- check with "curl localhost:8080/expansions?word=IBM&format=json" | ||
- for textual output: "curl localhost:8080/expansions&format=text" |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" class=" is-copy-enabled"> | ||
<head> | ||
<meta charset='utf-8'> | ||
</head> | ||
|
||
<body> | ||
<form action="http:https://localhost:8080/expansions" method="get"> | ||
Input text: <textarea rows="5" cols="80" name="word"> | ||
IBM | ||
</textarea> | ||
<br /> | ||
<select name="format"> | ||
<option value="text">Text</option> | ||
<option value="json">JSON</option> | ||
</select><input type="submit" value="Analyse"> | ||
</form> | ||
|
||
</body> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http:https://maven.apache.org/POM/4.0.0" xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>uhh_lt</groupId> | ||
<artifactId>wsd.server</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
|
||
<name>Basic Webserver</name> | ||
<description>Basic bootstrap webserver with REST support</description> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.3.3.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.8</java.version> | ||
<dkpro.core.version>1.6.2</dkpro.core.version> | ||
</properties> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-devtools</artifactId> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>org.apache.uima</groupId> | ||
<artifactId>uimafit-core</artifactId> | ||
<version>2.2.0</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>de.tudarmstadt.ukp.dkpro.core</groupId> | ||
<artifactId>de.tudarmstadt.ukp.dkpro.core.opennlp-asl</artifactId> | ||
<version>${dkpro.core.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>de.tudarmstadt.ukp.dkpro.core</groupId> | ||
<artifactId>de.tudarmstadt.ukp.dkpro.core.tokit-asl</artifactId> | ||
<version>${dkpro.core.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>de.tudarmstadt.ukp.dkpro.core</groupId> | ||
<artifactId>de.tudarmstadt.ukp.dkpro.core.io.text-asl</artifactId> | ||
<version>${dkpro.core.version}</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>de.tudarmstadt.ukp.dkpro.core</groupId> | ||
<artifactId>de.tudarmstadt.ukp.dkpro.core.api.segmentation-asl</artifactId> | ||
<version>${dkpro.core.version}</version> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>de.tudarmstadt.ukp.dkpro.core</groupId> | ||
<artifactId>de.tudarmstadt.ukp.dkpro.core.clearnlp-asl</artifactId> | ||
<version>${dkpro.core.version}</version> | ||
</dependency> | ||
|
||
|
||
<dependency> | ||
<groupId>net.sf.json-lib</groupId> | ||
<artifactId>json-lib-ext-spring</artifactId> | ||
<version>1.0.2</version> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>servlet-api</artifactId> | ||
<groupId>javax.servlet</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.apache.pig</groupId> | ||
<artifactId>pig</artifactId> | ||
<version>0.16.0</version> | ||
<exclusions> | ||
<exclusion> | ||
<artifactId>org.mortbay.jetty</artifactId> | ||
<groupId>servlet-api</groupId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.ibm.watson.developer_cloud</groupId> | ||
<artifactId>java-sdk</artifactId> | ||
<version>3.5.3</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.jobimtext</groupId> | ||
<artifactId>jobimtext</artifactId> | ||
<version>0.1.3</version> | ||
<scope>system</scope> | ||
<systemPath>${project.build.directory}/../lib/org.jobimtext-0.1.3.jar</systemPath> | ||
</dependency> | ||
|
||
|
||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>tudarmstadt.lt.wsd.server.ApplicationController</mainClass> | ||
</manifest> | ||
</archive> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
server.port=8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<webThesaurusConfiguration> | ||
<protocol>http</protocol> | ||
<server>ltmaggie.informatik.uni-hamburg.de</server> | ||
<port>80</port> | ||
<path>/jobimviz/</path> | ||
<dataset>germanTrigram</dataset> | ||
</webThesaurusConfiguration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package uhh_lt.webserver; | ||
|
||
import net.sf.json.JSONArray; | ||
import net.sf.json.JSONObject; | ||
import org.jobimtext.api.struct.Order2; | ||
import org.jobimtext.api.struct.WebThesaurusDatastructure; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@EnableAutoConfiguration | ||
public class ApplicationController { | ||
|
||
|
||
private static WebThesaurusDatastructure dt; | ||
|
||
|
||
@RequestMapping("/expansions") | ||
String home(@RequestParam(value = "word", defaultValue = "") String word, @RequestParam(value = "format", defaultValue = "text") String format) { | ||
|
||
word = word.replace("\r", " ").replace("\n", " ").trim(); | ||
format = format.replace("\r", " ").replace("\n", " ").trim(); | ||
|
||
if (format.compareTo("json") == 0) { | ||
return generateJSONResponse(word); | ||
} else { | ||
return generateTextResponse(word); | ||
} | ||
} | ||
|
||
private String generateJSONResponse(String input) { | ||
JSONObject out = new JSONObject(); | ||
out.put("input", input); | ||
|
||
JSONArray expansions = new JSONArray(); | ||
for (Order2 exp : dt.getSimilarTerms(input)) { | ||
expansions.add(exp.key); | ||
} | ||
out.put("expansions", expansions); | ||
|
||
return out.toString(); | ||
} | ||
|
||
private String generateTextResponse(String input) { | ||
StringBuilder output = new StringBuilder(); | ||
|
||
output.append("input: " + input); | ||
output.append("\nexpansions:"); | ||
for (Order2 exp : dt.getSimilarTerms(input)) { | ||
output.append("\n - " + exp.key); | ||
} | ||
return output.toString(); | ||
} | ||
|
||
/** | ||
* Runs the RESTful server. | ||
* | ||
* @param args execution arguments | ||
*/ | ||
public static void main(String[] args) { | ||
dt = new WebThesaurusDatastructure("resources/conf_web_deNews_trigram.xml"); | ||
dt.connect(); | ||
SpringApplication.run(ApplicationController.class, args); | ||
} | ||
|
||
} |