- Create input structures (best is to start from an example similar to one found in "surge/inputs")
- The macro "def-test" is used to associate a SURGE input specification (an FD) with the expected sentence.
For example:
(def-test t1
"This car is expensive."
((cat clause)
(proc ((type ascriptive)
(mode attributive))) ;; default
(partic ((carrier ((lex "car")
(cat common)
(distance near)))
(attribute ((lex "expensive")
(cat ap)))))))
Keep your test pairs in a development file and add the line (in-package "FUG5") at the beginning of your file.
- To test the interpretation of your input specification, use the "fug5:test" function:
(fug5:test :item 't1)
- If everything works fine, you will see the following input:
CL-USER> (fug5:test :item 't1)
====================
FUG5::T1 --> "This car is expensive."
[Used 88 backtracking points - 19 wrong branches - 8 undos]
[Used 89 backtracking points - 19 wrong branches - 8 undos]
OK
====================
1 test run - 1 correct.
- If the name of the test you invoke does not exist (no correspond def-test was entered), you will see:
(fug5:test :item 'd1)
====================
D1 --> NIL
[Used 1 backtracking points - 0 wrong branches - 0 undos]
[Used 1 backtracking points - 0 wrong branches - 0 undos]
Expected NIL
Instead "<fail>"
====================
1 test run - 0 correct.
The following tests are incorrect: (D1)
- If the input specification is not good, you will see a message similar to this:
FUG5::T146 --> "The Denver Nuggets surprisingly beat the Celtics."
[Used 90 backtracking points - 21 wrong branches - 10 undos]
[Used 110 backtracking points - 37 wrong branches - 14 undos]
Expected "The Denver Nuggets surprisingly beat the Celtics."
Instead "Denver Nuggets surprisingly beat Celtics."
====================
- Sometimes, the grammar will get exhausted trying many alternatives without terminating the search process.
The test macro limits the search space to up to 1000 backtracking points. When the input you specified is too complex or causes the grammar to search over this limit, you will see the following message:
====================
FUG5::A4 --> "John takes a book from Mary."
;;; Unification stopped after 1001 backtracking points.
Expected "John takes a book from Mary."
Instead "Mary ."
====================
- At other times, the input you enter is not compatible with the expectations of SURGE.
In this case, you will see:
====================
FUG5::T97 --> "The person to whom John will give a blue book."
Expected "The person to whom John will give a blue book."
Instead ""
====================
Debugging your SURGE Input Specifications
In any case when the input specification fails to produce the sentence you expect, you want to find out the reason for the failure.
To get information on the unification process, use the function:
(fug5:trace-on)
And to remove the trace info, use:
(fug5:trace-off)
This produces lots of information. You can control the verbosity of the trace by using:
(fug5:trace-level 30) ;; minimum level of trace detail
...
(fug5:trace-level 0) ;; maximum level of trace detail
Last modified October 29th 2012