Skip to content

Instantly share code, notes, and snippets.

@epiicme epiicme/Main.java
Created Apr 8, 2018

Embed
What would you like to do?
Copenhacks2018JavaServer
package com.copenhacks2018;
import static com.copenhacks2018.GetSentiment.prettify;
import java.io.IOException;
import java.net.InetSocketAddress;
import com.sun.net.httpserver.HttpServer;
import twitter4j.*;
public class Main {
public static void main(String[] args) throws TwitterException, IOException {
try {
HttpServer server = HttpServer.create(new InetSocketAddress(8080), 0);
server.createContext("/test", new MyHandler());
server.setExecutor(null);
server.start();
} catch (IOException e) {
System.out.println("Server error!");
}
try {
Documents documents = new Documents();
documents.add("1", "en", "I really enjoy the new XBox One S. It has a clean look, it has 4K/HDR resolution and it is affordable.");
documents.add("2", "es", "Este ha sido un dia terrible, llegué tarde al trabajo debido a un accidente automobilistico.");
String response = GetSentiment.GetSentiment(documents);
System.out.println(prettify(response));
} catch (Exception e) {
System.out.println(e);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.