Created
August 2, 2013 00:21
-
-
Save rclayton-the-terrible/6136559 to your computer and use it in GitHub Desktop.
Demonstrates that the text will be parsed without timing out (from a previous infinite loop introduced by the 'named-regex' library).
This file contains hidden or 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
package com.berico.clavin.resolver.integration; | |
import org.junit.Before; | |
import org.junit.Test; | |
import com.berico.clavin.GeoParser; | |
import com.berico.clavin.GeoParserFactory; | |
import com.berico.clavin.resolver.ResolutionContext; | |
public class BugFixesIT { | |
GeoParser geoParser; | |
@Before | |
public void setup() throws Exception { | |
geoParser = GeoParserFactory.getDefault("./IndexDirectory"); | |
} | |
public static final String DG_EXAMPLE_TEXT = "271147350322998 LONDON: Oil prices slid " + | |
"for a second day running Tuesday as weaker-than-expected Chinese economic " + | |
"growth data sparked concern over a slowdown in demand from the world?s top " + | |
"consumer of energy. Sentiment took another hit after ratings agency Moody?s " + | |
"warned that France?s top-level credit rating could be put on negative " + | |
"outlook, sparking new concern over the eurozone debt crisis ahead of a key " + | |
"EU summit this weekend. New York?s main contract, light sweet crude for " + | |
"delivery in November, shed 44 cents to $85.94 a barrel. Brent North Sea " + | |
"crude for delivery in December fell 84 cents to $109.32 a barrel in London " + | |
"midday trade. China announced on Tuesday that its economic growth slowed to " + | |
"9.1 percent in the third quarter as government efforts to tame inflation and " + | |
"turbulence in Europe and the US curbed activity. Growth in the world?s " + | |
"second-largest economy slowed from 9.5 percent in the second quarter to its " + | |
"lowest rate in two years, the National Bureau of Statistics (NBS) revealed. " + | |
"China?s economic growth has a direct impact on crude prices and demand, as " + | |
"it is the world?s largest energy consumer according to the International " + | |
"Energy Agency. Crude futures had sunk on Monday after the weekend Group of " + | |
"20 meeting in Paris failed to solidify market confidence in the global " + | |
"growth picture and Europe?s financial soundness. afp"; | |
@Test(timeout=1000) | |
public void dg_example_does_not_stall_and_resolves_locations() throws Exception { | |
ResolutionContext context = geoParser.parse(DG_EXAMPLE_TEXT); | |
System.out.println( | |
String.format( | |
"Extracted %s locations, and resolved %s.\n" + | |
"Extracted %s coordinates, and resolved %s.", | |
context.getExtractionContext().getLocations().size(), | |
context.getLocations().size(), | |
context.getExtractionContext().getCoordinates().size(), | |
context.getCoordinates().size())); | |
System.out.println(context.getLocations()); | |
} | |
} |
This file contains hidden or 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
17:19:13.472 [Thread-1] INFO com.berico.clavin.GeoParser - Input Size: 1353 | |
17:19:13.571 [Thread-1] INFO com.berico.clavin.GeoParser - Extracted Location Count: 6 | |
17:19:13.585 [Thread-1] INFO com.berico.clavin.GeoParser - Extracted Coordinates Count: 0 | |
17:19:13.586 [Thread-1] DEBUG c.b.c.r.impl.DefaultLocationResolver - Beginning resolution step. | |
17:19:14.086 [Thread-1] DEBUG c.b.c.r.impl.DefaultLocationResolver - Found 6 location candidate lists. | |
17:19:14.086 [Thread-1] DEBUG c.b.c.r.impl.DefaultLocationResolver - Found 0 coordinate candidate lists. | |
17:19:14.086 [Thread-1] DEBUG c.b.c.r.impl.DefaultLocationResolver - Selected 0 coordinates. | |
17:19:14.091 [Thread-1] DEBUG c.b.c.r.impl.DefaultLocationResolver - Selected 6 locations. | |
17:19:14.091 [Thread-1] INFO com.berico.clavin.GeoParser - Resolved 6 locations and 0 coordinates. | |
Extracted 6 locations, and resolved 6. | |
Extracted 0 coordinates, and resolved 0. | |
[Resolved "France" as"France" { Place [name: France, country: CI, center: 5.20375, -3.73905]}, position: 278, confidence: 0.0, fuzzy: false, Resolved "North Sea" as"North Sea Canal" { Place [name: Noordzeekanaal, country: NL, center: 52.46667, 4.61667]}, position: 545, confidence: 6.0, fuzzy: false, Resolved "London" as"London" { Place [name: London, country: FR, center: 48.8715, 2.337]}, position: 623, confidence: 0.0, fuzzy: false, Resolved "Europe" as"HOTEL EUROPE" { Place [name: Hotel Europe, country: FR, center: 48.9027, 2.3135]}, position: 797, confidence: 6.0, fuzzy: false, Resolved "Paris" as"Paris" { Place [name: Paris, country: FR, center: 48.86, 2.34444]}, position: 1244, confidence: 0.0, fuzzy: false, Resolved "Europe" as"HOTEL EUROPE" { Place [name: Hotel Europe, country: FR, center: 48.9027, 2.3135]}, position: 1320, confidence: 6.0, fuzzy: false] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment