Mercurial > hg > anteater
view src/Test.java @ 1:7a4341c9f2e5
checking permit numbers for similarity if no direct match
author | jdamerow |
---|---|
date | Fri, 05 Oct 2012 18:52:14 -0700 |
parents | 036535fcd179 |
children | 1c2b4f5e2c05 |
line wrap: on
line source
import java.net.URI; import javax.ws.rs.core.UriBuilder; import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.config.ClientConfig; import com.sun.jersey.api.client.config.DefaultClientConfig; public class Test { public static void main(String[] args) { ClientConfig config = new DefaultClientConfig(); Client client = Client.create(config); WebResource service = client.resource(getBaseURI2()); // Get XML String content = "We seek public review. Notice is hereby given that Paul E. Nachtigall, Ph.D., " + "Director, Marine Mammal Research Program, Hawaii Institute of Marine " + "Biology, University of Hawaii, P.O. Box 1106, Kailua, Hawaii 96734, " + "has been issued a permit to conduct scientific research on three captive " + "bottlenose dolphins (Tursiops truncatus) and one captive false killer whale " + "(Pseudorca crassidens) for scientific research at the University of Hawaii."; String text = "A. Endangered Species. Applicant: 777 Ranch, Inc. Hondo TX; PRT-013008. The applicant requests renewal of their permit authorizing interstate and foreign commerce, export and cull of excess male barasingha (Cervus duvauceli), Eld's deer (Cervus eldi), Arabian oryx and red lechwe (Kobus leche) from their captive herd for the purpose of enhancement of the survival of the species. This notification covers activities conducted by the applicant over a 5-year period. Applicant: Lincoln Park Zoological Gardens, Chicago, IL; PRT-090113</HD>"; // MultivaluedMap<String, String> values = new MultivaluedMapImpl(); // values.add("documentContent", content); // values.add("documentType", "text/plain"); // values.add("appid", // "nV7rNc_V34F5EjG5VjBaFxIxpwxemBhUa0h4N2To8CnfjVBBmLrTVOgaCsXXU7EP"); // MultivaluedMap<String, String> values = new MultivaluedMapImpl(); // values.add("text", content); // // String result = // service.accept(MediaType.TEXT_XML).post(String.class, values); // String result = service.accept(MediaType.TEXT_XML).get(String.class); // // System.out.println(result); // test ner // String serializedClassifier = "classifiers/english.all.3class.distsim.crf.ser.gz"; // // // AbstractSequenceClassifier<CoreLabel> classifier = CRFClassifier // .getClassifierNoExceptions(serializedClassifier); // // String text = "Notice is hereby given that <PERSON>Paul E. Nachtigall Paul Szelag</PERSON>, Ph.D., Director, <ORGANIZATION>Marine Mammal Research Program</ORGANIZATION>, <ORGANIZATION>Hawaii Institute of Marine Biology</ORGANIZATION>, University of <LOCATION>Hawaii</LOCATION>, P.O. Box 1106, <LOCATION>Kailua</LOCATION>, <LOCATION>Hawaii</LOCATION> 96734, has been issued a permit to conduct scientific research on three captive bottlenose dolphins (Tursiops truncatus) and one captive false killer whale (Pseudorca crassidens) for scientific research at the <ORGANIZATION>University of Hawaii</ORGANIZATION>."; // //classifier.classifyWithInlineXML(content); // System.out.println(text); // Pattern pattern = Pattern.compile("\\<[A-Z]+\\>.+?\\</[A-Z]+\\>"); // Matcher matcher = pattern.matcher(text); // while (matcher.find()) { // System.out.print("Start index: " + matcher.start()); // System.out.print(" End index: " + matcher.end() + " "); // System.out.println(matcher.group()); // } // // StanfordNLPTextParser p = new StanfordNLPTextParser(); // p.getSubjects(content); // for (int i = 0; i < 5; i++) { // System.out.println(i); // try { // Thread.sleep(1000); // } catch (InterruptedException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // } // String xml = "<hallo><a>xxx</a><a><b>2</b>abc</a><c/></hallo>"; // // JDOMParser p = new JDOMParser(xml, false); // System.out.println(p.executeXPath("/hallo/a/b[text()=2]")); } private static URI getBaseURI2() { return UriBuilder.fromUri("http://wherein.yahooapis.com/").path("v1") .path("document").build(); } private static URI getBaseURI() { return UriBuilder.fromUri("http://gnrd.globalnames.org/") .path("name_finder.xml").build(); } private static URI getBaseURIToken() { return UriBuilder .fromUri( "http://gnrd.globalnames.org/name_finder.xml?token=Eo6PwCuWRl6owxBiHp1g2g") .build(); } }