blob: 15a8ff7fff9a7472f4393d0408092ba08147ca15 (
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
35
|
import java.io.*;
import java.util.*;
import org.grammaticalframework.pgf.*;
public class Test {
public static void main(String[] args) {
PGF gr = null;
try {
gr = PGF.readPGF("Phrasebook.pgf");
} catch (FileNotFoundException e) {
e.printStackTrace();
return;
} catch (PGFError e) {
e.printStackTrace();
return;
}
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("PhrasebookEng");
Concr ger = gr.getLanguages().get("PhrasebookGer");
try {
for (ExprProb ep : eng.parse(gr.getStartCat(), "where is the conference")) {
System.out.println("["+ep.getProb()+"] "+ep.getExpr());
System.out.println(ger.linearize(ep.getExpr()));
}
} catch (ParseError e) {
System.out.println("Parsing failed at token \""+e.getToken()+"\"");
}
}
}
|