INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Return Davidson s Consonant Code. | def davidson(lname, fname='.', omit_fname=False):
"""Return Davidson's Consonant Code.
This is a wrapper for :py:meth:`Davidson.encode`.
Parameters
----------
lname : str
Last name (or word) to be encoded
fname : str
First name (optional), of which the first character is includ... |
Return Davidson s Consonant Code. | def encode(self, lname, fname='.', omit_fname=False):
"""Return Davidson's Consonant Code.
Parameters
----------
lname : str
Last name (or word) to be encoded
fname : str
First name (optional), of which the first character is included in
the c... |
Encode a text using arithmetic coding with the provided probabilities. | def ac_encode(text, probs):
"""Encode a text using arithmetic coding with the provided probabilities.
This is a wrapper for :py:meth:`Arithmetic.encode`.
Parameters
----------
text : str
A string to encode
probs : dict
A probability statistics dictionary generated by
:p... |
Decode the number to a string using the given statistics. | def ac_decode(longval, nbits, probs):
"""Decode the number to a string using the given statistics.
This is a wrapper for :py:meth:`Arithmetic.decode`.
Parameters
----------
longval : int
The first part of an encoded tuple from ac_encode
nbits : int
The second part of an encoded... |
r Generate a probability dict from the provided text. | def train(self, text):
r"""Generate a probability dict from the provided text.
Text to 0-order probability statistics as a dict
Parameters
----------
text : str
The text data over which to calculate probability statistics. This
must not contain the NUL (... |
Encode a text using arithmetic coding. | def encode(self, text):
"""Encode a text using arithmetic coding.
Text and the 0-order probability statistics -> longval, nbits
The encoded number is Fraction(longval, 2**nbits)
Parameters
----------
text : str
A string to encode
Returns
--... |
Decode the number to a string using the given statistics. | def decode(self, longval, nbits):
"""Decode the number to a string using the given statistics.
Parameters
----------
longval : int
The first part of an encoded tuple from encode
nbits : int
The second part of an encoded tuple from encode
Returns
... |
Return the Fuzzy Soundex code for a word. | def fuzzy_soundex(word, max_length=5, zero_pad=True):
"""Return the Fuzzy Soundex code for a word.
This is a wrapper for :py:meth:`FuzzySoundex.encode`.
Parameters
----------
word : str
The word to transform
max_length : int
The length of the code returned (defaults to 4)
z... |
Return the Fuzzy Soundex code for a word. | def encode(self, word, max_length=5, zero_pad=True):
"""Return the Fuzzy Soundex code for a word.
Parameters
----------
word : str
The word to transform
max_length : int
The length of the code returned (defaults to 4)
zero_pad : bool
P... |
r Fill in self. ngcorpus from a Corpus argument. | def corpus_importer(self, corpus, n_val=1, bos='_START_', eos='_END_'):
r"""Fill in self.ngcorpus from a Corpus argument.
Parameters
----------
corpus :Corpus
The Corpus from which to initialize the n-gram corpus
n_val : int
Maximum n value for n-grams
... |
r Get the count of an n - gram in the corpus. | def get_count(self, ngram, corpus=None):
r"""Get the count of an n-gram in the corpus.
Parameters
----------
ngram : str
The n-gram to retrieve the count of from the n-gram corpus
corpus : Corpus
The corpus
Returns
-------
int
... |
Build up a corpus entry recursively. | def _add_to_ngcorpus(self, corpus, words, count):
"""Build up a corpus entry recursively.
Parameters
----------
corpus : Corpus
The corpus
words : [str]
Words to add to the corpus
count : int
Count of words
"""
if word... |
Fill in self. ngcorpus from a Google NGram corpus file. | def gng_importer(self, corpus_file):
"""Fill in self.ngcorpus from a Google NGram corpus file.
Parameters
----------
corpus_file : file
The Google NGram file from which to initialize the n-gram corpus
"""
with c_open(corpus_file, 'r', encoding='utf-8') as gn... |
r Return term frequency. | def tf(self, term):
r"""Return term frequency.
Parameters
----------
term : str
The term for which to calculate tf
Returns
-------
float
The term frequency (tf)
Raises
------
ValueError
tf can only cal... |
Return the Standardized Phonetic Frequency Code ( SPFC ) of a word. | def encode(self, word):
"""Return the Standardized Phonetic Frequency Code (SPFC) of a word.
Parameters
----------
word : str
The word to transform
Returns
-------
str
The SPFC value
Raises
------
AttributeError
... |
r Return the Burrows - Wheeler transformed form of a word. | def encode(self, word, terminator='\0'):
r"""Return the Burrows-Wheeler transformed form of a word.
Parameters
----------
word : str
The word to transform using BWT
terminator : str
A character added to signal the end of the string
Returns
... |
r Return a word decoded from BWT form. | def decode(self, code, terminator='\0'):
r"""Return a word decoded from BWT form.
Parameters
----------
code : str
The word to transform from BWT form
terminator : str
A character added to signal the end of the string
Returns
-------
... |
Return the indel distance between two strings. | def dist_abs(self, src, tar):
"""Return the indel distance between two strings.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
Returns
-------
int
Indel distance
... |
Return the normalized indel distance between two strings. | def dist(self, src, tar):
"""Return the normalized indel distance between two strings.
This is equivalent to normalized Levenshtein distance, when only
inserts and deletes are possible.
Parameters
----------
src : str
Source string for comparison
tar... |
Return the Haase Phonetik ( numeric output ) code for a word. | def encode(self, word, primary_only=False):
"""Return the Haase Phonetik (numeric output) code for a word.
While the output code is numeric, it is nevertheless a str.
Parameters
----------
word : str
The word to transform
primary_only : bool
If T... |
Return similarity. | def sim(self, src, tar, *args, **kwargs):
"""Return similarity.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
*args
Variable length argument list.
**kwargs
Arbit... |
Return absolute distance. | def dist_abs(self, src, tar, *args, **kwargs):
"""Return absolute distance.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
*args
Variable length argument list.
**kwargs
... |
Return the occurrence fingerprint. | def occurrence_fingerprint(
word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG
):
"""Return the occurrence fingerprint.
This is a wrapper for :py:meth:`Occurrence.fingerprint`.
Parameters
----------
word : str
The word to fingerprint
n_bits : int
Number of bits in the fing... |
Return the occurrence fingerprint. | def fingerprint(self, word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG):
"""Return the occurrence fingerprint.
Parameters
----------
word : str
The word to fingerprint
n_bits : int
Number of bits in the fingerprint returned
most_common : list
... |
Return the Baystat similarity. | def sim_baystat(src, tar, min_ss_len=None, left_ext=None, right_ext=None):
"""Return the Baystat similarity.
This is a wrapper for :py:meth:`Baystat.sim`.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
min_ss_len : int
... |
Return the Baystat distance. | def dist_baystat(src, tar, min_ss_len=None, left_ext=None, right_ext=None):
"""Return the Baystat distance.
This is a wrapper for :py:meth:`Baystat.dist`.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
min_ss_len : int
... |
Return the Baystat similarity. | def sim(self, src, tar, min_ss_len=None, left_ext=None, right_ext=None):
"""Return the Baystat similarity.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
min_ss_len : int
Minimum sub... |
Return the Tversky index of two strings. | def sim_tversky(src, tar, qval=2, alpha=1, beta=1, bias=None):
"""Return the Tversky index of two strings.
This is a wrapper for :py:meth:`Tversky.sim`.
Parameters
----------
src : str
Source string (or QGrams/Counter objects) for comparison
tar : str
Target string (or QGrams/C... |
Return the Tversky distance between two strings. | def dist_tversky(src, tar, qval=2, alpha=1, beta=1, bias=None):
"""Return the Tversky distance between two strings.
This is a wrapper for :py:meth:`Tversky.dist`.
Parameters
----------
src : str
Source string (or QGrams/Counter objects) for comparison
tar : str
Target string (o... |
Return the Tversky index of two strings. | def sim(self, src, tar, qval=2, alpha=1, beta=1, bias=None):
"""Return the Tversky index of two strings.
Parameters
----------
src : str
Source string (or QGrams/Counter objects) for comparison
tar : str
Target string (or QGrams/Counter objects) for compa... |
Return the longest common subsequence of two strings. | def lcsseq(self, src, tar):
"""Return the longest common subsequence of two strings.
Based on the dynamic programming algorithm from
http://rosettacode.org/wiki/Longest_common_subsequence
:cite:`rosettacode:2018b`. This is licensed GFDL 1.2.
Modifications include:
c... |
r Return the longest common subsequence similarity of two strings. | def sim(self, src, tar):
r"""Return the longest common subsequence similarity of two strings.
Longest common subsequence similarity (:math:`sim_{LCSseq}`).
This employs the LCSseq function to derive a similarity metric:
:math:`sim_{LCSseq}(s,t) = \frac{|LCSseq(s,t)|}{max(|s|, |t|)}`
... |
Return the prefix similarity of two strings. | def sim(self, src, tar):
"""Return the prefix similarity of two strings.
Prefix similarity is the ratio of the length of the shorter term that
exactly matches the longer term to the length of the shorter term,
beginning at the start of both terms.
Parameters
----------
... |
Return the count fingerprint. | def count_fingerprint(word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG):
"""Return the count fingerprint.
This is a wrapper for :py:meth:`Count.fingerprint`.
Parameters
----------
word : str
The word to fingerprint
n_bits : int
Number of bits in the fingerprint returned
... |
Return the count fingerprint. | def fingerprint(self, word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG):
"""Return the count fingerprint.
Parameters
----------
word : str
The word to fingerprint
n_bits : int
Number of bits in the fingerprint returned
most_common : list
... |
Return the phonetic fingerprint of a phrase. | def phonetic_fingerprint(
phrase, phonetic_algorithm=double_metaphone, joiner=' ', *args, **kwargs
):
"""Return the phonetic fingerprint of a phrase.
This is a wrapper for :py:meth:`Phonetic.fingerprint`.
Parameters
----------
phrase : str
The string from which to calculate the phoneti... |
Return the phonetic fingerprint of a phrase. | def fingerprint(
self,
phrase,
phonetic_algorithm=double_metaphone,
joiner=' ',
*args,
**kwargs
):
"""Return the phonetic fingerprint of a phrase.
Parameters
----------
phrase : str
The string from which to calculate the ph... |
r Return the docs in the corpus with sentences flattened. | def docs_of_words(self):
r"""Return the docs in the corpus, with sentences flattened.
Each list within the corpus represents all the words of that document.
Thus the sentence level of lists has been flattened.
Returns
-------
[[str]]
The docs in the corpus a... |
r Return the raw corpus. | def raw(self):
r"""Return the raw corpus.
This is reconstructed by joining sub-components with the corpus' split
characters
Returns
-------
str
The raw corpus
Example
-------
>>> tqbf = 'The quick brown fox jumped over the lazy dog.\... |
r Calculate the Inverse Document Frequency of a term in the corpus. | def idf(self, term, transform=None):
r"""Calculate the Inverse Document Frequency of a term in the corpus.
Parameters
----------
term : str
The term to calculate the IDF of
transform : function
A function to apply to each document term before checking for... |
Return Paice - Husk stem. | def stem(self, word):
"""Return Paice-Husk stem.
Parameters
----------
word : str
The word to stem
Returns
-------
str
Word stem
Examples
--------
>>> stmr = PaiceHusk()
>>> stmr.stem('assumption')
... |
Return Reth - Schek Phonetik code for a word. | def encode(self, word):
"""Return Reth-Schek Phonetik code for a word.
Parameters
----------
word : str
The word to transform
Returns
-------
str
The Reth-Schek Phonetik code
Examples
--------
>>> reth_schek_phone... |
Return the SfinxBis code for a word. | def encode(self, word, max_length=-1):
"""Return the SfinxBis code for a word.
Parameters
----------
word : str
The word to transform
max_length : int
The length of the code returned (defaults to unlimited)
Returns
-------
tuple
... |
Return the Beider - Morse Phonetic Matching encoding ( s ) of a term. | def bmpm(
word,
language_arg=0,
name_mode='gen',
match_mode='approx',
concat=False,
filter_langs=False,
):
"""Return the Beider-Morse Phonetic Matching encoding(s) of a term.
This is a wrapper for :py:meth:`BeiderMorse.encode`.
Parameters
----------
word : str
The w... |
Return the best guess language ID for the word and language choices. | def _language(self, name, name_mode):
"""Return the best guess language ID for the word and language choices.
Parameters
----------
name : str
The term to guess the language of
name_mode : str
The name mode of the algorithm: ``gen`` (default),
... |
Reassess the language of the terms and call the phonetic encoder. | def _redo_language(
self, term, name_mode, rules, final_rules1, final_rules2, concat
):
"""Reassess the language of the terms and call the phonetic encoder.
Uses a split multi-word term.
Parameters
----------
term : str
The term to encode via Beider-Mors... |
Return the Beider - Morse encoding ( s ) of a term. | def _phonetic(
self,
term,
name_mode,
rules,
final_rules1,
final_rules2,
language_arg=0,
concat=False,
):
"""Return the Beider-Morse encoding(s) of a term.
Parameters
----------
term : str
The term to encode... |
Apply a set of final rules to the phonetic encoding. | def _apply_final_rules(self, phonetic, final_rules, language_arg, strip):
"""Apply a set of final rules to the phonetic encoding.
Parameters
----------
phonetic : str
The term to which to apply the final rules
final_rules : tuple
The set of final phonetic... |
Expand phonetic alternates separated by |s. | def _expand_alternates(self, phonetic):
"""Expand phonetic alternates separated by |s.
Parameters
----------
phonetic : str
A Beider-Morse phonetic encoding
Returns
-------
str
A Beider-Morse phonetic code
"""
alt_start =... |
Join prefixes & suffixes in cases of alternate phonetic values. | def _pnums_with_leading_space(self, phonetic):
"""Join prefixes & suffixes in cases of alternate phonetic values.
Parameters
----------
phonetic : str
A Beider-Morse phonetic encoding
Returns
-------
str
A Beider-Morse phonetic code
... |
Prepare & join phonetic numbers. | def _phonetic_numbers(self, phonetic):
"""Prepare & join phonetic numbers.
Split phonetic value on '-', run through _pnums_with_leading_space,
and join with ' '
Parameters
----------
phonetic : str
A Beider-Morse phonetic encoding
Returns
--... |
Remove duplicates from a phonetic encoding list. | def _remove_dupes(self, phonetic):
"""Remove duplicates from a phonetic encoding list.
Parameters
----------
phonetic : str
A Beider-Morse phonetic encoding
Returns
-------
str
A Beider-Morse phonetic code
"""
alt_string ... |
Remove embedded bracketed attributes. | def _normalize_lang_attrs(self, text, strip):
"""Remove embedded bracketed attributes.
This (potentially) bitwise-ands bracketed attributes together and adds
to the end.
This is applied to a single alternative at a time -- not to a
parenthesized list.
It removes all embe... |
Apply a phonetic regex if compatible. | def _apply_rule_if_compat(self, phonetic, target, language_arg):
"""Apply a phonetic regex if compatible.
tests for compatible language rules
to do so, apply the rule, expand the results, and detect alternatives
with incompatible attributes
then drop each alternative that ... |
Return the index value for a language code. | def _language_index_from_code(self, code, name_mode):
"""Return the index value for a language code.
This returns l_any if more than one code is specified or the code is
out of bounds.
Parameters
----------
code : int
The language code to interpret
n... |
Return the Beider - Morse Phonetic Matching encoding ( s ) of a term. | def encode(
self,
word,
language_arg=0,
name_mode='gen',
match_mode='approx',
concat=False,
filter_langs=False,
):
"""Return the Beider-Morse Phonetic Matching encoding(s) of a term.
Parameters
----------
word : str
... |
Return the strcmp95 similarity of two strings. | def sim_strcmp95(src, tar, long_strings=False):
"""Return the strcmp95 similarity of two strings.
This is a wrapper for :py:meth:`Strcmp95.sim`.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
long_strings : bool
S... |
Return the strcmp95 distance between two strings. | def dist_strcmp95(src, tar, long_strings=False):
"""Return the strcmp95 distance between two strings.
This is a wrapper for :py:meth:`Strcmp95.dist`.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
long_strings : bool
... |
Return the strcmp95 similarity of two strings. | def sim(self, src, tar, long_strings=False):
"""Return the strcmp95 similarity of two strings.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
long_strings : bool
Set to True to incre... |
Return the Naval Research Laboratory phonetic encoding of a word. | def encode(self, word):
"""Return the Naval Research Laboratory phonetic encoding of a word.
Parameters
----------
word : str
The word to transform
Returns
-------
str
The NRL phonetic encoding
Examples
--------
>... |
Return the longest common substring of two strings. | def lcsstr(self, src, tar):
"""Return the longest common substring of two strings.
Longest common substring (LCSstr).
Based on the code from
https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Longest_common_substring
:cite:`Wikibooks:2018`.
This is licensed ... |
r Return the longest common substring similarity of two strings. | def sim(self, src, tar):
r"""Return the longest common substring similarity of two strings.
Longest common substring similarity (:math:`sim_{LCSstr}`).
This employs the LCS function to derive a similarity metric:
:math:`sim_{LCSstr}(s,t) = \frac{|LCSstr(s,t)|}{max(|s|, |t|)}`
... |
Return the Needleman - Wunsch score of two strings. | def needleman_wunsch(src, tar, gap_cost=1, sim_func=sim_ident):
"""Return the Needleman-Wunsch score of two strings.
This is a wrapper for :py:meth:`NeedlemanWunsch.dist_abs`.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
... |
Return the matrix similarity of two strings. | def sim_matrix(
src,
tar,
mat=None,
mismatch_cost=0,
match_cost=1,
symmetric=True,
alphabet=None,
):
"""Return the matrix similarity of two strings.
With the default parameters, this is identical to sim_ident.
It is possible for sim_ma... |
Return the IBM Alpha Search Inquiry System code for a word. | def encode(self, word, max_length=14):
"""Return the IBM Alpha Search Inquiry System code for a word.
A collection is necessary as the return type since there can be
multiple values for a single word. But the collection must be ordered
since the first value is the primary coding.
... |
Return the PhoneticSpanish coding of word. | def encode(self, word, max_length=-1):
"""Return the PhoneticSpanish coding of word.
Parameters
----------
word : str
The word to transform
max_length : int
The length of the code returned (defaults to unlimited)
Returns
-------
s... |
Return Q - Gram fingerprint. | def qgram_fingerprint(phrase, qval=2, start_stop='', joiner=''):
"""Return Q-Gram fingerprint.
This is a wrapper for :py:meth:`QGram.fingerprint`.
Parameters
----------
phrase : str
The string from which to calculate the q-gram fingerprint
qval : int
The length of each q-gram (... |
Return Q - Gram fingerprint. | def fingerprint(self, phrase, qval=2, start_stop='', joiner=''):
"""Return Q-Gram fingerprint.
Parameters
----------
phrase : str
The string from which to calculate the q-gram fingerprint
qval : int
The length of each q-gram (by default 2)
start_s... |
Return the NCD between two strings using BWT plus RLE. | def dist(self, src, tar):
"""Return the NCD between two strings using BWT plus RLE.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
Returns
-------
float
Compression ... |
Return the Daitch - Mokotoff Soundex code for a word. | def dm_soundex(word, max_length=6, zero_pad=True):
"""Return the Daitch-Mokotoff Soundex code for a word.
This is a wrapper for :py:meth:`DaitchMokotoff.encode`.
Parameters
----------
word : str
The word to transform
max_length : int
The length of the code returned (defaults to... |
Return the Daitch - Mokotoff Soundex code for a word. | def encode(self, word, max_length=6, zero_pad=True):
"""Return the Daitch-Mokotoff Soundex code for a word.
Parameters
----------
word : str
The word to transform
max_length : int
The length of the code returned (defaults to 6; must be between 6
... |
Return the Norphone code. | def encode(self, word):
"""Return the Norphone code.
Parameters
----------
word : str
The word to transform
Returns
-------
str
The Norphone code
Examples
--------
>>> pe = Norphone()
>>> pe.encode('Hansen... |
Cast to tuple. | def to_tuple(self):
"""Cast to tuple.
Returns
-------
tuple
The confusion table as a 4-tuple (tp, tn, fp, fn)
Example
-------
>>> ct = ConfusionTable(120, 60, 20, 30)
>>> ct.to_tuple()
(120, 60, 20, 30)
"""
return sel... |
Cast to dict. | def to_dict(self):
"""Cast to dict.
Returns
-------
dict
The confusion table as a dict
Example
-------
>>> ct = ConfusionTable(120, 60, 20, 30)
>>> import pprint
>>> pprint.pprint(ct.to_dict())
{'fn': 30, 'fp': 20, 'tn': 60, '... |
Return population N. | def population(self):
"""Return population, N.
Returns
-------
int
The population (N) of the confusion table
Example
-------
>>> ct = ConfusionTable(120, 60, 20, 30)
>>> ct.population()
230
"""
return self._tp + self.... |
r Return precision. | def precision(self):
r"""Return precision.
Precision is defined as :math:`\frac{tp}{tp + fp}`
AKA positive predictive value (PPV)
Cf. https://en.wikipedia.org/wiki/Precision_and_recall
Cf. https://en.wikipedia.org/wiki/Information_retrieval#Precision
Returns
... |
r Return gain in precision. | def precision_gain(self):
r"""Return gain in precision.
The gain in precision is defined as:
:math:`G(precision) = \frac{precision}{random~ precision}`
Cf. https://en.wikipedia.org/wiki/Gain_(information_retrieval)
Returns
-------
float
The gain in ... |
r Return recall. | def recall(self):
r"""Return recall.
Recall is defined as :math:`\frac{tp}{tp + fn}`
AKA sensitivity
AKA true positive rate (TPR)
Cf. https://en.wikipedia.org/wiki/Precision_and_recall
Cf. https://en.wikipedia.org/wiki/Sensitivity_(test)
Cf. https://en.wikip... |
r Return specificity. | def specificity(self):
r"""Return specificity.
Specificity is defined as :math:`\frac{tn}{tn + fp}`
AKA true negative rate (TNR)
Cf. https://en.wikipedia.org/wiki/Specificity_(tests)
Returns
-------
float
The specificity of the confusion table
... |
r Return negative predictive value ( NPV ). | def npv(self):
r"""Return negative predictive value (NPV).
NPV is defined as :math:`\frac{tn}{tn + fn}`
Cf. https://en.wikipedia.org/wiki/Negative_predictive_value
Returns
-------
float
The negative predictive value of the confusion table
Example
... |
r Return fall - out. | def fallout(self):
r"""Return fall-out.
Fall-out is defined as :math:`\frac{fp}{fp + tn}`
AKA false positive rate (FPR)
Cf. https://en.wikipedia.org/wiki/Information_retrieval#Fall-out
Returns
-------
float
The fall-out of the confusion table
... |
r Return false discovery rate ( FDR ). | def fdr(self):
r"""Return false discovery rate (FDR).
False discovery rate is defined as :math:`\frac{fp}{fp + tp}`
Cf. https://en.wikipedia.org/wiki/False_discovery_rate
Returns
-------
float
The false discovery rate of the confusion table
Example... |
r Return accuracy. | def accuracy(self):
r"""Return accuracy.
Accuracy is defined as :math:`\frac{tp + tn}{population}`
Cf. https://en.wikipedia.org/wiki/Accuracy
Returns
-------
float
The accuracy of the confusion table
Example
-------
>>> ct = Confusi... |
r Return gain in accuracy. | def accuracy_gain(self):
r"""Return gain in accuracy.
The gain in accuracy is defined as:
:math:`G(accuracy) = \frac{accuracy}{random~ accuracy}`
Cf. https://en.wikipedia.org/wiki/Gain_(information_retrieval)
Returns
-------
float
The gain in accura... |
r Return logarithmic mean of precision & recall. | def pr_lmean(self):
r"""Return logarithmic mean of precision & recall.
The logarithmic mean is:
0 if either precision or recall is 0,
the precision if they are equal,
otherwise :math:`\frac{precision - recall}
{ln(precision) - ln(recall)}`
Cf. https://en.wikiped... |
r Return: math: F_ { \ beta } score. | def fbeta_score(self, beta=1.0):
r"""Return :math:`F_{\beta}` score.
:math:`F_{\beta}` for a positive real value :math:`\beta` "measures
the effectiveness of retrieval with respect to a user who
attaches :math:`\beta` times as much importance to recall as
precision" (van Rijsber... |
r Return Matthews correlation coefficient ( MCC ). | def mcc(self):
r"""Return Matthews correlation coefficient (MCC).
The Matthews correlation coefficient is defined in
:cite:`Matthews:1975` as:
:math:`\frac{(tp \cdot tn) - (fp \cdot fn)}
{\sqrt{(tp + fp)(tp + fn)(tn + fp)(tn + fn)}}`
This is equivalent to the geometric ... |
r Return the significance: math: \ chi^ { 2 }. | def significance(self):
r"""Return the significance, :math:`\chi^{2}`.
Significance is defined as:
:math:`\chi^{2} =
\frac{(tp \cdot tn - fp \cdot fn)^{2} (tp + tn + fp + fn)}
{((tp + fp)(tp + fn)(tn + fp)(tn + fn)}`
Also: :math:`\chi^{2} = MCC^{2} \cdot n`
Cf.... |
r Return κ statistic. | def kappa_statistic(self):
r"""Return κ statistic.
The κ statistic is defined as:
:math:`\kappa = \frac{accuracy - random~ accuracy}
{1 - random~ accuracy}`
The κ statistic compares the performance of the classifier relative to
the performance of a random classifier. :m... |
Return the Double Metaphone code for a word. | def encode(self, word, max_length=-1):
"""Return the Double Metaphone code for a word.
Parameters
----------
word : str
The word to transform
max_length : int
The maximum length of the returned Double Metaphone codes (defaults
to unlmited, but... |
Return CLEF German stem. | def stem(self, word):
"""Return CLEF German stem.
Parameters
----------
word : str
The word to stem
Returns
-------
str
Word stem
Examples
--------
>>> stmr = CLEFGerman()
>>> stmr.stem('lesen')
'l... |
Return the phonet code for a word. | def encode(self, word, mode=1, lang='de'):
"""Return the phonet code for a word.
Parameters
----------
word : str
The word to transform
mode : int
The ponet variant to employ (1 or 2)
lang : str
``de`` (default) for German, ``none`` fo... |
Return Snowball Danish stem. | def stem(self, word):
"""Return Snowball Danish stem.
Parameters
----------
word : str
The word to stem
Returns
-------
str
Word stem
Examples
--------
>>> stmr = SnowballDanish()
>>> stmr.stem('underviser... |
Return Snowball German stem. | def stem(self, word, alternate_vowels=False):
"""Return Snowball German stem.
Parameters
----------
word : str
The word to stem
alternate_vowels : bool
Composes ae as ä, oe as ö, and ue as ü before running the algorithm
Returns
-------
... |
Return the simplest Sift4 distance between two terms. | def dist_abs(self, src, tar, max_offset=5):
"""Return the "simplest" Sift4 distance between two terms.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
max_offset : int
The number of c... |
Return the typo distance between two strings. | def typo(src, tar, metric='euclidean', cost=(1, 1, 0.5, 0.5), layout='QWERTY'):
"""Return the typo distance between two strings.
This is a wrapper for :py:meth:`Typo.typo`.
Parameters
----------
src : str
Source string for comparison
tar : str
Target string for comparison
m... |
Return the normalized typo distance between two strings. | def dist_typo(
src, tar, metric='euclidean', cost=(1, 1, 0.5, 0.5), layout='QWERTY'
):
"""Return the normalized typo distance between two strings.
This is a wrapper for :py:meth:`Typo.dist`.
Parameters
----------
src : str
Source string for comparison
tar : str
Target strin... |
Return the normalized typo similarity between two strings. | def sim_typo(
src, tar, metric='euclidean', cost=(1, 1, 0.5, 0.5), layout='QWERTY'
):
"""Return the normalized typo similarity between two strings.
This is a wrapper for :py:meth:`Typo.sim`.
Parameters
----------
src : str
Source string for comparison
tar : str
Target strin... |
Return the typo distance between two strings. | def dist_abs(
self,
src,
tar,
metric='euclidean',
cost=(1, 1, 0.5, 0.5),
layout='QWERTY',
):
"""Return the typo distance between two strings.
Parameters
----------
src : str
Source string for comparison
tar : str
... |
Return the normalized typo distance between two strings. | def dist(
self,
src,
tar,
metric='euclidean',
cost=(1, 1, 0.5, 0.5),
layout='QWERTY',
):
"""Return the normalized typo distance between two strings.
This is typo distance, normalized to [0, 1].
Parameters
----------
src : str
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.