Skip to content

Commit

Permalink
small, temporary workaround of clamsproject/mmif#228 for annotations …
Browse files Browse the repository at this point in the history
…list
  • Loading branch information
keighrim committed Jul 12, 2024
1 parent 2543352 commit 74e5400
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mmif/serialize/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Dict, Union, Optional, Generator, List, cast

from mmif import DocumentTypes, AnnotationTypes, ThingTypesBase, ClamsTypesBase
from mmif.serialize import model
from mmif.serialize.annotation import Annotation, Document
from mmif.serialize.model import PRMTV_TYPES, MmifObject, DataList, DataDict

Expand Down Expand Up @@ -439,6 +440,16 @@ def append(self, value: Union[Annotation, Document], overwrite=False) -> None:
:return: None
"""
super()._append_with_key(value.id, value, overwrite)

def __getitem__(self, key: str) -> model.T:
"""
specialized getter implementation to workaround https://github.com/clamsproject/mmif/issues/228
# TODO (krim @ 7/12/24): annotation ids must be in the long form in the future, so this check will be unnecessary once https://github.com/clamsproject/mmif/issues/228 is resolved.
"""
if ":" in key:
_, aid = key.split(":")
return self._items.__getitem__(aid)
return self._items.get(key, None)


class ContainsDict(DataDict[ThingTypesBase, Contain]):
Expand Down

0 comments on commit 74e5400

Please sign in to comment.