private static void getparseArticle ( ) throws Exception { // Instantiate a CLAVIN GeoParser using the StanfordExtractor GeoParser parser = GeoParserFactory . getDefault ( "./IndexDirectory" , new StanfordExtractor ( ) , 1 , 1 , false ) ; // Unstructured text file about Somalia to be geoparsed File inputFile = new File ( "src/test/resources/sample-docs/Somalia-doc.txt" ) ; // Grab the contents of the text file as a String String inputString = TextUtils . fileToString ( inputFile ) ; // Parse location names in the text into geographic entities List < ResolvedLocation > resolvedLocations = parser . parse ( inputString ) ; // Display the ResolvedLocations found for the location names for ( ResolvedLocation resolvedLocation : resolvedLocations ) System . out . println ( resolvedLocation ) ; }
Standard usage of CLAVIN . Instantiate a default GeoParser give it some text check out the locations it extracts and resolves .