mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-10 05:29:30 -06:00
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.
This commit is contained in:
@@ -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<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()));
|
||||
}
|
||||
|
||||
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()+"\"");
|
||||
|
||||
Reference in New Issue
Block a user