Gismo#
Tools to make gismos. WIP
- class gismap.gismo.GismoLab(lab, ngram_range=(1, 3), stop_words=None)[source]#
Cross-embedding of a lab’s authors and the words of their publications.
Built on Gismo’s
XGismo, it relates authors to the vocabulary of their work, so a single object answers keyword queries by topic, by author, by group, or for the whole lab. Building it embeds every publication twice (words and authors), so reuse one instance across queries rather than rebuilding per call (e.g.LabMap.wordcloudrebuilds each time).- Parameters:
- keywords(query=None, group=None, y=True, k=50, threshold=50, length_impact=0.1)[source]#
Return ranked
(word, weight)pairs, with near-duplicate n-grams merged.- Parameters:
query (
strorlist, optional) – A text query (y=True), or a list of author keys (y=False). Defaults to the whole lab (empty query).group (
str, optional) – Restrict to the authors of this group (overridesquery).y – Ranking and de-duplication tuning (see Gismo / similarity_matrix).
k – Ranking and de-duplication tuning (see Gismo / similarity_matrix).
threshold – Ranking and de-duplication tuning (see Gismo / similarity_matrix).
length_impact – Ranking and de-duplication tuning (see Gismo / similarity_matrix).
- wordcloud(query=None, group=None, **kwargs)[source]#
Like
keywords(), but wrapped in a renderableWordCloud.
- class gismap.gismo.WordCloud(words, title=None)[source]#
A set of
(word, weight)pairs with a self-contained HTML rendering.Displays natively in notebooks via
_repr_html_(font size and colour follow the weight);to_html()/save_html()produce a standalone snippet with no external dependency.- Parameters:
- gismap.gismo.make_post_publi(lab)[source]#
Hook to turn publication key stored in a corpus into actual publication.
- Parameters:
lab (
LabMap) – Lab that contains the corpus publications.- Return type:
callable
- gismap.gismo.publication_author_keys(pub)[source]#
Author keys of a publication (the tokens of the author-side embedding).
- gismap.gismo.publication_text(pub)[source]#
Text used for keyword extraction: title plus the first available abstract.
- Parameters:
pub (
Publication) – A publication (typically aSourcedPublication).- Return type:
- class gismap.search.Search(gismo, action_list, post=None, corrector=True)[source]#
Builds a gismo search engine.
- Parameters:
gismo (
Gismo) – Gismo to use.action_list (
list) – List of actions to perform.post (callable, optional) – Output transformation.
corrector (
Bool, default=True) – Implement word correction.
- class gismap.search.SearchAction(name=None, post=None)[source]#
Base class for extracting search results from a Gismo.
Subclasses should implement
process()to define how to extract results from the gismo.- Parameters:
name (
str, optional) – Name of this action (used as key in results dict).post (callable, optional) – Post-processing function applied to results.
- class gismap.search.SearchDocuments(name='articles', post=None, k=5)[source]#
Gives k best covering articles.
- class gismap.search.SearchLandmarks(name='landmarks', post=None, lmks=None)[source]#
Gives best landmarks.
- gismap.search.publi_to_html(publi)[source]#
Convert a publication to an HTML list item.
- Parameters:
publi (
Publication) – Publication to convert.- Returns:
HTML list item string.
- Return type:
- gismap.search.publis_to_html(publis)[source]#
Convert a list of publications to an HTML unordered list.