-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatternMatching.java
More file actions
45 lines (29 loc) · 946 Bytes
/
PatternMatching.java
File metadata and controls
45 lines (29 loc) · 946 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package gui;
import java.io.*;
import org.omg.CORBA.PUBLIC_MEMBER;
import edu.stanford.nlp.patterns.ConstantsAndVariables.PatternIndexWay;
import edu.stanford.nlp.trees.*;
import edu.stanford.nlp.trees.tregex.*;
public class PatternMatching {
public String output="";
public void PatternMatch()throws IOException {
ChooseFile cf = new ChooseFile();
String pattern="NP",sentence;
Parser parser=new Parser();
Tree tree=null;
TregexPattern p=TregexPattern.compile(pattern);
TregexMatcher m=null;
String PATH=cf.getPath();
System.out.println(PATH);
BufferedReader br=new BufferedReader(new FileReader(PATH));
int an=657583,dp=6877,ar=6568,at=6582,ka=7571;
while((sentence=br.readLine())!=null){
tree=parser.parse(sentence);
m=p.matcher(tree);
while(m.find()){
output+="\n"+m.getMatch().toString();
}
}
br.close();
}
}