-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding in code to ensure that term statistics will show up even if no…
… documents are present in visualization.
- Loading branch information
1 parent
83c5db8
commit 948d244
Showing
6 changed files
with
43 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import scattertext as st | ||
|
||
df = st.SampleCorpora.ConventionData2012.get_data().assign( | ||
parse=lambda df: df.text.apply(st.whitespace_nlp_with_sentences) | ||
) | ||
|
||
corpus = st.CorpusFromParsedDocuments( | ||
df, category_col='party', parsed_col='parse' | ||
).build().get_unigram_corpus().compact(st.AssociationCompactor(2000)) | ||
|
||
html = st.produce_scattertext_explorer( | ||
corpus, | ||
category='democrat', | ||
category_name='Democratic', | ||
not_category_name='Republican', | ||
minimum_term_frequency=0, pmi_threshold_coefficient=0, | ||
width_in_pixels=1000, metadata=corpus.get_df()['speaker'], | ||
transform=st.Scalers.dense_rank, | ||
max_docs_per_category=0 | ||
) | ||
open('./demo_compact_suppress_documents.html', 'w').write(html) | ||
print('open ./demo_compact_suppress_documents.html in Chrome') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters