| 1 |
using LinkGrammar; |
| 2 |
|
| 3 |
namespace Examples { |
| 4 |
public class HelloLinkGrammar { |
| 5 |
public static int main (string[] args) { |
| 6 |
print ("# Link Grammar Sample\n"); |
| 7 |
string[] input_strings = { |
| 8 |
"He eats cake.", |
| 9 |
"He eat cake.", |
| 10 |
"The side affects were devastating.", |
| 11 |
"The side effects were devastating." |
| 12 |
}; |
| 13 |
|
| 14 |
var opts = new ParseOptions (); |
| 15 |
var dict = new Dictionary ("en"); |
| 16 |
|
| 17 |
// Allow for null links. |
| 18 |
opts.set_max_null_count (10); |
| 19 |
|
| 20 |
if (dict == null) { |
| 21 |
warning ("Could not load dictionary"); |
| 22 |
return 1; |
| 23 |
} |
| 24 |
|
| 25 |
for (int i = 0; i < input_strings.length; i++) { |
| 26 |
var sentence = new Sentence (input_strings[i], dict); |
| 27 |
sentence.split (opts); |
| 28 |
var num_linkages = sentence.parse (opts); |
| 29 |
if (num_linkages > 0) { |
| 30 |
var linkage = new Linkage (0, sentence, opts); |
| 31 |
var diagram = linkage.print_diagram (true, 800); |
| 32 |
print ("%s\n", diagram); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
return 0; |
| 37 |
} |
| 38 |
} |
| 39 |
} |