From 584d589041f63fdd3ea777019679275657902c2d Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Mon, 11 Aug 2014 10:59:10 +0000 Subject: 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. --- src/runtime/java/Test.java | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src/runtime/java/Test.java') diff --git a/src/runtime/java/Test.java b/src/runtime/java/Test.java index 7ac11d8a3..08d6445cb 100644 --- a/src/runtime/java/Test.java +++ b/src/runtime/java/Test.java @@ -3,10 +3,10 @@ import java.util.*; import org.grammaticalframework.pgf.*; public class Test { - public static void main(String[] args) { + public static void main(String[] args) throws IOException { PGF gr = null; try { - gr = PGF.readPGF("Phrasebook.pgf"); + gr = PGF.readPGF("/home/krasimir/www.grammaticalframework.org/examples/phrasebook/Phrasebook.pgf"); } catch (FileNotFoundException e) { e.printStackTrace(); return; @@ -14,28 +14,19 @@ public class Test { e.printStackTrace(); return; } - + + Type typ = gr.getFunctionType("Bulgarian"); + System.out.println(typ.getCategory()); System.out.println(gr.getAbstractName()); for (Map.Entry entry : gr.getLanguages().entrySet()) { System.out.println(entry.getKey()+" "+entry.getValue()+" "+entry.getValue().getName()); entry.getValue().addLiteral("PN", new NercLiteralCallback(gr,entry.getValue())); } - - int count = 10; - for (ExprProb ep : gr.generateAll("Phrase")) { - System.out.println(ep.getExpr()); - - if (count-- <= 0) - break; - } - - Concr eng = gr.getLanguages().get("PhrasebookEng"); - Concr ger = gr.getLanguages().get("PhrasebookGer"); + Concr eng = gr.getLanguages().get("SimpleEng"); try { - for (ExprProb ep : eng.parse(gr.getStartCat(), "where is the hotel")) { + for (ExprProb ep : eng.parse(gr.getStartCat(), "persons who work with Malmö")) { 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()+"\""); -- cgit v1.2.3