Utils#
Various functions and classes.
Common#
All-purpose functions.
- gismap.utils.common.get_classes(root, key='name')[source]#
- Parameters:
root (
class
) – Starting class (can be abstract).key (
str
, default=’name’) – Attribute to look-up
- Returns:
Dictionaries of all subclasses that have a key attribute (as in class attribute key).
- Return type:
Examples
>>> from gismap.sources.models import DB >>> subclasses = get_classes(DB, key='db_name') >>> dict(sorted(subclasses.items())) {'dblp': <class 'gismap.sources.dblp.DBLP'>, 'hal': <class 'gismap.sources.hal.HAL'>}
Requests#
Functions related to the requests
.
Logger#
Keep track of things that go wrong.
- gismap.utils.logger.logger = <Logger GisMap (WARNING)>#
Default logging interface.
Text#
Text manipulation tools.
- class gismap.utils.text.Corrector(voc, score_cutoff=20, min_length=3)[source]#
A simple word corrector base on input vocabulary. Short words are discarded.
- Parameters:
Examples
>>> vocabulary = ['My Taylor Swift is Rich'] >>> phrase = "How riche ise Tailor Swyft" >>> cor = Corrector(vocabulary, min_length=4) >>> cor(phrase) 'How rich ise taylor swift' >>> cor = Corrector(vocabulary, min_length=2) >>> cor(phrase) 'How rich is taylor swift'