inception-project / inception-external-recommender

Get annotation suggestions for the INCEpTION text annotation platform from spaCy, Sentence BERT, scikit-learn and more. Runs as a web-service compatible with the external recommender API of INCEpTION.
Apache License 2.0
40 stars 17 forks source link

Helper methods #26

Closed reckart closed 3 years ago

reckart commented 3 years ago

Is your feature request related to a problem? Please describe. The helper methods we have right now e.g. to create predictions are very hard-coded to the DKPro Core type system.

Describe the solution you'd like Either make the helpers more flexible or remove them in favor of calling cassis directly.

jcklie commented 3 years ago

How do you then write recommender? You hard code the token type then inside the recommender instead of a util function, Does that help you?

reckart commented 3 years ago

What I do right now looks like e.g. this:

        words = [cas.get_covered_text(cas_token) for cas_token in cas.select(MY_NON_DKPRO_TOKEN_TYPE)]
...
        AnnotationType = cas.typesystem.get_type(layer) // layer from the predict-method argument
        for cas_token, spacy_token in zip(cas.select(MY_NON_DKPRO_TOKEN_TYPE), doc):
            fields = {"begin": cas_token.begin, "end": cas_token.end, feature: spacy_token.pos_, "componentId": "spacy"}
            cas.add_annotation(AnnotationType(**fields))