-
Notifications
You must be signed in to change notification settings - Fork 289
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding in preliminary support for some extensions to Scattertext. Cod…
…e for an easier solution to Issue #56 present in `SpacyEntities`. Fixes to the TermDocMatrix modify-and-create-new functionality. Limit the number of overlapping terms displayed through the max_overlapping argument. Custom background frequencies are easier.
- Loading branch information
1 parent
42646d7
commit da7ac7c
Showing
11 changed files
with
33 additions
and
22 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
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
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_overlapping=3 | ||
) | ||
open('./demo_compact.html', 'w').write(html) | ||
print('open ./demo_compact.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