Hi everyone,

I'm facing a little problem when extending protocols in a mix of inheriting and implementing classes...Let me explain:

stanford-corenlp defines a top level interface called "Annotator" (with a single 'annotatate' method signature'). It also defines a class called "AnnotationPipeline" which implements Annotator and a class StanfordCoreNLP which extends AnnotationPipeline and is essentially the main entry point for the library...Under this class (in the hierarchy), one can find all the concrete implementations of several 'Annotators'. Now the problem is this: All these Annotators are not pipelines (or workflows) they are single components in a sense, but they do implement "Annotator" as does AnnotationPipeline. I need to extend my own protocol "IWorkflow" to AnnotationPipeline and my own 'IComponent' to all the single-Annotators without having them satisfy IWorkflow. It is fine if AnnotationPipeline satisfies IComponent and NOT the other way round (components satisfying IWorkflow).

Mybest attempt was this:

(defn extend-stanford-core
"A single fn to extend to all stanford-corenlp modules (or 'annotators' as they call them). "
[]
(extend-type edu.stanford.nlp.pipeline.AnnotationPipeline
IWorkflow
(deploy [this ^String text]
  (.annotate this text))
(appendComponent [this co]
  (.addAnnotator this (reify edu.stanford.nlp.pipeline.Annotator
              (annotate [this annotation]
                (run co annotation))))) )
(extend-type edu.stanford.nlp.pipeline.StanfordCoreNLP
IComponent
 (run [this ^String text]
  (let [ann (edu.stanford.nlp.pipeline.Annotation. text)]
    (.annotate this ann) ann)))
)

However, as I said, a stanfordNLP consumer will most likely use the StanfordCoreNLP class to create the single-annotators...Consequently, his 'components' will also satisfy IWorkflow (because StanfordCoreNLP inherits from AnnotationPipeline), which is not desirable...

any thoughts?

Jim

--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to