code: def singularize(word, pos=NOUN, custom={}):
      if word in list(custom.keys()):
          return custom[word]
  
      # Recursion of compound words (e.g. mothers-in-law).
      if "-" in word:
          words = word.split("-")
          if len(words) > 1 and words[1] in plural_prepositions:
              return (
                  singularize(words[0], pos, custom)
                  + "-"
                  + "-".join(words[1:])
              )
      # dogs' => dog's
      if word.endswith("'"):
          return singularize(word[:-1]) + "'s"
  
      lower = word.lower()
      for w in singular_uninflected:
          if w.endswith(lower):
              return word
      for w in singular_uncountable:
          if w.endswith(lower):
              return word
      for w in singular_ie:
          if lower.endswith(w + "s"):
              return w
      for w in singular_s:
          if lower.endswith(w + "es"):
              return w
      for w in list(singular_irregular.keys()):
          if lower.endswith(w):
              return re.sub(
                  "(?i)" + w + "$", singular_irregular[w], word
              )
  
      for rule in singular_rules:
          suffix, inflection = rule
          match = suffix.search(word)
          if match:
              groups = match.groups()
              for k in range(0, len(groups)):
                  if groups[k] == None:
                      inflection = inflection.replace(
                          "\\" + str(k + 1), ""
                      )
              return suffix.sub(inflection, word)
  
      return word
  
label_desc: Use image node_id 2 for calling a global function with example usage: singularize(word, pos, custom) and returns: word, custom, unknown, unknown, word, word, w, w, re, suffix