code: def nltk_tokenize_words(string, attached_period=False, language=None):
      
      assert isinstance(string, str), "Incoming string must be type str."
      if language == 'sanskrit':
          periods = ['.', '।','॥']
      else:
          periods = ['.']
      punkt = PunktLanguageVars()
      tokens = punkt.word_tokenize(string)
      if attached_period:
          return tokens
      new_tokens = []
      for word in tokens:
          for char in periods:
              if word.endswith(char):
                  new_tokens.append(word[:-1])
                  new_tokens.append(char)
                  break
          else:
              new_tokens.append(word)
      return new_tokens
docs: Wrap NLTK's tokenizer PunktLanguageVars(), but make final period
      its own token.
  
      >>> nltk_tokenize_words("Sentence 1. Sentence 2.")
      ['Sentence', '1', '.', 'Sentence', '2', '.']
  
      >>> #Optionally keep the NLTK's output:
  
      >>> nltk_tokenize_words("Sentence 1. Sentence 2.", attached_period=True)
      ['Sentence', '1.', 'Sentence', '2.']
  
      TODO: Run some tests to determine whether there is a large penalty for
      re-calling PunktLanguageVars() for each use of this function. If so, this
      will need to become a class, perhaps inheriting from the PunktLanguageVars
      object. Maybe integrate with WordTokenizer.