Files
gf-core/src/runtime/java/Test.java
kr.angelov 03b067782c a partial support for def rules in the C runtime
The def rules are now compiled to byte code by the compiler and then to
native code by the JIT compiler in the runtime. Not all constructions
are implemented yet. The partial implementation is now in the repository
but it is not activated by default since this requires changes in the
PGF format. I will enable it only after it is complete.
2014-08-11 10:59:10 +00:00

36 lines
1.1 KiB
Java

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());
entry.getValue().addLiteral("PN", new NercLiteralCallback(gr,entry.getValue()));
}
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()+"\"");
}
}
}