diff --git a/doc/runtime-api.html b/doc/runtime-api.html index d6a46149e..374060403 100644 --- a/doc/runtime-api.html +++ b/doc/runtime-api.html @@ -396,6 +396,13 @@ a tree into a function name and a list of arguments: Prelude PGF2> unApp e Just ("AdjCN", [..., ...]) +
+ExprApplication app = e.unApp();
+System.out.println(app.getFunction());
+for (Expr arg : app.getArguments()) {
+ System.out.println(arg);
+}
+
@@ -420,6 +427,17 @@ For example the result from:
Prelude PGF2> readExpr "\"literal\"" >>= unStr
"literal"
+
+The result from unApp is not null if the expression
+is an application, and null in all other cases.
+Similarly, if the tree is a literal string then the return value
+from unStr will not be null with the actual literal.
+For example the output from:
+
+ In case of type error you will get an error:
+Expr e = Expr.readExpr("\"literal\"")
+System.out.println(e.unStr())
+
is just the string "literal".
Situations like this can be detected
in Python by checking the type of the result from unpack.
@@ -489,6 +507,14 @@ Prelude PGF2> print e2
DetCN (DetQuant IndefArt NumSg) (AdjCN (PositA red_A) (UseN theatre_N))
+
+using the constructor for Expr:
+
+Expr quant = Expr.readExpr("DetQuant IndefArt NumSg");
+Expr e2 = new Expr("DetCN", new Expr[] {quant, e});
+System.out.println(e2);
+
+
Embedded GF Grammars
@@ -653,8 +679,7 @@ AdjCN (PositA red_A) (UseN theatre_N)
Expr e = gr.checkExpr(e,Type.readType("CN"))
->>> System.out.println(e)
-AdjCN (PositA red_A) (UseN theatre_N)
+System.out.println(e)
@@ -668,7 +693,7 @@ Prelude PGF2> putStrLn msg
Expr e = gr.checkExpr(e,Type.readType("A"))
-pgf.TypeError: The expected type of the expression AdjCN (PositA red_A) (UseN theatre_N) is A but CN is infered
+TypeError: The expected type of the expression AdjCN (PositA red_A) (UseN theatre_N) is A but CN is infered
+System.out.println(gr.graphvizAbstractTree(e))
+graph {
+n0[label = "AdjCN", style = "solid", shape = "plaintext"]
+n1[label = "PositA", style = "solid", shape = "plaintext"]
+n2[label = "red_A", style = "solid", shape = "plaintext"]
+n1 -- n2 [style = "solid"]
+n0 -- n1 [style = "solid"]
+n3[label = "UseN", style = "solid", shape = "plaintext"]
+n4[label = "theatre_N", style = "solid", shape = "plaintext"]
+n3 -- n4 [style = "solid"]
+n0 -- n3 [style = "solid"]
+}
+
>>> print(eng.graphvizParseTree(e))
@@ -874,6 +913,43 @@ graph {
n0 -- n100000
n2 -- n100001
}
+
+
+System.out.println(eng.graphvizParseTree(e))
+graph {
+ node[shape=plaintext]
+
+ subgraph {rank=same;
+ n4[label="CN"]
+ }
+
+ subgraph {rank=same;
+ edge[style=invis]
+ n1[label="AP"]
+ n3[label="CN"]
+ n1 -- n3
+ }
+ n4 -- n1
+ n4 -- n3
+
+ subgraph {rank=same;
+ edge[style=invis]
+ n0[label="A"]
+ n2[label="N"]
+ n0 -- n2
+ }
+ n1 -- n0
+ n3 -- n2
+
+ subgraph {rank=same;
+ edge[style=invis]
+ n100000[label="red"]
+ n100001[label="theatre"]
+ n100000 -- n100001
+ }
+ n0 -- n100000
+ n2 -- n100001
+}