You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a recent conversation, we discussed a future direction of text summarization apps based on small slices of text document, using, for example, SWT results.
Specifically, I think we need
get_annotations_between_time(start: int, end:int) (tentative name) function in mmif.serialize.mmif.Mmif class that
returns all TimeFrame and TimePoint annotations falling into the time interval, sorted by start time,
along with other annotations aligned with those TF or TP annotations.
a new util module text_document_helper (also tentative) in mmif.utils package that contains a function that takes a collection of Token (or other text region/segment annotations) and return a single, concatenated string.
We will use this issue card to continue technical discussion.
In terms of implementing get_annotations_between_time function, some questions about:
Return format: my idea is to return a dict whose key is the string ("timeFrame", "timePoint") and the value is a list of TF/TP annotations
Judging whether a TimeFrame is in a time interval: should the condition be only true if the entire TimeFrame is in the interval? Or we can say it's also true for when they overlap, e.g. [2, 8] overlaps with [3, 10]?
Other annotations: Since our goal is to "slice" text from transcribed texts, I'm wondering if there's any other annotations other than Token annotations.
Return format: my idea is to return a dict whose key is the string ("timeFrame", "timePoint") and the value is a list of TF/TP annotations
I was naively thinking that they can be just in a single list, when starting this feature requests. For the downstream use of this method, for example mmif.utils.text_document_helper.slice_text, if the return type is just one iterable;
defslice_text(mmif, start_time, end_time):
time_annotations=mmif.get_annotations_between_time(start_time, end_time)
slice= []
forannintime_annotations:
ifann._attype==AnnotationTypes.Token: # this has to be actually lapps.discriminators.Uri.TOKEN, I use AnnotationTypes just for demonstration slice.append(ann.get_propery('text')
return' '.join(slice)
Then internally, the implementation can be something like
This is just a suggestion, so feel free to come up with any working implementation that works best for the downstream usage.
Judging whether a TimeFrame is in a time interval: should the condition be only true if the entire TimeFrame is in the interval? Or we can say it's also true for when they overlap, e.g. [2, 8] overlaps with [3, 10]?
I think we definitely don't want to include full overlaps (e.g., [2, 13] overlaps with [3, 10]). For partial overlaps, maybe we can add a parameter to select the behavior?
defget_annotations_between_time(self, s, e, allow_overlap=False):
time_anns= []
forvinself.views:
forainv.annotations:
ifa.attypein (AnnotationTypes.TimePoint, AnnotationTypes.TimePoint):
ifself.is_in_time(a, s, e, allow_overlap):
time_anns.append(a)
...
Other annotations: Since our goal is to "slice" text from transcribed texts, I'm wondering if there's any other annotations other than Token annotations.
Technically, all types under Region in this tree https://vocab.lappsgrid.org/ are slice-able text annotations. Usually, when there's multiple levels of text annotations in one MMIF (look at the spacy output for example), only the lowest level of the character-based annotation (Token for most case) is directly aligned to time-based annotations.
Activity
bohJiang12 commentedon Jun 7, 2024
In terms of implementing
get_annotations_between_timefunction, some questions about:dictwhose key is the string ("timeFrame", "timePoint") and the value is a list of TF/TP annotationsTimeFrameis in a time interval: should the condition be only true if the entireTimeFrameis in the interval? Or we can say it's also true for when they overlap, e.g. [2, 8] overlaps with [3, 10]?Tokenannotations.keighrim commentedon Jun 8, 2024
I was naively thinking that they can be just in a single list, when starting this feature requests. For the downstream use of this method, for example
mmif.utils.text_document_helper.slice_text, if the return type is just one iterable;Then internally, the implementation can be something like
This is just a suggestion, so feel free to come up with any working implementation that works best for the downstream usage.
I think we definitely don't want to include full overlaps (e.g., [2, 13] overlaps with [3, 10]). For partial overlaps, maybe we can add a parameter to select the behavior?
Technically, all types under
Regionin this tree https://vocab.lappsgrid.org/ are slice-able text annotations. Usually, when there's multiple levels of text annotations in one MMIF (look at the spacy output for example), only the lowest level of the character-based annotation (Tokenfor most case) is directly aligned to time-based annotations.Another case we need to be careful here is OCR . OCR is done on images, and images (still frames) are extracted from and aligned to
TimePointannotations. OCR results are stored inTextDocumentannotation type (along with lower-level tokenizations, if available). Here's an example MMIF from SWT-docTR pipeline (search forv_2to go to OCR view) https://github.com/clamsproject/aapb-evaluations/blob/main/ocr_eval/preds%40doctr-wrapper1.1%40aapb-annotation-44/cpb-aacip-0515ac167c0.swt.stitch.doctr.mmif.credits.mmif