> the word is the key and the count the value. When storing in the database
> somehow the value (count) gets lost and I have no idea why.
This is probably my fault. I gave you a bad advice :-(
The idx'ings and countings work all fine, and the counted values are
stored in the value of each transient symtol in the tree.
However: Storing that idx tree in a database object will _not_ preserve
the values of the transient symbols in that tree. In general, when the
values or properties of external symbols refer to other symbols, those
symbol's values and properties are not taken account of in any way.
For example, if we write
(put!> MyObject 'lst '(a foo bar))
we don't want the values of 'a', 'foo' or 'bar' to be processed. They
could be anything out of context. The same holds for transient symbols.
The values of (transient and other) symbols will also not be preserved
if you write the tree structure directly to a file:
(out "file.save" (println Widx))
If you read it back later, you'll get the idx tree structure, but new
transient symbols without the counts.
So what can we do? I would store two separate lists in the database
object, one for the words and one for the counts:
(class +Awords +Entity)
(rel words (+Key +List))
(rel counts (+List))
(setq Widx (countWords Wrds))
(let L (idx 'Widx)
'words L # Store a sorted list of words
'counts (mapcar val L) ) ) # and their corresponding counts
When you access the tree later, you need two steps: Set the values of
the symbols, and rebuild the tree with 'balance':
(mapc set (: words) (: counts)) # Set each word to its count
(balance 'Widx (: words)) ) # Build an index in 'Widx'
Then you can retrieve the count as before:
(println (val (car (idx 'Widx "hello"))))
Hope this is ok. The drawback is that it does not work completely
transparent during database I/O.
UNSUBSCRIBE: mailto:[EMAIL PROTECTED]