Skip to content

Unhelpful warning when loading MMIF file #331

@marcverhagen

Description

@marcverhagen

Because

If an Annotation has both a word and a text property you get this warning printed to the standard output:

UserWarning: Both "text" and "word" are in the properties of "to_1", however "text" and "word" are both aliases of "text".Having two synonyms in the same annotation can cause unexpected behavior.
  warnings.warn(warning_msg, UserWarning)
/Applications/ADDED/venv/clams/mmif-summarizer2/lib/python3.10/site-packages/mmif/serialize/annotation.py:131: UserWarning: Both "word" and "text" are in the properties of "to_1", however "word" is an alias of "text".Having two synonyms in the same annotation can cause unexpected behavior.
  warnings.warn(warning_msg, UserWarning)

You get two warnings per annotation.

This may be helpful to the developer but it is not helpful to an end user. It is not clear how some property comes to be an alias of another property, so this would be very confusing.

The easiest way to replicate this is to to take the MMIF file below and run mmif rewind <FILENAME>.

{
  "metadata": {
    "mmif": "http://mmif.clams.ai/1.0.4"
  },
  "documents": [
    {
      "@type": "http://mmif.clams.ai/vocabulary/VideoDocument/v1",
      "properties": {
        "mime": "video",
        "id": "d1",
        "location": "baapb://cpb-aacip-526-z60bv7c69m.video"
      }
    }
  ],
  "views": [
    {
      "id": "v_1",
      "metadata": {
        "timestamp": "2024-07-03T21:23:42.458728",
        "app": "http://apps.clams.ai/doctr-wrapper/v1.1",
        "contains": {
          "http://vocab.lappsgrid.org/Token": {}
        },
        "appConfiguration": {}
      },
      "annotations": [
        {
          "@type": "http://vocab.lappsgrid.org/Token",
          "properties": {
            "document": "td_1",
            "start": 0,
            "end": 1,
            "text": ".",
            "word": ".",
            "id": "to_1"
          }
        }
      ]
    }
  ]
}

Done when

This is done when warnings are gone or have a documented meaning.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions