class_docstr: Create a doc instance of text, obtain cleaned, readable text and
  metadata from this doc.
  
  Properties:
  raw: incoming, unedited text
  language: 2-letter code for the language of the text
  is_detected_language: is the language detected or specified beforehand
  is_reliable_language: is the language specified or was it reliably detected
  hint_language: language you expect your text to be
  _spacy_nlps: nested dictionary {lang: {model_id: model}} with loaded spacy language modules
docstr: Returns document embeddings generated with Gensim word2vec model.
  idf_weighting scheme can be 'naive' or 'log'
  
  >>> import numpy
  >>> from textpipe.doc import Doc
  >>> doc1 = Doc('textmining is verwant aan tekstanalyse')
  >>> doc2 = Doc('textmining is verwant aan textmining')
  >>> doc3 = Doc('tekstanalyse is verwant aan textmining')
  >>> test_model_file = 'tests/models/gensim_test_nl.kv'
  >>> numpy.allclose(doc1.generate_gensim_document_embedding(model_uri=test_model_file),                            doc2.generate_gensim_document_embedding(model_uri=test_model_file))
  False
  >>> numpy.allclose(doc1.generate_gensim_document_embedding(model_uri=test_model_file),                            doc3.generate_gensim_document_embedding(model_uri=test_model_file))
  True
docstr_tok: ["Returns","document","embeddings","generated","with","Gensim","word2vec","model",".","idf_weighting","scheme","can","be","'naive","'","or","'log'",">",">",">","import","numpy",">",">",">","from","textpipe.doc","import","Doc",">",">",">","doc1","=","Doc","(","'textmining","is","verwant","aan","tekstanalyse","'",")",">",">",">","doc2","=","Doc","(","'textmining","is","verwant","aan","textmining","'",")",">",">",">","doc3","=","Doc","(","'tekstanalyse","is","verwant","aan","textmining","'",")",">",">",">","test_model_file","=","'tests\/models\/gensim_test_nl.kv'",">",">",">","numpy.allclose","(","doc1.generate_gensim_document_embedding","(","model_uri=test_model_file",")",",","doc2.generate_gensim_document_embedding","(","model_uri=test_model_file",")",")","False",">",">",">","numpy.allclose","(","doc1.generate_gensim_document_embedding","(","model_uri=test_model_file",")",",","doc3.generate_gensim_document_embedding","(","model_uri=test_model_file",")",")","True"]
code: def generate_gensim_document_embedding(
      self,
      model_uri=None,
      lowercase=True,
      max_lru_cache_size=1024,
      idf_weighting="naive",
  ):
      """
          Returns document embeddings generated with Gensim word2vec model.
          idf_weighting scheme can be 'naive' or 'log'
  
          >>> import numpy
          >>> from textpipe.doc import Doc
          >>> doc1 = Doc('textmining is verwant aan tekstanalyse')
          >>> doc2 = Doc('textmining is verwant aan textmining')
          >>> doc3 = Doc('tekstanalyse is verwant aan textmining')
          >>> test_model_file = 'tests/models/gensim_test_nl.kv'
          >>> numpy.allclose(doc1.generate_gensim_document_embedding(model_uri=test_model_file), \
                             doc2.generate_gensim_document_embedding(model_uri=test_model_file))
          False
          >>> numpy.allclose(doc1.generate_gensim_document_embedding(model_uri=test_model_file), \
                             doc3.generate_gensim_document_embedding(model_uri=test_model_file))
          True
          """
      if not model_uri:
          raise TextpipeMissingModelException(
              "No Gensim keyed vector location specified."
          )
  
      model = self._load_gensim_word2vec_model(
          model_uri, max_lru_cache_size
      )
  
      if lowercase:
          prepared_word_counts = [
              (word.lower(), count)
              for word, count in self.word_counts.items()
              if word.lower() in model
          ]
      else:
          prepared_word_counts = [
              (word, count)
              for word, count in self.word_counts.items()
              if word in model
          ]
  
      if not prepared_word_counts:
          return []
  
      if isinstance(model, RedisKeyedVectors):
          # For redis, the word vectors are already divided by the idf when a word2vec model
          # was loaded (see RedisKeyedVectors.load_keyed_vectors_into_redis)
          if model.idf_weighting != idf_weighting:
              raise RedisIDFWeightingMismatchException(
                  f"The specified document embedding idf "
                  f'weighting "{idf_weighting}" does not '
                  f'match weighting in RedisKeyedVector "'
                  f'{model.idf_weighting}"'
              )
          vectors = [
              model[word] * count
              for word, count in prepared_word_counts
          ]
      else:
          vectors = []
          for word, count in prepared_word_counts:
              if idf_weighting == "naive":
                  idf = model.vocab[word].count
              elif idf_weighting == "log":
                  idf = (
                      numpy.log(
                          self.nr_train_tokens
                          / (model.vocab[word].count + 1)
                      )
                      + 1
                  )
              else:
                  raise ValueError(
                      f'idf_weighting "{idf_weighting}" not available; use '
                      f'"naive" or "log"'
                  )
  
              vectors.append(model[word] * (count / idf))
      return list(sum(vectors))
  
imports: import functools
  import re
  import unicodedata
  from collections import Counter
  from urllib.parse import urlparse
  import cld2
  import numpy
  import spacy
  import spacy.matcher
  import textacy
  import textacy.ke
  import textacy.text_utils
  from bs4 import BeautifulSoup
  from datasketch import MinHash
  from gensim.models.keyedvectors import KeyedVectors
  from gensim.summarization.summarizer import summarize
  from textpipe.data.emoji import EMOJI_TO_UNICODE_NAME, EMOJI_TO_SENTIMENT
  from textpipe.wrappers import RedisKeyedVectors
  from textpipe.util import getattr_
label_desc: Use image node_id 31 for calling the Doc obj's underlying member method code with example usage: obj.generate_gensim_document_embedding(model_uri, lowercase, max_lru_cache_size, idf_weighting) and returns: list, list