Libraryless. Click here for Pure Java version (7884L/53K).
1 | svoid test_RecursiveProbabilisticParser1() { |
2 | new RecursiveProbabilisticParser1 p; |
3 | p.requireQuotedProductions = false; |
4 | p.loadRules("<thing> has a <thing> => <sentence> => has($1, $2)"); |
5 | assertEqualsVerbose(ll([[has("the farmer", "pig")]]), |
6 | p.parse("the farmer has a pig")); |
7 | test_RecursiveProbabilisticParser1_2(); |
8 | } |
9 | |
10 | svoid test_RecursiveProbabilisticParser1_2() { |
11 | new RecursiveProbabilisticParser1 p; |
12 | p.loadRules([[ |
13 | "Ein/eine/der/die/das <ding> führt (nach/in/hin zu/ins) <ort>" => satz => $1 leads to $2 |
14 | "zimmer <zimmername>" => zimmer => room $1 |
15 | "der/die/dem/das/den <nomen>" => nomen => the $1 |
16 | ]]); |
17 | p.sentenceClass = "satz"; |
18 | p.useRoundBrackets = true; |
19 | assertEqualsVerbose(ll("(Haustür) leads to (the (room (Flur)))"), p.parse("Die Haustür führt in das Zimmer Flur")); |
20 | |
21 | test_RecursiveProbabilisticParser1_3(); |
22 | } |
23 | |
24 | svoid test_RecursiveProbabilisticParser1_3() { |
25 | new RecursiveProbabilisticParser1 p; |
26 | p.loadRules([[ |
27 | "vom/... <ort> kommt/gelangt man <füller> in/nach/... <ort>" => satz => $1 connects to $2 |
28 | "zimmer <zimmername>" => zimmer => room $1 |
29 | "der/die/dem/das/den <nomen>" => nomen => the $1 |
30 | ]]); |
31 | p.sentenceClass = "satz"; |
32 | p.useRoundBrackets = true; |
33 | assertEqualsVerbose(ll("(Flur) connects to (the (room (GästeWC)))"), p.parse("Vom Flur kommt man (auch) in das Zimmer GästeWC")); |
34 | |
35 | test_RecursiveProbabilisticParser1_4(); |
36 | } |
37 | |
38 | svoid test_RecursiveProbabilisticParser1_4() { |
39 | new RecursiveProbabilisticParser1 p; |
40 | p.loadRules([[ |
41 | "Ein/eine/der/die/das <ding> führt (nach/in/hin zu/ins) <ort>" => satz => $1 leads to $2 |
42 | "Ein/eine/der/die/das <ding> führt von/vom <ort> (nach/in/hin zu/ins) <ort>" => satz => $1 leads from $2 to $3 |
43 | "Ein/eine/der/die/das <ding> führt von/vom <ort> nach <ort> (in/hin zu/ins) <ort>" => satz => $1 leads from $2 to $3 to $4 |
44 | "der/die/dem/das/den <nomen>" => nomen => the $1 |
45 | "der/die/dem/das/den <nomen> des/der <nomen>" => nomen => $1 of $2 |
46 | "<ding> in/im <ort>" => ding => $1 in $2 |
47 | "erster/erste/ersten <nomen>" => nomen => first $1 |
48 | "zimmer <zimmername>" => zimmer => room $1 |
49 | zimmer => ort |
50 | ding => nomen |
51 | ort => nomen |
52 | bereich => ort |
53 | "auch <nomen>" => nomen => also $1 |
54 | "ein/eine/einen/einem <nomen>" => nomen => a $1 |
55 | "kein/keine/keinen/keinem <nomen>" => nomen => no $1 |
56 | "bereich <bereichsname>" => bereich => area $1 |
57 | "der/... <ding> zwischen <ort> und <ort>" => ding => the $1 between $2 and $3 |
58 | "<ding> geht <füller> nach <richtung> auf" => satz => $1 opens to the $2 |
59 | "<nomen> und <nomen>" => nomen => $1 and $2 |
60 | "vom/... <ort> kommt/gelangt man <füller> in/nach/... <ort>" => satz => $1 connects to $2 |
61 | "von da aus kommt/gelangt man <füller> in/nach/... <ort>" => satz => last mentioned place connects to $1 |
62 | "<nomen> hat <füller> <nomen>" => satz => $1 has $2 |
63 | "<nomen> hat <füller> einen Bereich <nomen>" => satz => $1 has an area $2 |
64 | ]]); |
65 | p.sentenceClass = "satz"; |
66 | p.useRoundBrackets = true; |
67 | assertEqualsVerbose(ll("(the (room (Hauptkeller))) has (a (area (Heizungsanlage)))"), p.parse("Das Zimmer Hauptkeller hat einen Bereich Heizungsanlage")); |
68 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027975 |
Snippet name: | test_RecursiveProbabilisticParser1 |
Eternal ID of this version: | #1027975/17 |
Text MD5: | 519eff9e95e29386154bda23d09fcd8d |
Transpilation MD5: | 274c3f209a3af2de0bb7f95b445a7739 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-04-23 12:04:06 |
Source code size: | 3226 bytes / 68 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 249 / 462 |
Version history: | 16 change(s) |
Referenced in: | [show references] |