scattertext/__init__.py
def produce_projection_explorer(corpus,
                                category,
                                word2vec_model=None,
                                projection_model=None,
                                embeddings=None,
                                term_acceptance_re=re.compile('[a-z]{3,}'),
                                show_axes=False,
                                **kwargs):
    '''
    Parameters
    ----------
    corpus : ParsedCorpus
        It is highly recommended to use a stoplisted, unigram corpus-- `corpus.get_stoplisted_unigram_corpus()`
    category : str
    word2vec_model : Word2Vec
        A gensim word2vec model.  A default model will be used instead. See Word2VecFromParsedCorpus for the default
        model.
    projection_model : sklearn-style dimensionality reduction model.
        By default: umap.UMAP(min_dist=0.5, metric='cosine')
      You could also use, e.g., sklearn.manifold.TSNE(perplexity=10, n_components=2, init='pca', n_iter=2500, random_state=23)
    embeddings : array[len(corpus.get_terms()), X]
        Word embeddings.  If None (default), will train them using word2vec Model
    term_acceptance_re : SRE_Pattern,
        Regular expression to identify valid terms
    show_axes : bool, default False
        Show the ticked axes on the plot.  If false, show inner axes as a crosshair.
    kwargs : dict
        Remaining produce_scattertext_explorer keywords get_tooltip_content

    Returns
    -------
    str
    HTML of visualization

    '''
    embeddings_resolover = EmbeddingsResolver(corpus)
    if embeddings is not None:
        embeddings_resolover.set_embeddings(embeddings)
    else:
        embeddings_resolover.set_embeddings_model(word2vec_model, term_acceptance_re)
    corpus, word_axes = embeddings_resolover.project_embeddings(projection_model, x_dim=0, y_dim=1)
    html = produce_scattertext_explorer(
        corpus=corpus,
        category=category,
        minimum_term_frequency=0,
        sort_by_dist=False,
        x_coords=scale(word_axes['x']),
        y_coords=scale(word_axes['y']),
        y_label='',
        x_label='',
        show_axes=show_axes,
        **kwargs
    )
    return html

    Parameters
    ----------
    corpus : ParsedCorpus
        It is highly recommended to use a stoplisted, unigram corpus-- `corpus.get_stoplisted_unigram_corpus()`
    category : str
    word2vec_model : Word2Vec
        A gensim word2vec model.  A default model will be used instead. See Word2VecFromParsedCorpus for the default
        model.
    projection_model : sklearn-style dimensionality reduction model.
        By default: umap.UMAP(min_dist=0.5, metric='cosine')
      You could also use, e.g., sklearn.manifold.TSNE(perplexity=10, n_components=2, init='pca', n_iter=2500, random_state=23)
    embeddings : array[len(corpus.get_terms()), X]
        Word embeddings.  If None (default), will train them using word2vec Model
    term_acceptance_re : SRE_Pattern,
        Regular expression to identify valid terms
    show_axes : bool, default False
        Show the ticked axes on the plot.  If false, show inner axes as a crosshair.
    kwargs : dict
        Remaining produce_scattertext_explorer keywords get_tooltip_content

    Returns
    -------
    str
    HTML of visualization

    
Parameters
corpus : ParsedCorpus
It is highly recommended to use a stoplisted, unigram corpus-- `corpus.get_stoplisted_unigram_corpus()`
category : str
word2vec_model : Word2Vec
A gensim word2vec model.  A default model will be used instead. See Word2VecFromParsedCorpus for the default
model.
projection_model : sklearn-style dimensionality reduction model.

Returns

str
HTML of visualization
Parameters corpus : ParsedCorpus It is highly recommended to use a stoplisted unigram corpus -- ` corpus . get_stoplisted_unigram_corpus () ` category : str word2vec_model : Word2Vec A gensim word2vec model . A default model will be used instead . See Word2VecFromParsedCorpus for the default model . projection_model : sklearn - style dimensionality reduction model . Returns str HTML of visualization
def produce_projection_explorer(corpus,
                                category,
                                word2vec_model=None,
                                projection_model=None,
                                embeddings=None,
                                term_acceptance_re=re.compile('[a-z]{3,}'),
                                show_axes=False,
                                **kwargs):
    embeddings_resolover = EmbeddingsResolver(corpus)
    if embeddings is not None:
        embeddings_resolover.set_embeddings(embeddings)
    else:
        embeddings_resolover.set_embeddings_model(word2vec_model, term_acceptance_re)
    corpus, word_axes = embeddings_resolover.project_embeddings(projection_model, x_dim=0, y_dim=1)
    html = produce_scattertext_explorer(
        corpus=corpus,
        category=category,
        minimum_term_frequency=0,
        sort_by_dist=False,
        x_coords=scale(word_axes['x']),
        y_coords=scale(word_axes['y']),
        y_label='',
        x_label='',
        show_axes=show_axes,
        **kwargs
    )
    return html
def produce_projection_explorer ( corpus , category , word2vec_model = None , projection_model = None , embeddings = None , term_acceptance_re = re . compile ( '[a-z]{3,}' ) , show_axes = False , ** kwargs ) : embeddings_resolover = EmbeddingsResolver ( corpus ) if embeddings is not None : embeddings_resolover . set_embeddings ( embeddings ) else : embeddings_resolover . set_embeddings_model ( word2vec_model , term_acceptance_re ) corpus , word_axes = embeddings_resolover . project_embeddings ( projection_model , x_dim = 0 , y_dim = 1 ) html = produce_scattertext_explorer ( corpus = corpus , category = category , minimum_term_frequency = 0 , sort_by_dist = False , x_coords = scale ( word_axes [ 'x' ] ) , y_coords = scale ( word_axes [ 'y' ] ) , y_label = '' , x_label = '' , show_axes = show_axes , ** kwargs ) return html
Parameters
corpus : ParsedCorpus
It is highly recommended to use a stoplisted, unigram corpus-- `corpus.get_stoplisted_unigram_corpus()`
category : str
word2vec_model : Word2Vec
A gensim word2vec model.
Parameters corpus : ParsedCorpus It is highly recommended to use a stoplisted unigram corpus -- ` corpus . get_stoplisted_unigram_corpus () ` category : str word2vec_model : Word2Vec A gensim word2vec model .
'''
    Parameters
    ----------
    corpus : ParsedCorpus
        It is highly recommended to use a stoplisted, unigram corpus-- `corpus.get_stoplisted_unigram_corpus()`
    category : str
    word2vec_model : Word2Vec
        A gensim word2vec model.  A default model will be used instead. See Word2VecFromParsedCorpus for the default
        model.
    projection_model : sklearn-style dimensionality reduction model.
        By default: umap.UMAP(min_dist=0.5, metric='cosine')
      You could also use, e.g., sklearn.manifold.TSNE(perplexity=10, n_components=2, init='pca', n_iter=2500, random_state=23)
    embeddings : array[len(corpus.get_terms()), X]
        Word embeddings.  If None (default), will train them using word2vec Model
    term_acceptance_re : SRE_Pattern,
        Regular expression to identify valid terms
    show_axes : bool, default False
        Show the ticked axes on the plot.  If false, show inner axes as a crosshair.
    kwargs : dict
        Remaining produce_scattertext_explorer keywords get_tooltip_content

    Returns
    -------
    str
    HTML of visualization

    '''
corpus
category
word2vec_model
projection_model
embeddings
term_acceptance_re
show_axes