blob: 3c27e641bb60d9359c598c369d1bdec71d445ce3 (
plain)
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
|
import java.io.*;
import java.util.*;
import org.grammaticalframework.pgf.*;
public class Test {
public static void main(String[] args) throws IOException {
PGF gr = null;
try {
gr = PGF.readPGF("/home/krasimir/www.grammaticalframework.org/examples/phrasebook/Phrasebook.pgf");
} catch (FileNotFoundException e) {
e.printStackTrace();
return;
} catch (PGFError e) {
e.printStackTrace();
return;
}
Type typ = gr.getFunctionType("Bulgarian");
System.out.println(typ.getCategory());
System.out.println(gr.getAbstractName());
for (Map.Entry<String,Concr> entry : gr.getLanguages().entrySet()) {
System.out.println(entry.getKey()+" "+entry.getValue()+" "+entry.getValue().getName());
}
Concr eng = gr.getLanguages().get("SimpleEng");
try {
for (ExprProb ep : eng.parse(gr.getStartCat(), "persons who work with Malmö")) {
System.out.println("["+ep.getProb()+"] "+ep.getExpr());
}
} catch (ParseError e) {
System.out.println("Parsing failed at token \""+e.getToken()+"\"");
}
}
}
|