dkpro / dkpro-cassis

UIMA CAS processing library written in Python
https://pypi.org/project/dkpro-cassis/
Apache License 2.0
84 stars 22 forks source link

How can I add some Sofas into the same CAS? #261

Closed yanirmr closed 1 year ago

yanirmr commented 1 year ago

Hi!

Using the test example about setting Sofa strings, we can add a sofa as follows:

def test_sofa_string_can_be_set_and_read():
    cas = Cas()

    cas.sofa_string = "I am a test sofa string!"

    assert cas.sofa_string == "I am a test sofa string!"

However, I couldn't find an example where more than one Sofa was set in one CAS file either in the documentation or in the tests. As far as I know, there is a list of Sofas in CAS, which should make this possible (here.

Any help would be greatly appreciated. Thanks a lot!

reckart commented 1 year ago

That method to get a list of sofas be a bit misleading. You can have multiple "views" per CAS and each view can have one sofa. See create_view() and get_view().

yanirmr commented 1 year ago

Thanks for responding so quickly! I'm not sure if I understand you correctly. For example, let's say I want to create a new CAS that contains a list of sofas. Can you describe the steps in a few words?

Thank you, Richard!

reckart commented 1 year ago

I don't have the code in front of me right now, but it should look something like this:

doc_initial_view = CAS(...)
doc_view1 = doc_initial_view.create_view("view1")
doc_view2 = doc_initial_view.create_view("view2")

What this gives you are three objects, each of them exposing the CAS calls, but each of them basically being a "sub-CAS". On each you can set a sofa string. When you add annotations to any of these views, the annotations point to the respective sofa of that view.