class_docstr: Main class for sentiment inference execution.
  
  Attributes:
      opinion_lex: Opinion lexicon as outputted by TrainSentiment module.
      aspect_lex: Aspect lexicon as outputted by TrainSentiment module.
      intensifier_lex (dict): Pre-defined intensifier lexicon.
      negation_lex (dict): Pre-defined negation lexicon.
class_docstr_tok: ["Main","class","for","sentiment","inference","execution",".","Attributes",":","opinion_lex",":","Opinion","lexicon","as","outputted","by","TrainSentiment","module",".","aspect_lex",":","Aspect","lexicon","as","outputted","by","TrainSentiment","module",".","intensifier_lex","(","dict",")",":","Pre-defined","intensifier","lexicon",".","negation_lex","(","dict",")",":","Pre-defined","negation","lexicon","."]
docstr: Extract opinion-aspect events from sentence.
  
  Args:
      aspect_index: index of aspect in sentence.
      parsed_sent: current sentence parse tree.
      aspect_key: main aspect term serves as key in aspect dict.
      index_range: The index range of the multi word aspect.
  
  Returns:
      List of aspect sentiment pair, and list of events extracted.
docstr_tok: ["Extract","opinion-aspect","events","from","sentence",".","Args",":","aspect_index",":","index","of","aspect","in","sentence",".","parsed_sent",":","current","sentence","parse","tree",".","aspect_key",":","main","aspect","term","serves","as","key","in","aspect","dict",".","index_range",":","The","index","range","of","the","multi","word","aspect",".","Returns",":","List","of","aspect","sentiment","pair",",","and","list","of","events","extracted","."]
code: def _detect_opinion_aspect_events(
      self, aspect_index, parsed_sent, aspect_key, index_range
  ):
      """Extract opinion-aspect events from sentence.
  
      Args:
          aspect_index: index of aspect in sentence.
          parsed_sent: current sentence parse tree.
          aspect_key: main aspect term serves as key in aspect dict.
          index_range: The index range of the multi word aspect.
  
      Returns:
          List of aspect sentiment pair, and list of events extracted.
      """
      all_pairs, events = [], []
      sentence_text_list = [x["text"] for x in parsed_sent]
      sentence_text = " ".join(sentence_text_list)
      for tok_i, tok in enumerate(parsed_sent):
          aspect_op_pair = []
          terms = []
          gov_i = tok["gov"]
          gov = parsed_sent[gov_i]
          gov_text = gov["text"]
          tok_text = tok["text"]
  
          # 1st order rules
          # Is cur_tkn an aspect and gov an opinion?
          if tok_i == aspect_index:
              if gov_text.lower() in self.opinion_lex:
                  aspect_op_pair.append(
                      (
                          self._modify_for_multiple_word(
                              tok, parsed_sent, index_range
                          ),
                          gov,
                      )
                  )
  
          # Is gov an aspect and cur_tkn an opinion?
          if (
              gov_i == aspect_index
              and tok_text.lower() in self.opinion_lex
          ):
              aspect_op_pair.append(
                  (
                      self._modify_for_multiple_word(
                          gov, parsed_sent, index_range
                      ),
                      tok,
                  )
              )
  
          # If not found, try 2nd order rules
          if not aspect_op_pair and tok_i == aspect_index:
              # 2nd order rule #1
              for op_t in parsed_sent:
                  if (
                      op_t["gov"] == gov_i
                      and op_t["text"].lower() in self.opinion_lex
                  ):
                      aspect_op_pair.append(
                          (
                              self._modify_for_multiple_word(
                                  tok, parsed_sent, index_range
                              ),
                              op_t,
                          )
                      )
  
              # 2nd order rule #2
              gov_gov = parsed_sent[parsed_sent[gov_i]["gov"]]
              if gov_gov["text"].lower() in self.opinion_lex:
                  aspect_op_pair.append(
                      (
                          self._modify_for_multiple_word(
                              tok, parsed_sent, index_range
                          ),
                          gov_gov,
                      )
                  )
  
          # if aspect_tok found
          for aspect, opinion in aspect_op_pair:
              op_tok_i = parsed_sent.index(opinion)
              score = self.opinion_lex[opinion["text"].lower()].score
              neg_terms, sign = self._extract_neg_terms(
                  sentence_text_list, op_tok_i, parsed_sent
              )
              polarity = (
                  Polarity.POS if score * sign > 0 else Polarity.NEG
              )
              (
                  intensifier_score,
                  intensifier_terms,
              ) = self._extract_intensifier_terms(
                  sentence_text_list, op_tok_i, polarity, parsed_sent
              )
              over_all_score = score * sign * intensifier_score
              terms.append(
                  Term(
                      aspect_key,
                      TermType.ASPECT,
                      polarity,
                      over_all_score,
                      aspect["start"],
                      aspect["len"],
                  )
              )
              terms.append(
                  Term(
                      opinion["text"],
                      TermType.OPINION,
                      polarity,
                      over_all_score,
                      opinion["start"],
                      opinion["len"],
                  )
              )
              if len(neg_terms) > 0:
                  terms = terms + neg_terms
              if len(intensifier_terms) > 0:
                  terms = terms + intensifier_terms
              all_pairs.append(
                  [
                      aspect_key,
                      opinion["text"],
                      over_all_score,
                      polarity,
                      sentence_text,
                  ]
              )
              events.append(terms)
      return all_pairs, events
  
imports: import math
  from os import PathLike
  from pathlib import Path, PosixPath
  from typing import Union
  from nlp_architect.common.core_nlp_doc import CoreNLPDoc
  from nlp_architect.models.absa import INFERENCE_OUT
  from nlp_architect.models.absa.inference.data_types import Term, TermType, Polarity, SentimentDoc, SentimentSentence, LexiconElement
  from nlp_architect.models.absa.utils import _read_lexicon_from_csv, load_opinion_lex, _load_aspect_lexicon, parse_docs, parse_docs_bist, _load_parsed_docs_from_dir
  from tqdm import tqdm
label_desc: Use image node_id 9 for calling the SentimentInference obj's underlying member method code with example usage: obj._detect_opinion_aspect_events(aspect_index, parsed_sent, aspect_key, index_range) and returns: all_pairs,  events