From 8a50d851c330b5686f4d44cb0f94af1506fcf767 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Wed, 30 Aug 2017 09:09:45 +0200 Subject: [PATCH] Updated C# documentation --- doc/runtime-api.html | 52 +++++++++++++++++++++----------------- src/runtime/dotNet/Expr.cs | 2 +- src/runtime/dotNet/Type.cs | 2 +- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/doc/runtime-api.html b/doc/runtime-api.html index b0fc24b91..6c22f39f5 100644 --- a/doc/runtime-api.html +++ b/doc/runtime-api.html @@ -56,7 +56,7 @@ Choose a language: Haskell Python Java C# -

Krasimir Angelov, July 2015

+

Krasimir Angelov, July 2015 - August 2017

Loading the Grammar

@@ -140,7 +140,7 @@ Prelude PGF2> let res = parse eng (startCat gr) "this is a small theatre" Iterable<ExprProb> iterable = eng.parse(gr.getStartCat(), "this is a small theatre");
-IEnumerable<Tuple<Expr, float>> enumerable = eng.Parse(gr.StartCat, "this is a small theatre");
+IEnumerable<Tuple<Expr, float>> enumerable = eng.Parse("this is a small theatre");
 
This gives you an iterator which can enumerate all possible @@ -174,8 +174,9 @@ ExprProb ep = iter.next(); This gives you an enumerable which can enumerate all possible abstract trees. You can get the next tree by calling MoveNext:
-enumerable.MoveNext();
-Tuple<Expr, float> ep = enumerable.Current;
+IEnumerator<Tuple<Expr, float>> enumerator = enumerable.GetEnumerator();
+enumerator.MoveNext();
+Tuple<Expr, float> ep = enumerator.Current;
 
@@ -261,11 +262,16 @@ Iterable<ExprProb> iterable = eng.parseWithHeuristics(gr.startCat(), heuri -There is also the method ParseWithHeuristics which -takes two more paramaters which let you to have a better control -over the parser's behaviour: +The Parse method has also the following optional parameters: + + + +
catstart category
heuristicsa real number from 0 to 1
+ +

By using these parameters it is possible for instance to change the start category for +the parser. For example parsing with a different start category can be done as follows:

-IEnumerable<Tuple<Expr, float>> enumerable = eng.ParseWithHeuristics(gr.StartCat, heuristic_factor, callbacks);
+IEnumerable<Tuple<Expr, float>> enumerable = eng.Parse("this is a small theatre", cat: Type.ReadType("NP"));
 
@@ -343,7 +349,7 @@ red theatre red theater
-for (String s : eng.LinearizeAll(e)) {
+foreach (String s in eng.LinearizeAll(e)) {
     Console.WriteLine(s);
 }
 red theatre
@@ -369,7 +375,7 @@ s Pl Gen: red theatres'
 s Sg Gen: red theatre's
 
-for (Map.Entry<String,String> entry : eng.TabularLinearize(e).EntrySet()) {
+foreach (Map.Entry<String,String> entry in eng.TabularLinearize(e).EntrySet()) {  //// TODO
     Console.WriteLine(entry.Key + ": " + entry.Value);
 }
 s Sg Nom: red theatre
@@ -395,7 +401,7 @@ Prelude PGF2> putStrLn (showBracketedString b)
 Object[] bs = eng.bracketedLinearize(e);
 
-Object[] bs = eng.BracketedLinearize(e);
+Bracket b = eng.BracketedLinearize(e);
 
Each element in the sequence above is either a string or an object @@ -469,7 +475,7 @@ System.out.println(eng.hasLinearization("apple_N")); true
-Console.WriteLine(eng.HasLinearization("apple_N"));
+Console.WriteLine(eng.HasLinearization("apple_N"));  //// TODO
 true
 
@@ -497,7 +503,7 @@ for (Expr arg : app.getArguments()) {
 ExprApplication app = e.UnApp();
 System.out.println(app.Function);
-for (Expr arg : app.Arguments) {
+foreach (Expr arg in app.Arguments) {
    Console.WriteLine(arg);
 }
 
@@ -782,8 +788,8 @@ for (FullFormEntry entry : eng.fullFormLexicon()) { }
-for (FullFormEntry entry in eng.FullFormLexicon) {
-	for (MorphoAnalysis analysis : entry.Analyses) {
+foreach (FullFormEntry entry in eng.FullFormLexicon) {     //// TODO
+	foreach (MorphoAnalysis analysis in entry.Analyses) {
 		Console.WriteLine(entry.Form+" "+analysis.Prob+" "+analysis.Lemma+" "+analysis.Field);
 	}
 }
@@ -806,7 +812,7 @@ letter_1_N, s Sg Nom, inf
 letter_2_N, s Sg Nom, inf
 
-for (MorphoAnalysis an : eng.LookupMorpho("letter")) {
+foreach (MorphoAnalysis an in eng.LookupMorpho("letter")) {   //// TODO
     Console.WriteLine(an.Lemma+", "+an.Field+", "+an.Prob);
 }
 letter_1_N, s Sg Nom, inf
@@ -830,7 +836,7 @@ List<String> funs = gr.getFunctions()
 ....
 
-IList<String> funs = gr.Functions;
+IEnumerable<String> funs = gr.Functions;
 ....
 
or a list of categories: @@ -847,7 +853,7 @@ List<String> cats = gr.getCategories(); ....
-IList<String> cats = gr.Categories;
+IEnumerable<String> cats = gr.Categories;
 ....
 
You can also access all functions with the same result category: @@ -864,7 +870,7 @@ List<String> funsByCat = gr.getFunctionsByCat("Weekday"); ....
-IList<String> funsByCat = gr.FunctionsByCat("Weekday");
+IList<String> funsByCat = gr.FunctionsByCat("Weekday");    //// TODO
 ....
 
The full type of a function can be retrieved as: @@ -906,7 +912,7 @@ System.out.println(te.getExpr()+" : "+te.getType()); AdjCN (PositA red_A) (UseN theatre_N) : CN
-TypedExpr te = gr.InferExpr(e);
+TypedExpr te = gr.InferExpr(e);                 //// TODO
 Console.WriteLine(te.Expr+" : "+te.Type);
 AdjCN (PositA red_A) (UseN theatre_N) : CN
 
@@ -933,7 +939,7 @@ Expr new_e = gr.checkExpr(e,Type.readType("CN")); System.out.println(e)
-Expr new_e = gr.CheckExpr(e,Type.ReadType("CN"));
+Expr new_e = gr.CheckExpr(e,Type.ReadType("CN"));            //// TODO
 Console.WriteLine(e)
 

In case of type error you will get an error: @@ -1095,7 +1101,7 @@ n0 -- n3 [style = "solid"] }

-Console.WriteLine(gr.GraphvizAbstractTree(e));
+Console.WriteLine(gr.GraphvizAbstractTree(e));       //// TODO
 graph {
 n0[label = "AdjCN", style = "solid", shape = "plaintext"]
 n1[label = "PositA", style = "solid", shape = "plaintext"]
@@ -1221,7 +1227,7 @@ graph {
 }
 
-Console.WriteLine(eng.GraphvizParseTree(e));
+Console.WriteLine(eng.GraphvizParseTree(e));          //// TODO
 graph {
   node[shape=plaintext]
 
diff --git a/src/runtime/dotNet/Expr.cs b/src/runtime/dotNet/Expr.cs
index b5ab0b764..dada28fc0 100644
--- a/src/runtime/dotNet/Expr.cs
+++ b/src/runtime/dotNet/Expr.cs
@@ -38,7 +38,7 @@ namespace PGFSharp
         /// 
         /// 
         /// 
-        public Expr ReadExpr(string exprStr)
+        public static Expr ReadExpr(string exprStr)
         {
             var tmp_pool = new NativeGU.NativeMemoryPool();
             var exn = new NativeGU.NativeExceptionContext(tmp_pool);
diff --git a/src/runtime/dotNet/Type.cs b/src/runtime/dotNet/Type.cs
index f9392bdf7..f60ab7cf1 100644
--- a/src/runtime/dotNet/Type.cs
+++ b/src/runtime/dotNet/Type.cs
@@ -35,7 +35,7 @@ namespace PGFSharp
         /// 
         /// 
         /// 
-        public Type ReadType(string typeStr)
+        public static Type ReadType(string typeStr)
         {
             var tmp_pool = new NativeGU.NativeMemoryPool();
             var exn = new NativeGU.NativeExceptionContext(tmp_pool);