| … | … | @@ -26,7 +26,7 @@ |
| 26 | 26 | ; using nothing but a pure Atomese pipeline, continuing the below. |
| 27 | 27 | ; |
| 28 | 28 | (use-modules (opencog) (opencog exec) (opencog sensory)) |
| 29 | | (use-modules (opencog nlp) (opencog nlp lg-parse)) |
| 29 | (use-modules (opencog lg)) |
| 30 | 30 | |
| 31 | 31 | ; Before running this demo, copy `demo.txt` to the /tmp directory. |
| 32 | 32 | ; (copy-file "demo.txt" "/tmp/demo.txt") |
| … | … | @@ -135,10 +135,18 @@ |
| 135 | 135 | ; Sniff test. Does it work? |
| 136 | 136 | ; (cog-execute! bonder) |
| 137 | 137 | |
| 138 | ; The above creates a double-wrapped list. Peel off one layer. |
| 139 | (define unwrapper |
| 140 | (CollectionOfLink (Type 'FlatStream) |
| 141 | (OrderedLink bonder))) |
| 142 | |
| 143 | ; Sniff test. Does it work? |
| 144 | ; (cog-value->list (cog-execute! unwrapper)) |
| 145 | |
| 138 | 146 | ; Create the anchor for the word bonds |
| 139 | 147 | (cog-execute! |
| 140 | 148 | (SetValue (Anchor "parse pipe") (Predicate "word bonds") |
| 141 | | (DontExec bonder))) |
| 149 | (DontExec unwrapper))) |
| 142 | 150 | |
| 143 | 151 | ; Anchor reference |
| 144 | 152 | (define bond-stream |
| … | … | @@ -147,6 +155,25 @@ |
| 147 | 155 | ; Sniff test. Does it work? |
| 148 | 156 | ; (cog-execute! bond-stream) |
| 149 | 157 | |
| 158 | ; -------------------------------------------------------- |
| 159 | ; With the bonds between word-pairs available, one may now begin |
| 160 | ; statistical analysis. A good place to begin is simply counting |
| 161 | ; word-pairs. |
| 162 | |
| 163 | (define counter |
| 164 | (Filter |
| 165 | (Rule |
| 166 | (TypedVariable (Variable "$edge") (Type 'Edge)) |
| 167 | (Variable "$edge") |
| 168 | (IncrementValueOn |
| 169 | (Variable "$edge") |
| 170 | (Predicate ":edge-count:") |
| 171 | (Number 1))) |
| 172 | bond-stream)) |
| 173 | |
| 174 | ; Sniff test. Does it work? |
| 175 | ; (cog-execute! counter) |
| 176 | |
| 150 | 177 | |
| 151 | 178 | ; -------------------------------------------------------- |
| 152 | 179 | ; The End! That's All, Folks! |