With the following Java code, you can access the Connexor Machinese Phrase Tagger webservice.
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; public class Main { public static void main(String[] argv) throws Exception { String data = URLEncoder.encode("AuthKey", "UTF-8") + "=" + URLEncoder.encode("YourAuthenticationKey", "UTF-8"); data += "&" + URLEncoder.encode("text", "UTF-8") + "=" + URLEncoder.encode("This is a test", "UTF-8"); URL url = new URL("http://cxserv2.nlpengine.net/serv/tech/fdg1/en/"); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { System.out.println(line); } wr.close(); rd.close(); } }
Note: Please adjust the authentication key string to match the key assigned to you.