Search is not available for this dataset
text
stringlengths
75
104k
def phonix(word, max_length=4, zero_pad=True): """Return the Phonix code for a word. This is a wrapper for :py:meth:`Phonix.encode`. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 4) zero_pad : bool ...
def encode(self, word, max_length=4, zero_pad=True): """Return the Phonix 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 ...
def editex(src, tar, cost=(0, 1, 2), local=False): """Return the Editex distance between two strings. This is a wrapper for :py:meth:`Editex.dist_abs`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison cost : tuple A...
def dist_editex(src, tar, cost=(0, 1, 2), local=False): """Return the normalized Editex distance between two strings. This is a wrapper for :py:meth:`Editex.dist`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison cost : tup...
def sim_editex(src, tar, cost=(0, 1, 2), local=False): """Return the normalized Editex similarity of two strings. This is a wrapper for :py:meth:`Editex.sim`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison cost : tuple ...
def dist_abs(self, src, tar, cost=(0, 1, 2), local=False): """Return the Editex distance between two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison cost : tuple A 3-tuple re...
def dist(self, src, tar, cost=(0, 1, 2), local=False): """Return the normalized Editex distance between two strings. The Editex distance is normalized by dividing the Editex distance (calculated by any of the three supported methods) by the greater of the number of characters in src tim...
def position_fingerprint( word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG, bits_per_letter=3 ): """Return the position fingerprint. This is a wrapper for :py:meth:`Position.fingerprint`. Parameters ---------- word : str The word to fingerprint n_bits : int Number of bit...
def fingerprint( self, word, n_bits=16, most_common=MOST_COMMON_LETTERS_CG, bits_per_letter=3, ): """Return the position fingerprint. Parameters ---------- word : str The word to fingerprint n_bits : int Number ...
def stem(self, word): """Return Caumanns German stem. Parameters ---------- word : str The word to stem Returns ------- str Word stem Examples -------- >>> stmr = Caumanns() >>> stmr.stem('lesen') ...
def dist(self, src, tar, probs=None): """Return the NCD between two strings using arithmetic coding. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison probs : dict A dictionary trained ...
def readfile(fn): """Read fn and return the contents. Parameters ---------- fn : str A filename Returns ------- str The content of the file """ with open(path.join(HERE, fn), 'r', encoding='utf-8') as f: return f.read()
def spanish_metaphone(word, max_length=6, modified=False): """Return the Spanish Metaphone of a word. This is a wrapper for :py:meth:`SpanishMetaphone.encode`. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 6...
def encode(self, word, max_length=6, modified=False): """Return the Spanish Metaphone of a word. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 6) modified : bool Se...
def encode(self, word): """Return the FONEM code of a word. Parameters ---------- word : str The word to transform Returns ------- str The FONEM code Examples -------- >>> pe = FONEM() >>> pe.encode('March...
def encode(self, word, max_length=4): """Return the Statistics Canada code for a word. Parameters ---------- word : str The word to transform max_length : int The maximum length (default 4) of the code to return Returns ------- st...
def synoname( src, tar, word_approx_min=0.3, char_approx_min=0.73, tests=2 ** 12 - 1, ret_name=False, ): """Return the Synoname similarity type of two words. This is a wrapper for :py:meth:`Synoname.dist_abs`. Parameters ---------- src : str Source string for compar...
def _synoname_strip_punct(self, word): """Return a word with punctuation stripped out. Parameters ---------- word : str A word to strip punctuation from Returns ------- str The word stripped of punctuation Examples ------...
def _synoname_word_approximation( self, src_ln, tar_ln, src_fn='', tar_fn='', features=None ): """Return the Synoname word approximation score for two names. Parameters ---------- src_ln : str Last name of the source tar_ln : str Last name of ...
def dist_abs( self, src, tar, word_approx_min=0.3, char_approx_min=0.73, tests=2 ** 12 - 1, ret_name=False, ): """Return the Synoname similarity type of two words. Parameters ---------- src : str Source string for c...
def dist( self, src, tar, word_approx_min=0.3, char_approx_min=0.73, tests=2 ** 12 - 1, ): """Return the normalized Synoname distance between two words. Parameters ---------- src : str Source string for comparison t...
def sim(self, src, tar, qval=2): r"""Return the Jaccard 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 : i...
def tanimoto_coeff(self, src, tar, qval=2): """Return the Tanimoto distance between two strings. Tanimoto distance :cite:`Tanimoto:1958` is :math:`-log_{2} sim_{Tanimoto}(X, Y)`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for c...
def sift4_common(src, tar, max_offset=5, max_distance=0): """Return the "common" Sift4 distance between two terms. This is a wrapper for :py:meth:`Sift4.dist_abs`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison max_offset...
def dist_sift4(src, tar, max_offset=5, max_distance=0): """Return the normalized "common" Sift4 distance between two terms. This is a wrapper for :py:meth:`Sift4.dist`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison max_o...
def sim_sift4(src, tar, max_offset=5, max_distance=0): """Return the normalized "common" Sift4 similarity of two terms. This is a wrapper for :py:meth:`Sift4.sim`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison max_offset...
def dist_abs(self, src, tar, max_offset=5, max_distance=0): """Return the "common" Sift4 distance between two terms. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison max_offset : int T...
def dist(self, src, tar, max_offset=5, max_distance=0): """Return the normalized "common" Sift4 distance between two terms. This is Sift4 distance, normalized to [0, 1]. Parameters ---------- src : str Source string for comparison tar : str Targe...
def dist(self, src, tar): """Return the NCD between two strings using bzip2 compression. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison Returns ------- float Compres...
def encode(self, word, lang='en'): """Return the MetaSoundex code for a word. Parameters ---------- word : str The word to transform lang : str Either ``en`` for English or ``es`` for Spanish Returns ------- str The Me...
def stem(self, word): """Return the S-stemmed form of a word. Parameters ---------- word : str The word to stem Returns ------- str Word stem Examples -------- >>> stmr = SStemmer() >>> stmr.stem('summarie...
def sim(self, src, tar): """Return the Ratcliff-Obershelp similarity of two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison Returns ------- float Ratcliff-Ob...
def refined_soundex(word, max_length=-1, zero_pad=False, retain_vowels=False): """Return the Refined Soundex code for a word. This is a wrapper for :py:meth:`RefinedSoundex.encode`. Parameters ---------- word : str The word to transform max_length : int The length of the code r...
def encode(self, word, max_length=-1, zero_pad=False, retain_vowels=False): """Return the Refined Soundex code for a word. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to unlimited) ...
def dist_abs(self, src, tar): """Return the MRA comparison rating of two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison Returns ------- int MRA comparison r...
def encode(self, word): """Return the Parmar-Kumbharana encoding of a word. Parameters ---------- word : str The word to transform Returns ------- str The Parmar-Kumbharana encoding Examples -------- >>> pe = Parm...
def eudex_hamming( src, tar, weights='exponential', max_length=8, normalized=False ): """Calculate the Hamming distance between the Eudex hashes of two terms. This is a wrapper for :py:meth:`Eudex.eudex_hamming`. Parameters ---------- src : str Source string for comparison tar : st...
def dist_eudex(src, tar, weights='exponential', max_length=8): """Return normalized Hamming distance between Eudex hashes of two terms. This is a wrapper for :py:meth:`Eudex.dist`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparis...
def sim_eudex(src, tar, weights='exponential', max_length=8): """Return normalized Hamming similarity between Eudex hashes of two terms. This is a wrapper for :py:meth:`Eudex.sim`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparis...
def gen_fibonacci(): """Yield the next Fibonacci number. Based on https://www.python-course.eu/generators.php Starts at Fibonacci number 3 (the second 1) Yields ------ int The next Fibonacci number """ num_a, num_b = 1, 2 while True:...
def dist_abs( self, src, tar, weights='exponential', max_length=8, normalized=False ): """Calculate the distance between the Eudex hashes of two terms. Parameters ---------- src : str Source string for comparison tar : str Target string for co...
def dist(self, src, tar, weights='exponential', max_length=8): """Return normalized distance between the Eudex hashes of two terms. This is Eudex distance normalized to [0, 1]. Parameters ---------- src : str Source string for comparison tar : str ...
def euclidean(src, tar, qval=2, normalized=False, alphabet=None): """Return the Euclidean distance between two strings. This is a wrapper for :py:meth:`Euclidean.dist_abs`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target...
def dist_euclidean(src, tar, qval=2, alphabet=None): """Return the normalized Euclidean distance between two strings. This is a wrapper for :py:meth:`Euclidean.dist`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target strin...
def sim_euclidean(src, tar, qval=2, alphabet=None): """Return the normalized Euclidean similarity of two strings. This is a wrapper for :py:meth:`Euclidean.sim`. Parameters ---------- src : str Source string (or QGrams/Counter objects) for comparison tar : str Target string (or...
def _cond_k(self, word, suffix_len): """Return Lovins' condition K. Parameters ---------- word : str Word to check suffix_len : int Suffix length Returns ------- bool True if condition is met """ retur...
def _cond_n(self, word, suffix_len): """Return Lovins' condition N. Parameters ---------- word : str Word to check suffix_len : int Suffix length Returns ------- bool True if condition is met """ if le...
def _cond_s(self, word, suffix_len): """Return Lovins' condition S. Parameters ---------- word : str Word to check suffix_len : int Suffix length Returns ------- bool True if condition is met """ retur...
def _cond_x(self, word, suffix_len): """Return Lovins' condition X. Parameters ---------- word : str Word to check suffix_len : int Suffix length Returns ------- bool True if condition is met """ retur...
def _cond_bb(self, word, suffix_len): """Return Lovins' condition BB. Parameters ---------- word : str Word to check suffix_len : int Suffix length Returns ------- bool True if condition is met """ ret...
def stem(self, word): """Return Lovins stem. Parameters ---------- word : str The word to stem Returns ------- str Word stem Examples -------- >>> stmr = Lovins() >>> stmr.stem('reading') 'read' ...
def dist_abs(self, src, tar, cost=(1, 1, 1, 1)): """Return the Damerau-Levenshtein distance between two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison cost : tuple A 4-tuple...
def dist(self, src, tar): """Return the NCD between two strings using zlib compression. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison Returns ------- float Compress...
def phonex(word, max_length=4, zero_pad=True): """Return the Phonex code for a word. This is a wrapper for :py:meth:`Phonex.encode`. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 4) zero_pad : bool ...
def encode(self, word, max_length=4, zero_pad=True): """Return the Phonex 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 ...
def pylint_color(score): """Return Pylint badge color. Parameters ---------- score : float A Pylint score Returns ------- str Badge color """ # These are the score cutoffs for each color above. # I.e. score==10 -> brightgreen, down to 7.5 > score >= 5 -> orange...
def pydocstyle_color(score): """Return pydocstyle badge color. Parameters ---------- score : float A pydocstyle score Returns ------- str Badge color """ # These are the score cutoffs for each color above. # I.e. score==0 -> brightgreen, down to 100 < score <= ...
def flake8_color(score): """Return flake8 badge color. Parameters ---------- score : float A flake8 score Returns ------- str Badge color """ # These are the score cutoffs for each color above. # I.e. score==0 -> brightgreen, down to 100 < score <= 200 -> orang...
def gotoh(src, tar, gap_open=1, gap_ext=0.4, sim_func=sim_ident): """Return the Gotoh score of two strings. This is a wrapper for :py:meth:`Gotoh.dist_abs`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison gap_open : float ...
def dist_abs(self, src, tar, gap_open=1, gap_ext=0.4, sim_func=sim_ident): """Return the Gotoh score of two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison gap_open : float T...
def dist_abs(self, src, tar): """Return the bag distance between two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison Returns ------- int Bag distance ...
def dist(self, src, tar): """Return the normalized bag distance between two strings. Bag distance is normalized by dividing by :math:`max( |src|, |tar| )`. Parameters ---------- src : str Source string for comparison tar : str Target string for c...
def stem(self, word): """Return 'CLEF German stemmer plus' stem. Parameters ---------- word : str The word to stem Returns ------- str Word stem Examples -------- >>> stmr = CLEFGermanPlus() >>> clef_germa...
def sim_mlipns(src, tar, threshold=0.25, max_mismatches=2): """Return the MLIPNS similarity of two strings. This is a wrapper for :py:meth:`MLIPNS.sim`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison threshold : float ...
def dist_mlipns(src, tar, threshold=0.25, max_mismatches=2): """Return the MLIPNS distance between two strings. This is a wrapper for :py:meth:`MLIPNS.dist`. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison threshold : floa...
def sim(self, src, tar, threshold=0.25, max_mismatches=2): """Return the MLIPNS similarity of two strings. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison threshold : float A number [...
def sim(src, tar, method=sim_levenshtein): """Return a similarity of two strings. This is a generalized function for calling other similarity functions. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison method : function ...
def dist(src, tar, method=sim_levenshtein): """Return a distance between two strings. This is a generalized function for calling other distance functions. Parameters ---------- src : str Source string for comparison tar : str Target string for comparison method : function ...
def encode(self, word): """Return the MRA personal numeric identifier (PNI) for a word. Parameters ---------- word : str The word to transform Returns ------- str The MRA PNI Examples -------- >>> pe = MRA() ...
def _m_degree(self, term): """Return Porter helper function _m_degree value. m-degree is equal to the number of V to C transitions Parameters ---------- term : str The word for which to calculate the m-degree Returns ------- int ...
def _has_vowel(self, term): """Return Porter helper function _has_vowel value. Parameters ---------- term : str The word to scan for vowels Returns ------- bool True iff a vowel exists in the term (as defined in the Porter ste...
def _ends_in_doubled_cons(self, term): """Return Porter helper function _ends_in_doubled_cons value. Parameters ---------- term : str The word to check for a final doubled consonant Returns ------- bool True iff the stem ends in a doubled...
def _ends_in_cvc(self, term): """Return Porter helper function _ends_in_cvc value. Parameters ---------- term : str The word to scan for cvc Returns ------- bool True iff the stem ends in cvc (as defined in the Porter stemmer ...
def stem(self, word, early_english=False): """Return Porter 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 agreement suffixes) ...
def soundex_br(word, max_length=4, zero_pad=True): """Return the SoundexBR encoding of a word. This is a wrapper for :py:meth:`SoundexBR.encode`. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 4) zero_pad...
def encode(self, word, max_length=4, zero_pad=True): """Return the SoundexBR encoding of a word. Parameters ---------- word : str The word to transform max_length : int The length of the code returned (defaults to 4) zero_pad : bool Pa...
def filter_symlog(y, base=10.0): """Symmetrical logarithmic scale. Optional arguments: *base*: The base of the logarithm. """ log_base = np.log(base) sign = np.sign(y) logs = np.log(np.abs(y) / log_base) return sign * logs
def filter_savitzky_golay(y, window_size=5, order=2, deriv=0, rate=1): """Smooth (and optionally differentiate) with a Savitzky-Golay filter.""" try: window_size = np.abs(np.int(window_size)) order = np.abs(np.int(order)) except ValueError: raise ValueError('window_size and order mus...
def usage_function(parser): """Show usage and available curve functions.""" parser.print_usage() print('') print('available functions:') for function in sorted(FUNCTION): doc = FUNCTION[function].__doc__.strip().splitlines()[0] print(' %-12s %s' % (function + ':', doc)) retur...
def usage_palette(parser): """Show usage and available palettes.""" parser.print_usage() print('') print('available palettes:') for palette in sorted(PALETTE): print(' %-12s' % (palette,)) return 0
def run(): """Main entrypoint if invoked via the command line.""" import argparse parser = argparse.ArgumentParser( description=( 'Text mode diagrams using UTF-8 characters and fancy colors.' ), epilog=""" (1): only works for the horizontal bar graph, the first argum...
def size(self): """Get the current terminal size.""" for fd in range(3): cr = self._ioctl_GWINSZ(fd) if cr: break if not cr: try: fd = os.open(os.ctermid(), os.O_RDONLY) cr = self._ioctl_GWINSZ(fd) ...
def color(self, index): """Get the escape sequence for indexed color ``index``. The ``index`` is a color index in the 256 color space. The color space consists of: * 0x00-0x0f: default EGA colors * 0x10-0xe7: 6x6x6 RGB cubes * 0xe8-0xff: gray scale ramp """ ...
def csi(self, capname, *args): """Return the escape sequence for the selected Control Sequence.""" value = curses.tigetstr(capname) if value is None: return b'' else: return curses.tparm(value, *args)
def csi_wrap(self, value, capname, *args): """Return a value wrapped in the selected CSI and does a reset.""" if isinstance(value, str): value = value.encode('utf-8') return b''.join([ self.csi(capname, *args), value, self.csi('sgr0'), ])
def consume(self, istream, ostream, batch=False): """Read points from istream and output to ostream.""" datapoints = [] # List of 2-tuples if batch: sleep = max(0.01, self.option.sleep) fd = istream.fileno() while True: try: ...
def consume_line(self, line): """Consume data from a line.""" data = RE_VALUE_KEY.split(line.strip(), 1) if len(data) == 1: return float(data[0]), None else: return float(data[0]), data[1].strip()
def update(self, points, values=None): """Add a set of data points.""" self.values = values or [None] * len(points) if np is None: if self.option.function: warnings.warn('numpy not available, function ignored') self.points = points self.minimu...
def color_ramp(self, size): """Generate a color ramp for the current screen height.""" color = PALETTE.get(self.option.palette, {}) color = color.get(self.term.colors, None) color_ramp = [] if color is not None: ratio = len(color) / float(size) for i in ra...
def human(self, size, base=1000, units=' kMGTZ'): """Convert the input ``size`` to human readable, short form.""" sign = '+' if size >= 0 else '-' size = abs(size) if size < 1000: return '%s%d' % (sign, size) for i, suffix in enumerate(units): unit = 1000 ...
def apply_function(self, points): """Run the filter function on the provided points.""" if not self.option.function: return points if np is None: raise ImportError('numpy is not available') if ':' in self.option.function: function, arguments = self.o...
def line(self, p1, p2, resolution=1): """Resolve the points to make a line between two points.""" xdiff = max(p1.x, p2.x) - min(p1.x, p2.x) ydiff = max(p1.y, p2.y) - min(p1.y, p2.y) xdir = [-1, 1][int(p1.x <= p2.x)] ydir = [-1, 1][int(p1.y <= p2.y)] r = int(round(max(xdif...
def set_text(self, point, text): """Set a text value in the screen canvas.""" if not self.option.legend: return if not isinstance(point, Point): point = Point(point) for offset, char in enumerate(str(text)): self.screen.canvas[point.y][point.x + offs...
def render(self, stream): """Render graph to stream.""" encoding = self.option.encoding or self.term.encoding or "utf8" if self.option.color: ramp = self.color_ramp(self.size.y)[::-1] else: ramp = None if self.cycle >= 1 and self.lines: strea...
def _normalised_numpy(self): """Normalised data points using numpy.""" dx = (self.screen.width / float(len(self.points))) oy = (self.screen.height) points = np.array(self.points) - self.minimum points = points * 4.0 / self.extents * self.size.y for x, y in enumerate(point...
def _normalised_python(self): """Normalised data points using pure Python.""" dx = (self.screen.width / float(len(self.points))) oy = (self.screen.height) for x, point in enumerate(self.points): y = (point - self.minimum) * 4.0 / self.extents * self.size.y yield P...
def null(self): """Zero crossing value.""" if not self.option.axis: return -1 else: return self.screen.height - ( -self.minimum * 4.0 / self.extents * self.size.y )
def set(self, point): """Set pixel at (x, y) point.""" if not isinstance(point, Point): point = Point(point) rx = self.round(point.x) ry = self.round(point.y) item = Point((rx >> 1, min(ry >> 2, self.size.y))) self.screen[item] |= self.pixels[ry & 3][rx & 1]
def unset(self, point): """Unset pixel at (x, y) point.""" if not isinstance(point, Point): point = Point(point) x, y = self.round(point.x) >> 1, self.round(point.y) >> 2 if (x, y) not in self.screen: return if isinstance(self.screen[y][x], int): ...
def mem_size(self): '''used when allocating memory ingame''' data_len = self._data_mem_size node_count = len(list(self.xml_doc.iter(tag=etree.Element))) if self.compressed: size = 52 * node_count + data_len + 630 else: tags_len = 0 for e in s...