original_docstring: Expected input is a preprocessed document.
      Calculates sentence vectors using the built-in fastText function which
      averages the word-vector norms of all the words in the given sentence.
      
docstring: Expected input is a preprocessed document.
  Calculates sentence vectors using the built-in fastText function which
  averages the word-vector norms of all the words in the given sentence.
docstring_tokens: Expected input is a preprocessed document . Calculates sentence vectors using the built - in fastText function which averages the word - vector norms of all the words in the given sentence .
code: def build_doc_vectors(model, doc, export_path=None):
      """Expected input is a preprocessed document.
      Calculates sentence vectors using the built-in fastText function which
      averages the word-vector norms of all the words in the given sentence.
      """
      def calc_vectors(doc, vector_matrix):
          for idx, line in enumerate(doc):
              print('\rcalculating vector for line #', idx, end='')
              vector_matrix.append(model.get_sentence_vector(str(line.strip())))
          print()
  
      vector_matrix = []
      if isinstance(model, str):
          model = load_model(model)
      if isinstance(doc, str):
          if os.path.exists(doc):
              with open(doc, 'r') as doc_file:
                  calc_vectors(doc_file, vector_matrix)
          else:
              raise ValueError(doc_path_error)
      elif isinstance(doc, list):
          calc_vectors(doc, vector_matrix)
      else:
          raise TypeError(doc_type_error.format(type(doc)))
      vector_matrix = np.array(vector_matrix)
      if export_path:
          np.save(export_path, vector_matrix)
          print('\nfasttext doc vectors saved in', os.path.realpath(export_path))
      return vector_matrix
code_tokens: def build_doc_vectors ( model , doc , export_path = None ) : def calc_vectors ( doc , vector_matrix ) : for idx , line in enumerate ( doc ) : print ( '\rcalculating vector for line #' , idx , end = '' ) vector_matrix . append ( model . get_sentence_vector ( str ( line . strip ( ) ) ) ) print ( ) vector_matrix = [ ] if isinstance ( model , str ) : model = load_model ( model ) if isinstance ( doc , str ) : if os . path . exists ( doc ) : with open ( doc , 'r' ) as doc_file : calc_vectors ( doc_file , vector_matrix ) else : raise ValueError ( doc_path_error ) elif isinstance ( doc , list ) : calc_vectors ( doc , vector_matrix ) else : raise TypeError ( doc_type_error . format ( type ( doc ) ) ) vector_matrix = np . array ( vector_matrix ) if export_path : np . save ( export_path , vector_matrix ) print ( '\nfasttext doc vectors saved in' , os . path . realpath ( export_path ) ) return vector_matrix
short_docstring: Expected input is a preprocessed document.
short_docstring_tokens: Expected input is a preprocessed document .
comment: """Expected input is a preprocessed document.
      Calculates sentence vectors using the built-in fastText function which
      averages the word-vector norms of all the words in the given sentence.
      """