Search is not available for this dataset
text
stringlengths
75
104k
def manhattan(src, tar, qval=2, normalized=False, alphabet=None): """Return the Manhattan distance between two strings. This is a wrapper for :py:meth:`Manhattan.dist_abs`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target...
def dist_manhattan(src, tar, qval=2, alphabet=None): """Return the normalized Manhattan distance between two strings. This is a wrapper for :py:meth:`Manhattan.dist`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target strin...
def sim_manhattan(src, tar, qval=2, alphabet=None): """Return the normalized Manhattan similarity of two strings. This is a wrapper for :py:meth:`Manhattan.sim`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target string (or...
def sim_jaro_winkler( src, tar, qval=1, mode='winkler', long_strings=False, boost_threshold=0.7, scaling_factor=0.1, ): """Return the Jaro or Jaro-Winkler similarity of two strings. This is a wrapper for :py:meth:`JaroWinkler.sim`. Parameters ---------- src : str ...
def dist_jaro_winkler( src, tar, qval=1, mode='winkler', long_strings=False, boost_threshold=0.7, scaling_factor=0.1, ): """Return the Jaro or Jaro-Winkler distance between two strings. This is a wrapper for :py:meth:`JaroWinkler.dist`. Parameters ---------- src : str ...
def sim( self, src, tar, qval=1, mode='winkler', long_strings=False, boost_threshold=0.7, scaling_factor=0.1, ): """Return the Jaro or Jaro-Winkler similarity of two strings. Parameters ---------- src : str ...
def hamming(src, tar, diff_lens=True): """Return the Hamming distance between two strings. This is a wrapper for :py:meth:`Hamming.dist_abs`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison diff_lens : bool If True...
def dist_hamming(src, tar, diff_lens=True): """Return the normalized Hamming distance between two strings. This is a wrapper for :py:meth:`Hamming.dist`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison diff_lens : bool ...
def sim_hamming(src, tar, diff_lens=True): """Return the normalized Hamming similarity of two strings. This is a wrapper for :py:meth:`Hamming.sim`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison diff_lens : bool ...
def dist_abs(self, src, tar, diff_lens=True): """Return the Hamming distance between two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison diff_lens : bool If True (default), t...
def dist(self, src, tar, diff_lens=True): """Return the normalized Hamming distance between two strings. Hamming distance normalized to the interval [0, 1]. The Hamming distance is normalized by dividing it by the greater of the number of characters in src & tar (unless diff_le...
def encode(self, word, max_length=-1): """Return the Metaphone code for a word. Based on Lawrence Philips' Pick BASIC code from 1990 :cite:`Philips:1990`, as described in :cite:`Philips:1990b`. This incorporates some corrections to the above code, particularly some of those sugg...
def dolby(word, max_length=-1, keep_vowels=False, vowel_char='*'): r"""Return the Dolby Code of a name. This is a wrapper for :py:meth:`Dolby.encode`. Parameters ---------- word : str The word to transform max_length : int Maximum length of the returned Dolby code -- this also ...
def encode(self, word, max_length=-1, keep_vowels=False, vowel_char='*'): r"""Return the Dolby Code of a name. Parameters ---------- word : str The word to transform max_length : int Maximum length of the returned Dolby code -- this also activates ...
def pshp_soundex_last(lname, max_length=4, german=False): """Calculate the PSHP Soundex/Viewex Coding of a last name. This is a wrapper for :py:meth:`PSHPSoundexLast.encode`. Parameters ---------- lname : str The last name to encode max_length : int The length of the code retur...
def encode(self, lname, max_length=4, german=False): """Calculate the PSHP Soundex/Viewex Coding of a last name. Parameters ---------- lname : str The last name to encode max_length : int The length of the code returned (defaults to 4) german : bo...
def fingerprint(self, word): """Return the skeleton key. Parameters ---------- word : str The word to transform into its skeleton key Returns ------- str The skeleton key Examples -------- >>> sk = SkeletonKey() ...
def nysiis(word, max_length=6, modified=False): """Return the NYSIIS code for a word. This is a wrapper for :py:meth:`NYSIIS.encode`. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 6) of the code to return modified : bool...
def encode(self, word, max_length=6, modified=False): """Return the NYSIIS code for a word. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 6) of the code to return modified : bool In...
def chebyshev(src, tar, qval=2, alphabet=None): r"""Return the Chebyshev distance between two strings. This is a wrapper for the :py:meth:`Chebyshev.dist_abs`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target string (or Q...
def dist_abs(self, src, tar, qval=2, alphabet=None): r"""Return the Chebyshev distance between two strings. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target string (or QGrams/Counter objects) for co...
def mean_pairwise_similarity( collection, metric=sim, mean_func=hmean, symmetric=False ): """Calculate the mean pairwise similarity of a collection of strings. Takes the mean of the pairwise similarity between each member of a collection, optionally in both directions (for asymmetric similarity met...
def pairwise_similarity_statistics( src_collection, tar_collection, metric=sim, mean_func=amean, symmetric=False, ): """Calculate the pairwise similarity statistics a collection of strings. Calculate pairwise similarities among members of two collections, returning the maximum, minimum,...
def stem(self, word, early_english=False): """Return the Porter2 (Snowball English) stem. Parameters ---------- word : str The word to stem early_english : bool Set to True in order to remove -eth & -est (2nd & 3rd person singular verbal agree...
def synoname_toolcode(lname, fname='', qual='', normalize=0): """Build the Synoname toolcode. This is a wrapper for :py:meth:`SynonameToolcode.fingerprint`. Parameters ---------- lname : str Last name fname : str First name (can be blank) qual : str Qualifier no...
def fingerprint(self, lname, fname='', qual='', normalize=0): """Build the Synoname toolcode. Parameters ---------- lname : str Last name fname : str First name (can be blank) qual : str Qualifier normalize : int No...
def uealite( word, max_word_length=20, max_acro_length=8, return_rule_no=False, var='standard', ): """Return UEA-Lite stem. This is a wrapper for :py:meth:`UEALite.stem`. Parameters ---------- word : str The word to stem max_word_length : int The maximum wor...
def stem( self, word, max_word_length=20, max_acro_length=8, return_rule_no=False, var='standard', ): """Return UEA-Lite stem. Parameters ---------- word : str The word to stem max_word_length : int The ...
def _sb_r1(self, term, r1_prefixes=None): """Return the R1 region, as defined in the Porter2 specification. Parameters ---------- term : str The term to examine r1_prefixes : set Prefixes to consider Returns ------- int ...
def _sb_r2(self, term, r1_prefixes=None): """Return the R2 region, as defined in the Porter2 specification. Parameters ---------- term : str The term to examine r1_prefixes : set Prefixes to consider Returns ------- int ...
def _sb_ends_in_short_syllable(self, term): """Return True iff term ends in a short syllable. (...according to the Porter2 specification.) NB: This is akin to the CVC test from the Porter stemmer. The description is unfortunately poor/ambiguous. Parameters ---------- ...
def _sb_short_word(self, term, r1_prefixes=None): """Return True iff term is a short word. (...according to the Porter2 specification.) Parameters ---------- term : str The term to examine r1_prefixes : set Prefixes to consider Returns ...
def _sb_has_vowel(self, term): """Return Porter helper function _sb_has_vowel value. Parameters ---------- term : str The term to examine Returns ------- bool True iff a vowel exists in the term (as defined in the Porter stemm...
def encode(self, word, max_length=8): """Return the eudex phonetic hash of a word. Parameters ---------- word : str The word to transform max_length : int The length in bits of the code returned (default 8) Returns ------- int ...
def roger_root(word, max_length=5, zero_pad=True): """Return the Roger Root code for a word. This is a wrapper for :py:meth:`RogerRoot.encode`. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 5) of the code to return zero_...
def encode(self, word, max_length=5, zero_pad=True): """Return the Roger Root code for a word. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 5) of the code to return zero_pad : bool ...
def encode(self, word): """Return the Kölner Phonetik (numeric output) code for a word. While the output code is numeric, it is still a str because 0s can lead the code. Parameters ---------- word : str The word to transform Returns ------- ...
def _to_alpha(self, num): """Convert a Kölner Phonetik code from numeric to alphabetic. Parameters ---------- num : str or int A numeric Kölner Phonetik representation Returns ------- str An alphabetic representation of the same word ...
def main(argv): """Read input file and write to output. Parameters ---------- argv : list Arguments to the script """ first_col = 3 last_col = -1 def print_usage(): """Print usage statement.""" sys.stdout.write( 'features_csv_to_dict.py -i <inputfil...
def lein(word, max_length=4, zero_pad=True): """Return the Lein code for a word. This is a wrapper for :py:meth:`Lein.encode`. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 4) zero_pad : bool Pad...
def encode(self, word, max_length=4, zero_pad=True): """Return the Lein 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 Pad the en...
def _get_qgrams(self, src, tar, qval=0, skip=0): """Return the Q-Grams in src & tar. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target string (or QGrams/Counter objects) for comparison qval :...
def rle_encode(text, use_bwt=True): r"""Perform encoding of run-length-encoding (RLE). This is a wrapper for :py:meth:`RLE.encode`. Parameters ---------- text : str A text string to encode use_bwt : bool Indicates whether to perform BWT encoding before RLE encoding Returns...
def rle_decode(text, use_bwt=True): r"""Perform decoding of run-length-encoding (RLE). This is a wrapper for :py:meth:`RLE.decode`. Parameters ---------- text : str A text string to decode use_bwt : bool Indicates whether to perform BWT decoding after RLE decoding Returns ...
def encode(self, text): r"""Perform encoding of run-length-encoding (RLE). Parameters ---------- text : str A text string to encode Returns ------- str Word decoded by RLE Examples -------- >>> rle = RLE() ...
def decode(self, text): r"""Perform decoding of run-length-encoding (RLE). Parameters ---------- text : str A text string to decode Returns ------- str Word decoded by RLE Examples -------- >>> rle = RLE() ...
def encode(self, word, max_length=4): """Return the SoundD code. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 4) Returns ------- str The SoundD co...
def dist(self, src, tar): """Return the NCD between two strings using LZMA compression. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison Returns ------- float Compress...
def smith_waterman(src, tar, gap_cost=1, sim_func=sim_ident): """Return the Smith-Waterman score of two strings. This is a wrapper for :py:meth:`SmithWaterman.dist_abs`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison gap_...
def dist_abs(self, src, tar, gap_cost=1, sim_func=sim_ident): """Return the Smith-Waterman score of two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison gap_cost : float The c...
def levenshtein(src, tar, mode='lev', cost=(1, 1, 1, 1)): """Return the Levenshtein distance between two strings. This is a wrapper of :py:meth:`Levenshtein.dist_abs`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison mode :...
def dist_levenshtein(src, tar, mode='lev', cost=(1, 1, 1, 1)): """Return the normalized Levenshtein distance between two strings. This is a wrapper of :py:meth:`Levenshtein.dist`. Parameters ---------- src : str Source string for comparison tar : str Target string for compariso...
def sim_levenshtein(src, tar, mode='lev', cost=(1, 1, 1, 1)): """Return the Levenshtein similarity of two strings. This is a wrapper of :py:meth:`Levenshtein.sim`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison mode : str...
def dist_abs(self, src, tar, mode='lev', cost=(1, 1, 1, 1)): """Return the Levenshtein distance between two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison mode : str Specifi...
def dist(self, src, tar, mode='lev', cost=(1, 1, 1, 1)): """Return the normalized Levenshtein distance between two strings. The Levenshtein distance is normalized by dividing the Levenshtein distance (calculated by any of the three supported methods) by the greater of the number of char...
def fingerprint(self, word): """Return the omission key. Parameters ---------- word : str The word to transform into its omission key Returns ------- str The omission key Examples -------- >>> ok = OmissionKey() ...
def minkowski(src, tar, qval=2, pval=1, normalized=False, alphabet=None): """Return the Minkowski distance (:math:`L^p`-norm) of two strings. This is a wrapper for :py:meth:`Minkowski.dist_abs`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison ta...
def dist_minkowski(src, tar, qval=2, pval=1, alphabet=None): """Return normalized Minkowski distance of two strings. This is a wrapper for :py:meth:`Minkowski.dist`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target string...
def sim_minkowski(src, tar, qval=2, pval=1, alphabet=None): """Return normalized Minkowski similarity of two strings. This is a wrapper for :py:meth:`Minkowski.sim`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target string...
def dist_abs( self, src, tar, qval=2, pval=1, normalized=False, alphabet=None ): """Return the Minkowski distance (:math:`L^p`-norm) of two strings. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str ...
def dist(self, src, tar, qval=2, pval=1, alphabet=None): """Return normalized Minkowski distance of two strings. The normalized Minkowski distance :cite:`Minkowski:1910` is a distance metric in :math:`L^p`-space, normalized to [0, 1]. Parameters ---------- src : str ...
def occurrence_halved_fingerprint( word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG ): """Return the occurrence halved fingerprint. This is a wrapper for :py:meth:`OccurrenceHalved.fingerprint`. Parameters ---------- word : str The word to fingerprint n_bits : int Number...
def fingerprint(self, word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG): """Return the occurrence halved fingerprint. Based on the occurrence halved fingerprint from :cite:`Cislak:2017`. Parameters ---------- word : str The word to fingerprint n_bits : in...
def encode(self, word, max_length=3): """Calculate the early version of the Henry code for a word. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 3) Returns ------- ...
def pshp_soundex_first(fname, max_length=4, german=False): """Calculate the PSHP Soundex/Viewex Coding of a first name. This is a wrapper for :py:meth:`PSHPSoundexFirst.encode`. Parameters ---------- fname : str The first name to encode max_length : int The length of the code r...
def encode(self, fname, max_length=4, german=False): """Calculate the PSHP Soundex/Viewex Coding of a first name. Parameters ---------- fname : str The first name to encode max_length : int The length of the code returned (defaults to 4) german : ...
def c2u(name): """Convert camelCase (used in PHP) to Python-standard snake_case. Src: https://stackoverflow.com/questions/1175208/elegant-python-function-to-convert-camelcase-to-snake-case Parameters ---------- name: A function or variable name in camelCase Returns ------- str: Th...
def pythonize(line, fn='', subdir='gen'): """Convert a line of BMPM code from PHP to Python. Parameters ---------- line : str A line of code fn : str A filename subdir : str The file's subdirectory Returns ------- The code in Python """ glob...
def sim(self, src, tar, qval=2): r"""Return the cosine similarity of two strings. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target string (or QGrams/Counter objects) for comparison qval : in...
def sim_monge_elkan(src, tar, sim_func=sim_levenshtein, symmetric=False): """Return the Monge-Elkan similarity of two strings. This is a wrapper for :py:meth:`MongeElkan.sim`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison ...
def dist_monge_elkan(src, tar, sim_func=sim_levenshtein, symmetric=False): """Return the Monge-Elkan distance between two strings. This is a wrapper for :py:meth:`MongeElkan.dist`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparis...
def sim(self, src, tar, sim_func=sim_levenshtein, symmetric=False): """Return the Monge-Elkan similarity of two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison sim_func : function ...
def encode(self, word): """Return the Phonem code for a word. Parameters ---------- word : str The word to transform Returns ------- str The Phonem value Examples -------- >>> pe = Phonem() >>> pe.encode('Chri...
def stem(self, word): """Return CLEF Swedish stem. Parameters ---------- word : str The word to stem Returns ------- str Word stem Examples -------- >>> clef_swedish('undervisa') 'undervis' >>> cle...
def _undouble(self, word): """Undouble endings -kk, -dd, and -tt. Parameters ---------- word : str The word to stem Returns ------- str The word with doubled endings undoubled """ if ( len(word) > 1 ...
def stem(self, word): """Return Snowball Dutch stem. Parameters ---------- word : str The word to stem Returns ------- str Word stem Examples -------- >>> stmr = SnowballDutch() >>> stmr.stem('lezen') ...
def soundex(word, max_length=4, var='American', reverse=False, zero_pad=True): """Return the Soundex code for a word. This is a wrapper for :py:meth:`Soundex.encode`. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaul...
def encode( self, word, max_length=4, var='American', reverse=False, zero_pad=True ): """Return the Soundex code for a word. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 4...
def fingerprint(self, phrase, joiner=' '): """Return string fingerprint. Parameters ---------- phrase : str The string from which to calculate the fingerprint joiner : str The string that will be placed between each word Returns ------- ...
def encode(self, word): """Return the Russell Index (integer output) of a word. Parameters ---------- word : str The word to transform Returns ------- int The Russell Index value Examples -------- >>> pe = Russell...
def ipa_to_features(ipa): """Convert IPA to features. This translates an IPA string of one or more phones to a list of ints representing the features of the string. Parameters ---------- ipa : str The IPA representation of a phone or series of phones Returns ------- list o...
def get_feature(vector, feature): """Get a feature vector. This returns a list of ints, equal in length to the vector input, representing presence/absence/neutrality with respect to a particular phonetic feature. Parameters ---------- vector : list A tuple or list of ints r...
def cmp_features(feat1, feat2): """Compare features. This returns a number in the range [0, 1] representing a comparison of two feature bundles. If one of the bundles is negative, -1 is returned (for unknown values) If the bundles are identical, 1 is returned. If they are inverses of one ano...
def sim(self, src, tar): """Return the length similarity of two strings. Length similarity is the ratio of the length of the shorter string to the longer. Parameters ---------- src : str Source string for comparison tar : str Target strin...
def encode(self, word, version=2): """Return the Caverphone code for a word. Parameters ---------- word : str The word to transform version : int The version of Caverphone to employ for encoding (defaults to 2) Returns ------- str...
def hmean(nums): r"""Return harmonic mean. The harmonic mean is defined as: :math:`\frac{|nums|}{\sum\limits_{i}\frac{1}{nums_i}}` Following the behavior of Wolfram|Alpha: - If one of the values in nums is 0, return 0. - If more than one value in nums is 0, return NaN. Cf. https://en.wiki...
def lmean(nums): r"""Return logarithmic mean. The logarithmic mean of an arbitrarily long series is defined by http://www.survo.fi/papers/logmean.pdf as: :math:`L(x_1, x_2, ..., x_n) = (n-1)! \sum\limits_{i=1}^n \frac{x_i} {\prod\limits_{\substack{j = 1\\j \ne i}}^n ln \frac{x_i}{x_j}}`...
def imean(nums): r"""Return identric (exponential) mean. The identric mean of two numbers x and y is: x if x = y otherwise :math:`\frac{1}{e} \sqrt[x-y]{\frac{x^x}{y^y}}` Cf. https://en.wikipedia.org/wiki/Identric_mean Parameters ---------- nums : list A series of numbers ...
def seiffert_mean(nums): r"""Return Seiffert's mean. Seiffert's mean of two numbers x and y is: :math:`\frac{x - y}{4 \cdot arctan \sqrt{\frac{x}{y}} - \pi}` It is defined in :cite:`Seiffert:1993`. Parameters ---------- nums : list A series of numbers Returns ------- ...
def lehmer_mean(nums, exp=2): r"""Return Lehmer mean. The Lehmer mean is: :math:`\frac{\sum\limits_i{x_i^p}}{\sum\limits_i{x_i^(p-1)}}` Cf. https://en.wikipedia.org/wiki/Lehmer_mean Parameters ---------- nums : list A series of numbers exp : numeric The exponent of the...
def heronian_mean(nums): r"""Return Heronian mean. The Heronian mean is: :math:`\frac{\sum\limits_{i, j}\sqrt{{x_i \cdot x_j}}} {|nums| \cdot \frac{|nums| + 1}{2}}` for :math:`j \ge i` Cf. https://en.wikipedia.org/wiki/Heronian_mean Parameters ---------- nums : list A seri...
def hoelder_mean(nums, exp=2): r"""Return Hölder (power/generalized) mean. The Hölder mean is defined as: :math:`\sqrt[p]{\frac{1}{|nums|} \cdot \sum\limits_i{x_i^p}}` for :math:`p \ne 0`, and the geometric mean for :math:`p = 0` Cf. https://en.wikipedia.org/wiki/Generalized_mean Parameters ...
def agmean(nums): """Return arithmetic-geometric mean. Iterates between arithmetic & geometric means until they converge to a single value (rounded to 12 digits). Cf. https://en.wikipedia.org/wiki/Arithmetic-geometric_mean Parameters ---------- nums : list A series of numbers ...
def ghmean(nums): """Return geometric-harmonic mean. Iterates between geometric & harmonic means until they converge to a single value (rounded to 12 digits). Cf. https://en.wikipedia.org/wiki/Geometric-harmonic_mean Parameters ---------- nums : list A series of numbers Retur...
def aghmean(nums): """Return arithmetic-geometric-harmonic mean. Iterates over arithmetic, geometric, & harmonic means until they converge to a single value (rounded to 12 digits), following the method described in :cite:`Raissouli:2009`. Parameters ---------- nums : list A series ...
def median(nums): """Return median. With numbers sorted by value, the median is the middle value (if there is an odd number of values) or the arithmetic mean of the two middle values (if there is an even number of values). Cf. https://en.wikipedia.org/wiki/Median Parameters ---------- ...
def var(nums, mean_func=amean, ddof=0): r"""Calculate the variance. The variance (:math:`\sigma^2`) of a series of numbers (:math:`x_i`) with mean :math:`\mu` and population :math:`N` is: :math:`\sigma^2 = \frac{1}{N}\sum_{i=1}^{N}(x_i-\mu)^2`. Cf. https://en.wikipedia.org/wiki/Variance Para...
def stem(self, word): """Return the stem of a word according to the Schinke stemmer. Parameters ---------- word : str The word to stem Returns ------- str Word stem Examples -------- >>> stmr = Schinke() >...
def onca(word, max_length=4, zero_pad=True): """Return the Oxford Name Compression Algorithm (ONCA) code for a word. This is a wrapper for :py:meth:`ONCA.encode`. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 5) of the code ...
def encode(self, word, max_length=4, zero_pad=True): """Return the Oxford Name Compression Algorithm (ONCA) code for a word. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 5) of the code to return ...