Posted By:
Nikos_Papadakis
Posted On:
Thursday, April 4, 2002 03:31 AM
I am using the ORO project in order to extract information from a document, but some times the code seems to block near the if statement. The code is listed below: public static final void main(String args[]) { String lastThing; String kena, keyq, b, b11, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10; int groups; PatternMatcher matcher; PatternCompiler compiler; Pattern pattern = null; PatternMatcherInput input; MatchResult result; compiler = new Perl5Compiler(); matcher = new Perl5Matcher(); try { k
More>>
I am using the ORO project in order to extract information from a document, but some times the code seems to block near the if statement. The code is listed below:
public static final void main(String args[]) {
String lastThing;
String kena, keyq, b, b11, b1, b2, b3, b4, b5, b6, b7, b8, b9, b10;
int groups;
PatternMatcher matcher;
PatternCompiler compiler;
Pattern pattern = null;
PatternMatcherInput input;
MatchResult result;
compiler = new Perl5Compiler();
matcher = new Perl5Matcher();
try {
kena = "\s+";
b1 = "(.[^\r]+)\s+";
b11 = ".[^\r]+\s+";
b3 = "(.[^\|]+)\|";
b4 = "(\s*\d+\-\d+\-\d+\-\d+)";
b5 = "(\s*ABOUT THIS BOOK\s*)"; //let it out
b6 = "(\w[^@]+)More Titles By This Author";
b = kena + b11 + b1 + kena + b1 + kena + b3 + b3 + b3 + b3 + b3 + b4 + b5 + b6;
pattern = compiler.compile(b);
System.out.println("pattern insered ");
} catch (MalformedPatternException e) {
System.err.println("Bad pattern.");
System.err.println(e.getMessage());
return;
}
input = new PatternMatcherInput(readFile() + keyq);
if (matcher.contains(input, pattern)) {
result = matcher.getMatch();
System.out.println("--------------- results here------------");
groups = result.groups();
for (int group = 1; group
< groups; group++) {
System.out.println(group + ": " + result.group(group));
}
}
}
<<Less