code: def find_next_word(index, text, word, output):
      """
      Locate the next word in the text. In case a paragraph break is found, also write paragraph break to labels.
      """
      idx = 0
      word_sofar = ""
      while index < len(text) and idx < len(word):
          para_break, break_len = is_para_break(index, text)
          if para_break:
              # multiple newlines found, paragraph break
              if len(word_sofar) > 0:
                  assert re.match(
                      r"^\s+$", word_sofar
                  ), "Found non-empty string at the end of a paragraph that doesn't match any token: |{}|".format(
                      word_sofar
                  )
                  word_sofar = ""
  
              output.write("\n\n")
              index += break_len - 1
          elif re.match(r"^\s$", text[index]) and not re.match(
              r"^\s$", word[idx]
          ):
              # whitespace found, and whitespace is not part of a word
              word_sofar += text[index]
          else:
              # non-whitespace char, or a whitespace char that's part of a word
              word_sofar += text[index]
              assert text[index].replace("\n", " ") == word[idx], (
                  "Character mismatch: raw text contains |%s| but the next word is |%s|."
                  % (word_sofar, word)
              )
              idx += 1
          index += 1
      return index, word_sofar
  
file_path: stanza/stanza/utils/datasets/prepare_tokenizer_data.py
imports: import argparse
  import json
  import os
  import re
  import sys
  from collections import Counter
label_desc: Use image node_id 2 for calling a global function with example usage: find_next_word(index, text, word, output) and returns: index,  word_sofar