infineac.process_event.extract_passages_from_event#

infineac.process_event.extract_passages_from_event(event: dict, keywords: list[str] | dict[str, int], nlp_model, modifier_words: list[str] = ['disregarding', 'except', 'excluding', 'ignoring', 'leaving out', 'not including', 'omitting'], sections: str = 'all', context_window_sentence: tuple[int, int] | int = 0, join_adjacent_sentences: bool = True, subsequent_paragraphs: int = 0, extract_answers: bool = False, return_type: str = 'list') str | list[list[list[list[str]]]][source]#

Wrapper function to extract important passages from an event: comprises of extract_passages_from_presentation() and extract_passages_from_qa().

Parameters:
  • event (dict) – Event to extract the passages from.

  • keywords (list[str] | dict[str, int]) – List of keywords to search for in the event and extract the corresponding passages. If keywords is a dictionary, the keys are the keywords.

  • nlp_model (spacy.lang) – NLP model.

  • modifier_words (list[str], default: MODIFIER_WORDS) – List of modifier_words, which must not precede the keyword.

  • sections (str, default: "all") – Section of the event to extract the passages from. Either “all”, “presentation” or “qa”

  • context_window_sentence (tuple[int, int] | int, default: 0) – The context window of of the sentences to be extracted. Either an integer or a tuple of length 2. The first element of the tuple indicates the number of sentences to be extracted before the sentence the keyword was found in, the second element indicates the number of sentences after it. If only an integer is provided, the same number of sentences are extracted before and after the keyword. If one of the elements is -1, all sentences before or after the keyword are extracted. So -1 can be used to extract all sentences before and after the keyword, e.g. the entire paragraph.

  • join_adjacent_sentences (bool, default: True) – Whether to join adjacent sentences or leave them as individual. If context_window_sentence > 0, this parameter is automatically set to True.

  • subsequent_paragraphs (int, default: 0) – Number of subsequent paragraphs to extract after the one containing a keyword.

  • extract_answers (bool, default: False) – If True, entire answers to questions that include a keyword are also extracted.

  • return_type (str, default: "list") – The return type of the method. Either “str” or “list”

Returns:

The extracted passages as a concatenated string or a nested list with the following hierarchy: presentation and qa - parts - paragraphs - passages.

Return type:

str | list[list[list[list[str]]]]