Hi Lee,
Your extend-protocol call is incorrectly parenthesized (rank is
outside the body of the form).
This means that "use" should blow up because the source is invalid.
Maybe your use is reading a different source file than you think it is?
Once I fixed that, the code works fine, at least insofar as the score
and rank vars are accessible.
Stu
I'm having a difficult time referencing a protocol in the user
namespace, I have the following code:
(ns clomoios.contextsearcher)
(defprotocol Searcher
(score [this term text] "Score this text in similarity")
(rank [this term text] "Rank sentences in this text"))
(defrecord ContextSearcher [get-sentences tokenize pos-tag])
(extend-protocol Searcher ContextSearcher
(score
[this term text]
(score-text text score-words get-sentences tokenizer)))
(rank
[this term text]
(reverse (sort-by second (score-sentences text score-words get-
sentences tokenizer)))))
When I try to use it from a different namespace, I can't access the
score and rank methods.
Example:
user=> (use 'clomoios.contextsearcher)
nil
user=> (def foo (make-context-searcher "models/EnglishSD.bin.gz"
"models/EnglishTok.bin.gz" "models/tag.bin.gz"))
#'user/foo
user=> foo
#:clomoios.contextsearcher.ContextSearcher{:get-sentences #<nlp
$make_sentence_detector__248$sentenizer__249 opennlp.nlp
$make_sentence_detector__248$sentenizer__...@766b62d1>, :tokenize
#<nlp
$make_tokenizer__252$tokenizer__253 opennlp.nlp
$make_tokenizer__252$tokenizer__...@9c4ff2c>, :pos-tag #<nlp
$make_pos_tagger__258$pos_tagger__259 opennlp.nlp
$make_pos_tagger__258$pos_tagger__...@64552a2b>}
user=> (score foo "a" "a")
java.lang.Exception: Unable to resolve symbol: score in this context
(NO_SOURCE_FILE:6)
user=> (clomoios.contextsearcher/score foo "a" "a")
java.lang.Exception: No such var: clomoios.contextsearcher/score
(NO_SOURCE_FILE:7)
user=> (clomoios.contextsearcher.ContextSearcher/score foo "a" "a")
java.lang.IllegalArgumentException: No matching method: score
(NO_SOURCE_FILE:8)
Am I using protocols on the wrong way? How should I refer to the score
and rank methods in the different namespace?
Syntax highlighted code here: http://gist.github.com/394685
- Lee
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient
with your first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en