code: def get_scare_snippets(
      nlp, csv_dir_path, text_id_map, filename_pattern="*.csv"
  ):
      """
      Read snippets from the given CSV directory
      """
      num_short_items = 0
  
      snippets = []
      csv_files = glob.glob(
          os.path.join(csv_dir_path, filename_pattern)
      )
      for csv_filename in csv_files:
          with open(csv_filename, newline="") as fin:
              cin = csv.reader(fin, delimiter="\t", quotechar='"')
              lines = list(cin)
  
              for line in lines:
                  ann_id, begin, end, sentiment = [
                      line[i] for i in [1, 2, 3, 6]
                  ]
                  begin = int(begin)
                  end = int(end)
                  if sentiment.lower() == "unknown":
                      continue
                  elif sentiment.lower() == "positive":
                      sentiment = 2
                  elif sentiment.lower() == "neutral":
                      sentiment = 1
                  elif sentiment.lower() == "negative":
                      sentiment = 0
                  else:
                      raise ValueError(
                          "Tell John he screwed up and this is why he can't have Mox Opal: {}".format(
                              sentiment
                          )
                      )
                  if ann_id not in text_id_map:
                      print(
                          "Found snippet which can't be found: {}-{}".format(
                              csv_filename, ann_id
                          )
                      )
                      continue
                  snippet = text_id_map[ann_id][begin:end]
                  doc = nlp(snippet)
                  text = [
                      token.text
                      for sentence in doc.sentences
                      for token in sentence.tokens
                  ]
                  num_tokens = sum(
                      len(sentence.tokens) for sentence in doc.sentences
                  )
                  if num_tokens < 4:
                      num_short_items = num_short_items + 1
                  snippets.append(SentimentDatum(sentiment, text))
      print("Number of short items: {}".format(num_short_items))
      return snippets
  
file_path: stanza/stanza/utils/datasets/sentiment/process_scare.py
imports: import csv
  import glob
  import os
  import sys
  import stanza
  from stanza.models.classifiers.data import SentimentDatum
  import stanza.utils.datasets.sentiment.process_utils
label_desc: Use image node_id 1 for calling a global function with example usage: get_scare_snippets(nlp, csv_dir_path, text_id_map, filename_pattern) and returns: snippets