partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
Descriptor.err_msg
Return an error message for use in exceptions thrown by subclasses.
descriptors/Descriptor.py
def err_msg(self, instance, value): """Return an error message for use in exceptions thrown by subclasses. """ if not hasattr(self, "name"): # err_msg will be called by the composed descriptor return "" return ( "Attempted to set the {f_type} ...
def err_msg(self, instance, value): """Return an error message for use in exceptions thrown by subclasses. """ if not hasattr(self, "name"): # err_msg will be called by the composed descriptor return "" return ( "Attempted to set the {f_type} ...
[ "Return", "an", "error", "message", "for", "use", "in", "exceptions", "thrown", "by", "subclasses", "." ]
bheinzerling/descriptors
python
https://github.com/bheinzerling/descriptors/blob/04fff864649fba9bd6a2d8f8b649cf30994e0e46/descriptors/Descriptor.py#L83-L99
[ "def", "err_msg", "(", "self", ",", "instance", ",", "value", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"name\"", ")", ":", "# err_msg will be called by the composed descriptor", "return", "\"\"", "return", "(", "\"Attempted to set the {f_type} attribute {...
04fff864649fba9bd6a2d8f8b649cf30994e0e46
test
Descriptor.exc_thrown_by_descriptor
Return True if the last exception was thrown by a Descriptor instance.
descriptors/Descriptor.py
def exc_thrown_by_descriptor(): """Return True if the last exception was thrown by a Descriptor instance. """ traceback = sys.exc_info()[2] tb_locals = traceback.tb_frame.f_locals # relying on naming convention to get the object that threw # the exception ...
def exc_thrown_by_descriptor(): """Return True if the last exception was thrown by a Descriptor instance. """ traceback = sys.exc_info()[2] tb_locals = traceback.tb_frame.f_locals # relying on naming convention to get the object that threw # the exception ...
[ "Return", "True", "if", "the", "last", "exception", "was", "thrown", "by", "a", "Descriptor", "instance", "." ]
bheinzerling/descriptors
python
https://github.com/bheinzerling/descriptors/blob/04fff864649fba9bd6a2d8f8b649cf30994e0e46/descriptors/Descriptor.py#L171-L184
[ "def", "exc_thrown_by_descriptor", "(", ")", ":", "traceback", "=", "sys", ".", "exc_info", "(", ")", "[", "2", "]", "tb_locals", "=", "traceback", ".", "tb_frame", ".", "f_locals", "# relying on naming convention to get the object that threw", "# the exception", "if"...
04fff864649fba9bd6a2d8f8b649cf30994e0e46
test
Series._set_data
This method will be called to set Series data
flot/__init__.py
def _set_data(self): """ This method will be called to set Series data """ if getattr(self, 'data', False) and not getattr(self, '_x', False) and not getattr(self, '_y', False): _x = XVariable() _y = YVariable() _x.contribute_to_class(self, 'X', self.d...
def _set_data(self): """ This method will be called to set Series data """ if getattr(self, 'data', False) and not getattr(self, '_x', False) and not getattr(self, '_y', False): _x = XVariable() _y = YVariable() _x.contribute_to_class(self, 'X', self.d...
[ "This", "method", "will", "be", "called", "to", "set", "Series", "data" ]
andrefsp/pyflot
python
https://github.com/andrefsp/pyflot/blob/f2dde10709aeed39074fcce8172184b5cd8bfd66/flot/__init__.py#L168-L186
[ "def", "_set_data", "(", "self", ")", ":", "if", "getattr", "(", "self", ",", "'data'", ",", "False", ")", "and", "not", "getattr", "(", "self", ",", "'_x'", ",", "False", ")", "and", "not", "getattr", "(", "self", ",", "'_y'", ",", "False", ")", ...
f2dde10709aeed39074fcce8172184b5cd8bfd66
test
Graph._get_axis_mode
will get the axis mode for the current series
flot/__init__.py
def _get_axis_mode(self, axis): "will get the axis mode for the current series" if all([isinstance(getattr(s, axis), TimeVariable) for s in self._series]): return 'time' return None
def _get_axis_mode(self, axis): "will get the axis mode for the current series" if all([isinstance(getattr(s, axis), TimeVariable) for s in self._series]): return 'time' return None
[ "will", "get", "the", "axis", "mode", "for", "the", "current", "series" ]
andrefsp/pyflot
python
https://github.com/andrefsp/pyflot/blob/f2dde10709aeed39074fcce8172184b5cd8bfd66/flot/__init__.py#L266-L270
[ "def", "_get_axis_mode", "(", "self", ",", "axis", ")", ":", "if", "all", "(", "[", "isinstance", "(", "getattr", "(", "s", ",", "axis", ")", ",", "TimeVariable", ")", "for", "s", "in", "self", ".", "_series", "]", ")", ":", "return", "'time'", "re...
f2dde10709aeed39074fcce8172184b5cd8bfd66
test
Graph._set_options
sets the graph ploting options
flot/__init__.py
def _set_options(self): "sets the graph ploting options" # this is aweful # FIXME: Axis options should be passed completly by a GraphOption if 'xaxis' in self._options.keys(): self._options['xaxis'].update( {'mode' : self._get_axis_mode(XAxis._var_name...
def _set_options(self): "sets the graph ploting options" # this is aweful # FIXME: Axis options should be passed completly by a GraphOption if 'xaxis' in self._options.keys(): self._options['xaxis'].update( {'mode' : self._get_axis_mode(XAxis._var_name...
[ "sets", "the", "graph", "ploting", "options" ]
andrefsp/pyflot
python
https://github.com/andrefsp/pyflot/blob/f2dde10709aeed39074fcce8172184b5cd8bfd66/flot/__init__.py#L272-L281
[ "def", "_set_options", "(", "self", ")", ":", "# this is aweful", "# FIXME: Axis options should be passed completly by a GraphOption", "if", "'xaxis'", "in", "self", ".", "_options", ".", "keys", "(", ")", ":", "self", ".", "_options", "[", "'xaxis'", "]", ".", "u...
f2dde10709aeed39074fcce8172184b5cd8bfd66
test
create_init
Create an __init__ method that sets all the attributes necessary for the function the Descriptor invokes to check the value.
descriptors/massproduced.py
def create_init(attrs): """Create an __init__ method that sets all the attributes necessary for the function the Descriptor invokes to check the value. """ args = ", ".join(attrs) vals = ", ".join(['getattr(self, "{}")'.format(attr) for attr in attrs]) attr_lines = "\n ".join( ["...
def create_init(attrs): """Create an __init__ method that sets all the attributes necessary for the function the Descriptor invokes to check the value. """ args = ", ".join(attrs) vals = ", ".join(['getattr(self, "{}")'.format(attr) for attr in attrs]) attr_lines = "\n ".join( ["...
[ "Create", "an", "__init__", "method", "that", "sets", "all", "the", "attributes", "necessary", "for", "the", "function", "the", "Descriptor", "invokes", "to", "check", "the", "value", "." ]
bheinzerling/descriptors
python
https://github.com/bheinzerling/descriptors/blob/04fff864649fba9bd6a2d8f8b649cf30994e0e46/descriptors/massproduced.py#L51-L68
[ "def", "create_init", "(", "attrs", ")", ":", "args", "=", "\", \"", ".", "join", "(", "attrs", ")", "vals", "=", "\", \"", ".", "join", "(", "[", "'getattr(self, \"{}\")'", ".", "format", "(", "attr", ")", "for", "attr", "in", "attrs", "]", ")", "at...
04fff864649fba9bd6a2d8f8b649cf30994e0e46
test
create_setter
Create the __set__ method for the descriptor.
descriptors/massproduced.py
def create_setter(func, attrs): """Create the __set__ method for the descriptor.""" def _set(self, instance, value, name=None): args = [getattr(self, attr) for attr in attrs] if not func(value, *args): raise ValueError(self.err_msg(instance, value)) return _set
def create_setter(func, attrs): """Create the __set__ method for the descriptor.""" def _set(self, instance, value, name=None): args = [getattr(self, attr) for attr in attrs] if not func(value, *args): raise ValueError(self.err_msg(instance, value)) return _set
[ "Create", "the", "__set__", "method", "for", "the", "descriptor", "." ]
bheinzerling/descriptors
python
https://github.com/bheinzerling/descriptors/blob/04fff864649fba9bd6a2d8f8b649cf30994e0e46/descriptors/massproduced.py#L71-L77
[ "def", "create_setter", "(", "func", ",", "attrs", ")", ":", "def", "_set", "(", "self", ",", "instance", ",", "value", ",", "name", "=", "None", ")", ":", "args", "=", "[", "getattr", "(", "self", ",", "attr", ")", "for", "attr", "in", "attrs", ...
04fff864649fba9bd6a2d8f8b649cf30994e0e46
test
make_class
Turn a funcs list element into a class object.
descriptors/massproduced.py
def make_class(clsname, func, attrs): """Turn a funcs list element into a class object.""" clsdict = {"__set__": create_setter(func, attrs)} if len(attrs) > 0: clsdict["__init__"] = create_init(attrs) clsobj = type(str(clsname), (Descriptor, ), clsdict) clsobj.__doc__ = docstrings.get(clsnam...
def make_class(clsname, func, attrs): """Turn a funcs list element into a class object.""" clsdict = {"__set__": create_setter(func, attrs)} if len(attrs) > 0: clsdict["__init__"] = create_init(attrs) clsobj = type(str(clsname), (Descriptor, ), clsdict) clsobj.__doc__ = docstrings.get(clsnam...
[ "Turn", "a", "funcs", "list", "element", "into", "a", "class", "object", "." ]
bheinzerling/descriptors
python
https://github.com/bheinzerling/descriptors/blob/04fff864649fba9bd6a2d8f8b649cf30994e0e46/descriptors/massproduced.py#L80-L87
[ "def", "make_class", "(", "clsname", ",", "func", ",", "attrs", ")", ":", "clsdict", "=", "{", "\"__set__\"", ":", "create_setter", "(", "func", ",", "attrs", ")", "}", "if", "len", "(", "attrs", ")", ">", "0", ":", "clsdict", "[", "\"__init__\"", "]...
04fff864649fba9bd6a2d8f8b649cf30994e0e46
test
DashboardRunner.cycle
Cycles through notifications with latest results from data feeds.
doodledashboard/dashboard.py
def cycle(self): """ Cycles through notifications with latest results from data feeds. """ messages = self.poll_datafeeds() notifications = self.process_notifications(messages) self.draw_notifications(notifications)
def cycle(self): """ Cycles through notifications with latest results from data feeds. """ messages = self.poll_datafeeds() notifications = self.process_notifications(messages) self.draw_notifications(notifications)
[ "Cycles", "through", "notifications", "with", "latest", "results", "from", "data", "feeds", "." ]
SketchingDev/Doodle-Dashboard
python
https://github.com/SketchingDev/Doodle-Dashboard/blob/4d7f4c248875f82a962c275009aac4aa76bd0320/doodledashboard/dashboard.py#L39-L46
[ "def", "cycle", "(", "self", ")", ":", "messages", "=", "self", ".", "poll_datafeeds", "(", ")", "notifications", "=", "self", ".", "process_notifications", "(", "messages", ")", "self", ".", "draw_notifications", "(", "notifications", ")" ]
4d7f4c248875f82a962c275009aac4aa76bd0320
test
ForceNumeric.try_convert
Convert value to a numeric value or raise a ValueError if that isn't possible.
descriptors/handmade.py
def try_convert(value): """Convert value to a numeric value or raise a ValueError if that isn't possible. """ convertible = ForceNumeric.is_convertible(value) if not convertible or isinstance(value, bool): raise ValueError if isinstance(str(value), str): ...
def try_convert(value): """Convert value to a numeric value or raise a ValueError if that isn't possible. """ convertible = ForceNumeric.is_convertible(value) if not convertible or isinstance(value, bool): raise ValueError if isinstance(str(value), str): ...
[ "Convert", "value", "to", "a", "numeric", "value", "or", "raise", "a", "ValueError", "if", "that", "isn", "t", "possible", "." ]
bheinzerling/descriptors
python
https://github.com/bheinzerling/descriptors/blob/04fff864649fba9bd6a2d8f8b649cf30994e0e46/descriptors/handmade.py#L143-L153
[ "def", "try_convert", "(", "value", ")", ":", "convertible", "=", "ForceNumeric", ".", "is_convertible", "(", "value", ")", "if", "not", "convertible", "or", "isinstance", "(", "value", ",", "bool", ")", ":", "raise", "ValueError", "if", "isinstance", "(", ...
04fff864649fba9bd6a2d8f8b649cf30994e0e46
test
ForceNumeric.str_to_num
Convert str_value to an int or a float, depending on the numeric value represented by str_value.
descriptors/handmade.py
def str_to_num(str_value): """Convert str_value to an int or a float, depending on the numeric value represented by str_value. """ str_value = str(str_value) try: return int(str_value) except ValueError: return float(str_value)
def str_to_num(str_value): """Convert str_value to an int or a float, depending on the numeric value represented by str_value. """ str_value = str(str_value) try: return int(str_value) except ValueError: return float(str_value)
[ "Convert", "str_value", "to", "an", "int", "or", "a", "float", "depending", "on", "the", "numeric", "value", "represented", "by", "str_value", "." ]
bheinzerling/descriptors
python
https://github.com/bheinzerling/descriptors/blob/04fff864649fba9bd6a2d8f8b649cf30994e0e46/descriptors/handmade.py#L167-L176
[ "def", "str_to_num", "(", "str_value", ")", ":", "str_value", "=", "str", "(", "str_value", ")", "try", ":", "return", "int", "(", "str_value", ")", "except", "ValueError", ":", "return", "float", "(", "str_value", ")" ]
04fff864649fba9bd6a2d8f8b649cf30994e0e46
test
plot
Tag to plot graphs into the template
flot/templatetags/flot_tags.py
def plot(parser, token): """ Tag to plot graphs into the template """ tokens = token.split_contents() tokens.pop(0) graph = tokens.pop(0) attrs = dict([token.split("=") for token in tokens]) if 'id' not in attrs.keys(): attrs['id'] = ''.join([chr(choice(range(65, 90))) for i i...
def plot(parser, token): """ Tag to plot graphs into the template """ tokens = token.split_contents() tokens.pop(0) graph = tokens.pop(0) attrs = dict([token.split("=") for token in tokens]) if 'id' not in attrs.keys(): attrs['id'] = ''.join([chr(choice(range(65, 90))) for i i...
[ "Tag", "to", "plot", "graphs", "into", "the", "template" ]
andrefsp/pyflot
python
https://github.com/andrefsp/pyflot/blob/f2dde10709aeed39074fcce8172184b5cd8bfd66/flot/templatetags/flot_tags.py#L31-L48
[ "def", "plot", "(", "parser", ",", "token", ")", ":", "tokens", "=", "token", ".", "split_contents", "(", ")", "tokens", ".", "pop", "(", "0", ")", "graph", "=", "tokens", ".", "pop", "(", "0", ")", "attrs", "=", "dict", "(", "[", "token", ".", ...
f2dde10709aeed39074fcce8172184b5cd8bfd66
test
force_unicode
Try really really hard to get a Unicode copy of a string. First try :class:`BeautifulSoup.UnicodeDammit` to try to force to Unicode; if that fails, assume UTF-8 encoding, and ignore all errors. :param str raw: string to coerce :return: Unicode approximation of `raw` :returntype: :class:`unicod...
streamcorpus_pipeline/_clean_html.py
def force_unicode(raw): '''Try really really hard to get a Unicode copy of a string. First try :class:`BeautifulSoup.UnicodeDammit` to try to force to Unicode; if that fails, assume UTF-8 encoding, and ignore all errors. :param str raw: string to coerce :return: Unicode approximation of `raw` ...
def force_unicode(raw): '''Try really really hard to get a Unicode copy of a string. First try :class:`BeautifulSoup.UnicodeDammit` to try to force to Unicode; if that fails, assume UTF-8 encoding, and ignore all errors. :param str raw: string to coerce :return: Unicode approximation of `raw` ...
[ "Try", "really", "really", "hard", "to", "get", "a", "Unicode", "copy", "of", "a", "string", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_clean_html.py#L51-L73
[ "def", "force_unicode", "(", "raw", ")", ":", "converted", "=", "UnicodeDammit", "(", "raw", ",", "isHTML", "=", "True", ")", "if", "not", "converted", ".", "unicode", ":", "converted", ".", "unicode", "=", "unicode", "(", "raw", ",", "'utf8'", ",", "e...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
make_clean_html
Get a clean text representation of presumed HTML. Treat `raw` as though it is HTML, even if we have no idea what it really is, and attempt to get a properly formatted HTML document with all HTML-escaped characters converted to their unicode. This is called below by the `clean_html` transform stage, wh...
streamcorpus_pipeline/_clean_html.py
def make_clean_html(raw, stream_item=None, encoding=None): '''Get a clean text representation of presumed HTML. Treat `raw` as though it is HTML, even if we have no idea what it really is, and attempt to get a properly formatted HTML document with all HTML-escaped characters converted to their unicode....
def make_clean_html(raw, stream_item=None, encoding=None): '''Get a clean text representation of presumed HTML. Treat `raw` as though it is HTML, even if we have no idea what it really is, and attempt to get a properly formatted HTML document with all HTML-escaped characters converted to their unicode....
[ "Get", "a", "clean", "text", "representation", "of", "presumed", "HTML", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_clean_html.py#L111-L184
[ "def", "make_clean_html", "(", "raw", ",", "stream_item", "=", "None", ",", "encoding", "=", "None", ")", ":", "# Fix emails by protecting the <,> from HTML", "raw", "=", "fix_emails", "(", "raw", ")", "raw_decoded", "=", "nice_decode", "(", "raw", ",", "stream_...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
uniform_html
Takes a utf-8-encoded string of HTML as input and returns a new HTML string with fixed quoting and close tags, which generally should not break any of the offsets and makes it easier for functions like :func:`streamcorpus_pipeline.offsets.char_offsets_to_xpaths` to operate without failures.
streamcorpus_pipeline/_clean_html.py
def uniform_html(html): '''Takes a utf-8-encoded string of HTML as input and returns a new HTML string with fixed quoting and close tags, which generally should not break any of the offsets and makes it easier for functions like :func:`streamcorpus_pipeline.offsets.char_offsets_to_xpaths` to ope...
def uniform_html(html): '''Takes a utf-8-encoded string of HTML as input and returns a new HTML string with fixed quoting and close tags, which generally should not break any of the offsets and makes it easier for functions like :func:`streamcorpus_pipeline.offsets.char_offsets_to_xpaths` to ope...
[ "Takes", "a", "utf", "-", "8", "-", "encoded", "string", "of", "HTML", "as", "input", "and", "returns", "a", "new", "HTML", "string", "with", "fixed", "quoting", "and", "close", "tags", "which", "generally", "should", "not", "break", "any", "of", "the", ...
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_clean_html.py#L187-L202
[ "def", "uniform_html", "(", "html", ")", ":", "doc", "=", "html5lib", ".", "parse", "(", "html", ".", "decode", "(", "'utf-8'", ")", ")", "config", "=", "{", "'omit_optional_tags'", ":", "False", ",", "'encoding'", ":", "'utf-8'", ",", "'quote_attr_values'...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
clean_html.is_matching_mime_type
This implements the MIME-type matching logic for deciding whether to run `make_clean_html`
streamcorpus_pipeline/_clean_html.py
def is_matching_mime_type(self, mime_type): '''This implements the MIME-type matching logic for deciding whether to run `make_clean_html` ''' if len(self.include_mime_types) == 0: return True if mime_type is None: return False mime_type = mime_typ...
def is_matching_mime_type(self, mime_type): '''This implements the MIME-type matching logic for deciding whether to run `make_clean_html` ''' if len(self.include_mime_types) == 0: return True if mime_type is None: return False mime_type = mime_typ...
[ "This", "implements", "the", "MIME", "-", "type", "matching", "logic", "for", "deciding", "whether", "to", "run", "make_clean_html" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_clean_html.py#L250-L262
[ "def", "is_matching_mime_type", "(", "self", ",", "mime_type", ")", ":", "if", "len", "(", "self", ".", "include_mime_types", ")", "==", "0", ":", "return", "True", "if", "mime_type", "is", "None", ":", "return", "False", "mime_type", "=", "mime_type", "."...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
domain_name_cleanse
extract a lower-case, no-slashes domain name from a raw string that might be a URL
streamcorpus_pipeline/_filters.py
def domain_name_cleanse(raw_string): '''extract a lower-case, no-slashes domain name from a raw string that might be a URL ''' try: parts = urlparse(raw_string) domain = parts.netloc.split(':')[0] except: domain = '' if not domain: domain = raw_string if not d...
def domain_name_cleanse(raw_string): '''extract a lower-case, no-slashes domain name from a raw string that might be a URL ''' try: parts = urlparse(raw_string) domain = parts.netloc.split(':')[0] except: domain = '' if not domain: domain = raw_string if not d...
[ "extract", "a", "lower", "-", "case", "no", "-", "slashes", "domain", "name", "from", "a", "raw", "string", "that", "might", "be", "a", "URL" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_filters.py#L253-L267
[ "def", "domain_name_cleanse", "(", "raw_string", ")", ":", "try", ":", "parts", "=", "urlparse", "(", "raw_string", ")", "domain", "=", "parts", ".", "netloc", ".", "split", "(", "':'", ")", "[", "0", "]", "except", ":", "domain", "=", "''", "if", "n...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
domain_name_left_cuts
returns a list of strings created by splitting the domain on '.' and successively cutting off the left most portion
streamcorpus_pipeline/_filters.py
def domain_name_left_cuts(domain): '''returns a list of strings created by splitting the domain on '.' and successively cutting off the left most portion ''' cuts = [] if domain: parts = domain.split('.') for i in range(len(parts)): cuts.append( '.'.join(parts[i:])) r...
def domain_name_left_cuts(domain): '''returns a list of strings created by splitting the domain on '.' and successively cutting off the left most portion ''' cuts = [] if domain: parts = domain.split('.') for i in range(len(parts)): cuts.append( '.'.join(parts[i:])) r...
[ "returns", "a", "list", "of", "strings", "created", "by", "splitting", "the", "domain", "on", ".", "and", "successively", "cutting", "off", "the", "left", "most", "portion" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_filters.py#L269-L278
[ "def", "domain_name_left_cuts", "(", "domain", ")", ":", "cuts", "=", "[", "]", "if", "domain", ":", "parts", "=", "domain", ".", "split", "(", "'.'", ")", "for", "i", "in", "range", "(", "len", "(", "parts", ")", ")", ":", "cuts", ".", "append", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
keyword_indexer.make_hash_kw
Get a Murmur hash and a normalized token. `tok` may be a :class:`unicode` string or a UTF-8-encoded byte string. :data:`DOCUMENT_HASH_KEY`, hash value 0, is reserved for the document count, and this function remaps that value. :param tok: token to hash :return: pair of...
streamcorpus_pipeline/_kvlayer_keyword_search.py
def make_hash_kw(self, tok): '''Get a Murmur hash and a normalized token. `tok` may be a :class:`unicode` string or a UTF-8-encoded byte string. :data:`DOCUMENT_HASH_KEY`, hash value 0, is reserved for the document count, and this function remaps that value. :param tok...
def make_hash_kw(self, tok): '''Get a Murmur hash and a normalized token. `tok` may be a :class:`unicode` string or a UTF-8-encoded byte string. :data:`DOCUMENT_HASH_KEY`, hash value 0, is reserved for the document count, and this function remaps that value. :param tok...
[ "Get", "a", "Murmur", "hash", "and", "a", "normalized", "token", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer_keyword_search.py#L85-L102
[ "def", "make_hash_kw", "(", "self", ",", "tok", ")", ":", "if", "isinstance", "(", "tok", ",", "unicode", ")", ":", "tok", "=", "tok", ".", "encode", "(", "'utf-8'", ")", "h", "=", "mmh3", ".", "hash", "(", "tok", ")", "if", "h", "==", "DOCUMENT_...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
keyword_indexer.collect_words
Collect all of the words to be indexed from a stream item. This scans `si` for all of the configured tagger IDs. It collects all of the token values (the :attr:`streamcorpus.Token.token`) and returns a :class:`collections.Counter` of them. :param si: stream item to scan ...
streamcorpus_pipeline/_kvlayer_keyword_search.py
def collect_words(self, si): '''Collect all of the words to be indexed from a stream item. This scans `si` for all of the configured tagger IDs. It collects all of the token values (the :attr:`streamcorpus.Token.token`) and returns a :class:`collections.Counter` of them. ...
def collect_words(self, si): '''Collect all of the words to be indexed from a stream item. This scans `si` for all of the configured tagger IDs. It collects all of the token values (the :attr:`streamcorpus.Token.token`) and returns a :class:`collections.Counter` of them. ...
[ "Collect", "all", "of", "the", "words", "to", "be", "indexed", "from", "a", "stream", "item", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer_keyword_search.py#L104-L133
[ "def", "collect_words", "(", "self", ",", "si", ")", ":", "counter", "=", "Counter", "(", ")", "for", "tagger_id", ",", "sentences", "in", "si", ".", "body", ".", "sentences", ".", "iteritems", "(", ")", ":", "if", "(", "(", "self", ".", "keyword_tag...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
keyword_indexer.index
Record index records for a single document. Which indexes this creates depends on the parameters to the constructor. This records all of the requested indexes for a single document.
streamcorpus_pipeline/_kvlayer_keyword_search.py
def index(self, si): '''Record index records for a single document. Which indexes this creates depends on the parameters to the constructor. This records all of the requested indexes for a single document. ''' if not si.body.clean_visible: logger.warn('stre...
def index(self, si): '''Record index records for a single document. Which indexes this creates depends on the parameters to the constructor. This records all of the requested indexes for a single document. ''' if not si.body.clean_visible: logger.warn('stre...
[ "Record", "index", "records", "for", "a", "single", "document", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer_keyword_search.py#L135-L172
[ "def", "index", "(", "self", ",", "si", ")", ":", "if", "not", "si", ".", "body", ".", "clean_visible", ":", "logger", ".", "warn", "(", "'stream item %s has no clean_visible part, '", "'skipping keyword indexing'", ",", "si", ".", "stream_id", ")", "return", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
keyword_indexer.invert_hash
Get strings that correspond to some hash. No string will correspond to :data:`DOCUMENT_HASH_KEY`; use :data:`DOCUMENT_HASH_KEY_REPLACEMENT` instead. :param int tok_hash: Murmur hash to query :return: list of :class:`unicode` strings
streamcorpus_pipeline/_kvlayer_keyword_search.py
def invert_hash(self, tok_hash): '''Get strings that correspond to some hash. No string will correspond to :data:`DOCUMENT_HASH_KEY`; use :data:`DOCUMENT_HASH_KEY_REPLACEMENT` instead. :param int tok_hash: Murmur hash to query :return: list of :class:`unicode` strings ...
def invert_hash(self, tok_hash): '''Get strings that correspond to some hash. No string will correspond to :data:`DOCUMENT_HASH_KEY`; use :data:`DOCUMENT_HASH_KEY_REPLACEMENT` instead. :param int tok_hash: Murmur hash to query :return: list of :class:`unicode` strings ...
[ "Get", "strings", "that", "correspond", "to", "some", "hash", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer_keyword_search.py#L174-L187
[ "def", "invert_hash", "(", "self", ",", "tok_hash", ")", ":", "return", "[", "tok_encoded", ".", "decode", "(", "'utf8'", ")", "for", "(", "_", ",", "tok_encoded", ")", "in", "self", ".", "client", ".", "scan_keys", "(", "HASH_KEYWORD_INDEX_TABLE", ",", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
keyword_indexer.document_frequencies
Get document frequencies for a list of hashes. This will return all zeros unless the index was written with `hash_frequencies` set. If :data:`DOCUMENT_HASH_KEY` is included in `hashes`, that value will be returned with the total number of documents indexed. If you are looking for ...
streamcorpus_pipeline/_kvlayer_keyword_search.py
def document_frequencies(self, hashes): '''Get document frequencies for a list of hashes. This will return all zeros unless the index was written with `hash_frequencies` set. If :data:`DOCUMENT_HASH_KEY` is included in `hashes`, that value will be returned with the total number...
def document_frequencies(self, hashes): '''Get document frequencies for a list of hashes. This will return all zeros unless the index was written with `hash_frequencies` set. If :data:`DOCUMENT_HASH_KEY` is included in `hashes`, that value will be returned with the total number...
[ "Get", "document", "frequencies", "for", "a", "list", "of", "hashes", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer_keyword_search.py#L189-L210
[ "def", "document_frequencies", "(", "self", ",", "hashes", ")", ":", "result", "=", "{", "}", "for", "(", "k", ",", "v", ")", "in", "self", ".", "client", ".", "get", "(", "HASH_FREQUENCY_TABLE", ",", "*", "[", "(", "h", ",", ")", "for", "h", "in...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
keyword_indexer.lookup
Get stream IDs for a single hash. This yields strings that can be retrieved using :func:`streamcorpus_pipeline._kvlayer.get_kvlayer_stream_item`, or fed back into :mod:`coordinate` or other job queue systems. Note that for common terms this can return a large number of stream I...
streamcorpus_pipeline/_kvlayer_keyword_search.py
def lookup(self, h): '''Get stream IDs for a single hash. This yields strings that can be retrieved using :func:`streamcorpus_pipeline._kvlayer.get_kvlayer_stream_item`, or fed back into :mod:`coordinate` or other job queue systems. Note that for common terms this can return a ...
def lookup(self, h): '''Get stream IDs for a single hash. This yields strings that can be retrieved using :func:`streamcorpus_pipeline._kvlayer.get_kvlayer_stream_item`, or fed back into :mod:`coordinate` or other job queue systems. Note that for common terms this can return a ...
[ "Get", "stream", "IDs", "for", "a", "single", "hash", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer_keyword_search.py#L212-L236
[ "def", "lookup", "(", "self", ",", "h", ")", ":", "for", "(", "_", ",", "k1", ",", "k2", ")", "in", "self", ".", "client", ".", "scan_keys", "(", "HASH_TF_INDEX_TABLE", ",", "(", "(", "h", ",", ")", ",", "(", "h", ",", ")", ")", ")", ":", "...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
keyword_indexer.lookup_tf
Get stream IDs and term frequencies for a single hash. This yields pairs of strings that can be retrieved using :func:`streamcorpus_pipeline._kvlayer.get_kvlayer_stream_item` and the corresponding term frequency. ..see:: :meth:`lookup`
streamcorpus_pipeline/_kvlayer_keyword_search.py
def lookup_tf(self, h): '''Get stream IDs and term frequencies for a single hash. This yields pairs of strings that can be retrieved using :func:`streamcorpus_pipeline._kvlayer.get_kvlayer_stream_item` and the corresponding term frequency. ..see:: :meth:`lookup` ''' ...
def lookup_tf(self, h): '''Get stream IDs and term frequencies for a single hash. This yields pairs of strings that can be retrieved using :func:`streamcorpus_pipeline._kvlayer.get_kvlayer_stream_item` and the corresponding term frequency. ..see:: :meth:`lookup` ''' ...
[ "Get", "stream", "IDs", "and", "term", "frequencies", "for", "a", "single", "hash", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer_keyword_search.py#L238-L251
[ "def", "lookup_tf", "(", "self", ",", "h", ")", ":", "for", "(", "(", "_", ",", "k1", ",", "k2", ")", ",", "v", ")", "in", "self", ".", "client", ".", "scan", "(", "HASH_TF_INDEX_TABLE", ",", "(", "(", "h", ",", ")", ",", "(", "h", ",", ")"...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
_make_stream_items
Given a spinn3r feed, produce a sequence of valid StreamItems. Because of goopy Python interactions, you probably need to call this and re-yield its results, as >>> with open(filename, 'rb') as f: ... for si in _make_stream_items(f): ... yield si
streamcorpus_pipeline/_spinn3r_feed_storage.py
def _make_stream_items(f): """Given a spinn3r feed, produce a sequence of valid StreamItems. Because of goopy Python interactions, you probably need to call this and re-yield its results, as >>> with open(filename, 'rb') as f: ... for si in _make_stream_items(f): ... yield si """ ...
def _make_stream_items(f): """Given a spinn3r feed, produce a sequence of valid StreamItems. Because of goopy Python interactions, you probably need to call this and re-yield its results, as >>> with open(filename, 'rb') as f: ... for si in _make_stream_items(f): ... yield si """ ...
[ "Given", "a", "spinn3r", "feed", "produce", "a", "sequence", "of", "valid", "StreamItems", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_spinn3r_feed_storage.py#L226-L240
[ "def", "_make_stream_items", "(", "f", ")", ":", "reader", "=", "ProtoStreamReader", "(", "f", ")", "return", "itertools", ".", "ifilter", "(", "lambda", "x", ":", "x", "is", "not", "None", ",", "itertools", ".", "imap", "(", "_make_stream_item", ",", "r...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
_make_stream_item
Given a single spinn3r feed entry, produce a single StreamItem. Returns 'None' if a complete item can't be constructed.
streamcorpus_pipeline/_spinn3r_feed_storage.py
def _make_stream_item(entry): """Given a single spinn3r feed entry, produce a single StreamItem. Returns 'None' if a complete item can't be constructed. """ # get standard metadata, assuming it's present... if not hasattr(entry, 'permalink_entry'): return None pe = entry.permalink_entr...
def _make_stream_item(entry): """Given a single spinn3r feed entry, produce a single StreamItem. Returns 'None' if a complete item can't be constructed. """ # get standard metadata, assuming it's present... if not hasattr(entry, 'permalink_entry'): return None pe = entry.permalink_entr...
[ "Given", "a", "single", "spinn3r", "feed", "entry", "produce", "a", "single", "StreamItem", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_spinn3r_feed_storage.py#L243-L298
[ "def", "_make_stream_item", "(", "entry", ")", ":", "# get standard metadata, assuming it's present...", "if", "not", "hasattr", "(", "entry", ",", "'permalink_entry'", ")", ":", "return", "None", "pe", "=", "entry", ".", "permalink_entry", "# ...and create a streamitem...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
_make_content_item
Create a ContentItem from a node in the spinn3r data tree. The ContentItem is created with raw data set to ``node.data``, decompressed if the node's encoding is 'zlib', and UTF-8 normalized, with a MIME type from ``node.mime_type``. ``node`` the actual node from the spinn3r protobuf data ``m...
streamcorpus_pipeline/_spinn3r_feed_storage.py
def _make_content_item(node, mime_type=None, alternate_data=None): """Create a ContentItem from a node in the spinn3r data tree. The ContentItem is created with raw data set to ``node.data``, decompressed if the node's encoding is 'zlib', and UTF-8 normalized, with a MIME type from ``node.mime_type``. ...
def _make_content_item(node, mime_type=None, alternate_data=None): """Create a ContentItem from a node in the spinn3r data tree. The ContentItem is created with raw data set to ``node.data``, decompressed if the node's encoding is 'zlib', and UTF-8 normalized, with a MIME type from ``node.mime_type``. ...
[ "Create", "a", "ContentItem", "from", "a", "node", "in", "the", "spinn3r", "data", "tree", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_spinn3r_feed_storage.py#L301-L332
[ "def", "_make_content_item", "(", "node", ",", "mime_type", "=", "None", ",", "alternate_data", "=", "None", ")", ":", "raw", "=", "node", ".", "data", "if", "getattr", "(", "node", ",", "'encoding'", ",", "None", ")", "==", "'zlib'", ":", "try", ":", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
ProtoStreamReader._read
Read (up to) 'n' bytes from the underlying file. If any bytes have been pushed in with _unread() those are returned first.
streamcorpus_pipeline/_spinn3r_feed_storage.py
def _read(self, n): """Read (up to) 'n' bytes from the underlying file. If any bytes have been pushed in with _unread() those are returned first.""" if n <= len(self._prefix): # the read can be fulfilled entirely from the prefix result = self._prefix[:n] self...
def _read(self, n): """Read (up to) 'n' bytes from the underlying file. If any bytes have been pushed in with _unread() those are returned first.""" if n <= len(self._prefix): # the read can be fulfilled entirely from the prefix result = self._prefix[:n] self...
[ "Read", "(", "up", "to", ")", "n", "bytes", "from", "the", "underlying", "file", ".", "If", "any", "bytes", "have", "been", "pushed", "in", "with", "_unread", "()", "those", "are", "returned", "first", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_spinn3r_feed_storage.py#L104-L116
[ "def", "_read", "(", "self", ",", "n", ")", ":", "if", "n", "<=", "len", "(", "self", ".", "_prefix", ")", ":", "# the read can be fulfilled entirely from the prefix", "result", "=", "self", ".", "_prefix", "[", ":", "n", "]", "self", ".", "_prefix", "="...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
ProtoStreamReader._read_varint
Read exactly a varint out of the underlying file.
streamcorpus_pipeline/_spinn3r_feed_storage.py
def _read_varint(self): """Read exactly a varint out of the underlying file.""" buf = self._read(8) (n, l) = _DecodeVarint(buf, 0) self._unread(buf[l:]) return n
def _read_varint(self): """Read exactly a varint out of the underlying file.""" buf = self._read(8) (n, l) = _DecodeVarint(buf, 0) self._unread(buf[l:]) return n
[ "Read", "exactly", "a", "varint", "out", "of", "the", "underlying", "file", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_spinn3r_feed_storage.py#L118-L123
[ "def", "_read_varint", "(", "self", ")", ":", "buf", "=", "self", ".", "_read", "(", "8", ")", "(", "n", ",", "l", ")", "=", "_DecodeVarint", "(", "buf", ",", "0", ")", "self", ".", "_unread", "(", "buf", "[", "l", ":", "]", ")", "return", "n...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
ProtoStreamReader._read_a
Read some protobuf-encoded object stored in a single block out of the file.
streamcorpus_pipeline/_spinn3r_feed_storage.py
def _read_a(self, cls): """Read some protobuf-encoded object stored in a single block out of the file.""" o = cls() o.ParseFromString(self._read_block()) return o
def _read_a(self, cls): """Read some protobuf-encoded object stored in a single block out of the file.""" o = cls() o.ParseFromString(self._read_block()) return o
[ "Read", "some", "protobuf", "-", "encoded", "object", "stored", "in", "a", "single", "block", "out", "of", "the", "file", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_spinn3r_feed_storage.py#L131-L136
[ "def", "_read_a", "(", "self", ",", "cls", ")", ":", "o", "=", "cls", "(", ")", "o", ".", "ParseFromString", "(", "self", ".", "_read_block", "(", ")", ")", "return", "o" ]
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
parse_keys_and_ranges
Parse the :class:`from_kvlayer` input string. This accepts two formats. In the textual format, it accepts any number of stream IDs in timestamp-docid format, separated by ``,`` or ``;``, and processes those as individual stream IDs. In the binary format, it accepts 20-byte key blobs (16 bytes md5 has...
streamcorpus_pipeline/_kvlayer.py
def parse_keys_and_ranges(i_str, keyfunc, rangefunc): '''Parse the :class:`from_kvlayer` input string. This accepts two formats. In the textual format, it accepts any number of stream IDs in timestamp-docid format, separated by ``,`` or ``;``, and processes those as individual stream IDs. In the ...
def parse_keys_and_ranges(i_str, keyfunc, rangefunc): '''Parse the :class:`from_kvlayer` input string. This accepts two formats. In the textual format, it accepts any number of stream IDs in timestamp-docid format, separated by ``,`` or ``;``, and processes those as individual stream IDs. In the ...
[ "Parse", "the", ":", "class", ":", "from_kvlayer", "input", "string", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer.py#L128-L178
[ "def", "parse_keys_and_ranges", "(", "i_str", ",", "keyfunc", ",", "rangefunc", ")", ":", "while", "i_str", ":", "m", "=", "_STREAM_ID_RE", ".", "match", "(", "i_str", ")", "if", "m", ":", "# old style text stream_id", "for", "retval", "in", "keyfunc", "(", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
get_kvlayer_stream_item
Retrieve a :class:`streamcorpus.StreamItem` from :mod:`kvlayer`. This function requires that `client` already be set up properly:: client = kvlayer.client() client.setup_namespace(STREAM_ITEM_TABLE_DEFS, STREAM_ITEM_VALUE_DEFS) si = get_kvlayer_stream_item(cl...
streamcorpus_pipeline/_kvlayer.py
def get_kvlayer_stream_item(client, stream_id): '''Retrieve a :class:`streamcorpus.StreamItem` from :mod:`kvlayer`. This function requires that `client` already be set up properly:: client = kvlayer.client() client.setup_namespace(STREAM_ITEM_TABLE_DEFS, STREAM_I...
def get_kvlayer_stream_item(client, stream_id): '''Retrieve a :class:`streamcorpus.StreamItem` from :mod:`kvlayer`. This function requires that `client` already be set up properly:: client = kvlayer.client() client.setup_namespace(STREAM_ITEM_TABLE_DEFS, STREAM_I...
[ "Retrieve", "a", ":", "class", ":", "streamcorpus", ".", "StreamItem", "from", ":", "mod", ":", "kvlayer", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer.py#L182-L213
[ "def", "get_kvlayer_stream_item", "(", "client", ",", "stream_id", ")", ":", "if", "client", "is", "None", ":", "client", "=", "kvlayer", ".", "client", "(", ")", "client", ".", "setup_namespace", "(", "STREAM_ITEM_TABLE_DEFS", ",", "STREAM_ITEM_VALUE_DEFS", ")"...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
make_doc_id_range
Construct a tuple(begin, end) of one-tuple kvlayer keys from a hexdigest doc_id.
streamcorpus_pipeline/_kvlayer.py
def make_doc_id_range(doc_id): '''Construct a tuple(begin, end) of one-tuple kvlayer keys from a hexdigest doc_id. ''' assert len(doc_id) == 32, 'expecting 32 hex string, not: %r' % doc_id bin_docid = base64.b16decode(doc_id.upper()) doc_id_range = ((bin_docid,), (bin_docid,)) return doc_id...
def make_doc_id_range(doc_id): '''Construct a tuple(begin, end) of one-tuple kvlayer keys from a hexdigest doc_id. ''' assert len(doc_id) == 32, 'expecting 32 hex string, not: %r' % doc_id bin_docid = base64.b16decode(doc_id.upper()) doc_id_range = ((bin_docid,), (bin_docid,)) return doc_id...
[ "Construct", "a", "tuple", "(", "begin", "end", ")", "of", "one", "-", "tuple", "kvlayer", "keys", "from", "a", "hexdigest", "doc_id", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer.py#L216-L224
[ "def", "make_doc_id_range", "(", "doc_id", ")", ":", "assert", "len", "(", "doc_id", ")", "==", "32", ",", "'expecting 32 hex string, not: %r'", "%", "doc_id", "bin_docid", "=", "base64", ".", "b16decode", "(", "doc_id", ".", "upper", "(", ")", ")", "doc_id_...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
get_kvlayer_stream_item_by_doc_id
Retrieve :class:`streamcorpus.StreamItem`s from :mod:`kvlayer`. Namely, it returns an iterator over all documents with the given docid. The docid should be an md5 hash of the document's abs_url. :param client: kvlayer client object :type client: :class:`kvlayer.AbstractStorage` :param str doc_id: ...
streamcorpus_pipeline/_kvlayer.py
def get_kvlayer_stream_item_by_doc_id(client, doc_id): '''Retrieve :class:`streamcorpus.StreamItem`s from :mod:`kvlayer`. Namely, it returns an iterator over all documents with the given docid. The docid should be an md5 hash of the document's abs_url. :param client: kvlayer client object :type cl...
def get_kvlayer_stream_item_by_doc_id(client, doc_id): '''Retrieve :class:`streamcorpus.StreamItem`s from :mod:`kvlayer`. Namely, it returns an iterator over all documents with the given docid. The docid should be an md5 hash of the document's abs_url. :param client: kvlayer client object :type cl...
[ "Retrieve", ":", "class", ":", "streamcorpus", ".", "StreamItem", "s", "from", ":", "mod", ":", "kvlayer", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer.py#L227-L246
[ "def", "get_kvlayer_stream_item_by_doc_id", "(", "client", ",", "doc_id", ")", ":", "if", "client", "is", "None", ":", "client", "=", "kvlayer", ".", "client", "(", ")", "client", ".", "setup_namespace", "(", "STREAM_ITEM_TABLE_DEFS", ",", "STREAM_ITEM_VALUE_DEFS"...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
get_kvlayer_stream_ids_by_doc_id
Retrieve stream ids from :mod:`kvlayer`. Namely, it returns an iterator over all stream ids with the given docid. The docid should be an md5 hash of the document's abs_url. :param client: kvlayer client object :type client: :class:`kvlayer.AbstractStorage` :param str doc_id: doc id of documents to...
streamcorpus_pipeline/_kvlayer.py
def get_kvlayer_stream_ids_by_doc_id(client, doc_id): '''Retrieve stream ids from :mod:`kvlayer`. Namely, it returns an iterator over all stream ids with the given docid. The docid should be an md5 hash of the document's abs_url. :param client: kvlayer client object :type client: :class:`kvlayer.A...
def get_kvlayer_stream_ids_by_doc_id(client, doc_id): '''Retrieve stream ids from :mod:`kvlayer`. Namely, it returns an iterator over all stream ids with the given docid. The docid should be an md5 hash of the document's abs_url. :param client: kvlayer client object :type client: :class:`kvlayer.A...
[ "Retrieve", "stream", "ids", "from", ":", "mod", ":", "kvlayer", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer.py#L249-L266
[ "def", "get_kvlayer_stream_ids_by_doc_id", "(", "client", ",", "doc_id", ")", ":", "if", "client", "is", "None", ":", "client", "=", "kvlayer", ".", "client", "(", ")", "client", ".", "setup_namespace", "(", "STREAM_ITEM_TABLE_DEFS", ",", "STREAM_ITEM_VALUE_DEFS",...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
serialize_si_key
Return packed bytes representation of StreamItem kvlayer key. The result is 20 bytes, 16 of md5 hash, 4 of int timestamp.
streamcorpus_pipeline/_kvlayer.py
def serialize_si_key(si_key): ''' Return packed bytes representation of StreamItem kvlayer key. The result is 20 bytes, 16 of md5 hash, 4 of int timestamp. ''' if len(si_key[0]) != 16: raise ValueError('bad StreamItem key, expected 16 byte ' 'md5 hash binary digest, ...
def serialize_si_key(si_key): ''' Return packed bytes representation of StreamItem kvlayer key. The result is 20 bytes, 16 of md5 hash, 4 of int timestamp. ''' if len(si_key[0]) != 16: raise ValueError('bad StreamItem key, expected 16 byte ' 'md5 hash binary digest, ...
[ "Return", "packed", "bytes", "representation", "of", "StreamItem", "kvlayer", "key", ".", "The", "result", "is", "20", "bytes", "16", "of", "md5", "hash", "4", "of", "int", "timestamp", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer.py#L392-L400
[ "def", "serialize_si_key", "(", "si_key", ")", ":", "if", "len", "(", "si_key", "[", "0", "]", ")", "!=", "16", ":", "raise", "ValueError", "(", "'bad StreamItem key, expected 16 byte '", "'md5 hash binary digest, got: {0!r}'", ".", "format", "(", "si_key", ")", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
streamitem_to_key_data
extract the parts of a StreamItem that go into a kvlayer key, convert StreamItem to blob for storage. return (kvlayer key tuple), data blob
streamcorpus_pipeline/_kvlayer.py
def streamitem_to_key_data(si): ''' extract the parts of a StreamItem that go into a kvlayer key, convert StreamItem to blob for storage. return (kvlayer key tuple), data blob ''' key = key_for_stream_item(si) data = streamcorpus.serialize(si) errors, data = streamcorpus.compress_and_en...
def streamitem_to_key_data(si): ''' extract the parts of a StreamItem that go into a kvlayer key, convert StreamItem to blob for storage. return (kvlayer key tuple), data blob ''' key = key_for_stream_item(si) data = streamcorpus.serialize(si) errors, data = streamcorpus.compress_and_en...
[ "extract", "the", "parts", "of", "a", "StreamItem", "that", "go", "into", "a", "kvlayer", "key", "convert", "StreamItem", "to", "blob", "for", "storage", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_kvlayer.py#L411-L422
[ "def", "streamitem_to_key_data", "(", "si", ")", ":", "key", "=", "key_for_stream_item", "(", "si", ")", "data", "=", "streamcorpus", ".", "serialize", "(", "si", ")", "errors", ",", "data", "=", "streamcorpus", ".", "compress_and_encrypt", "(", "data", ")",...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
working_directory
Change working directory and restore the previous on exit
wimpy/util.py
def working_directory(path): """Change working directory and restore the previous on exit""" prev_dir = os.getcwd() os.chdir(str(path)) try: yield finally: os.chdir(prev_dir)
def working_directory(path): """Change working directory and restore the previous on exit""" prev_dir = os.getcwd() os.chdir(str(path)) try: yield finally: os.chdir(prev_dir)
[ "Change", "working", "directory", "and", "restore", "the", "previous", "on", "exit" ]
wimglenn/wimpy
python
https://github.com/wimglenn/wimpy/blob/4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e/wimpy/util.py#L41-L48
[ "def", "working_directory", "(", "path", ")", ":", "prev_dir", "=", "os", ".", "getcwd", "(", ")", "os", ".", "chdir", "(", "str", "(", "path", ")", ")", "try", ":", "yield", "finally", ":", "os", ".", "chdir", "(", "prev_dir", ")" ]
4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e
test
strip_prefix
Removes the prefix, if it's there, otherwise returns input string unchanged. If strict is True, also ensures the prefix was present
wimpy/util.py
def strip_prefix(s, prefix, strict=False): """Removes the prefix, if it's there, otherwise returns input string unchanged. If strict is True, also ensures the prefix was present""" if s.startswith(prefix): return s[len(prefix) :] elif strict: raise WimpyError("string doesn't start with p...
def strip_prefix(s, prefix, strict=False): """Removes the prefix, if it's there, otherwise returns input string unchanged. If strict is True, also ensures the prefix was present""" if s.startswith(prefix): return s[len(prefix) :] elif strict: raise WimpyError("string doesn't start with p...
[ "Removes", "the", "prefix", "if", "it", "s", "there", "otherwise", "returns", "input", "string", "unchanged", ".", "If", "strict", "is", "True", "also", "ensures", "the", "prefix", "was", "present" ]
wimglenn/wimpy
python
https://github.com/wimglenn/wimpy/blob/4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e/wimpy/util.py#L51-L58
[ "def", "strip_prefix", "(", "s", ",", "prefix", ",", "strict", "=", "False", ")", ":", "if", "s", ".", "startswith", "(", "prefix", ")", ":", "return", "s", "[", "len", "(", "prefix", ")", ":", "]", "elif", "strict", ":", "raise", "WimpyError", "("...
4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e
test
strip_suffix
Removes the suffix, if it's there, otherwise returns input string unchanged. If strict is True, also ensures the suffix was present
wimpy/util.py
def strip_suffix(s, suffix, strict=False): """Removes the suffix, if it's there, otherwise returns input string unchanged. If strict is True, also ensures the suffix was present""" if s.endswith(suffix): return s[: len(s) - len(suffix)] elif strict: raise WimpyError("string doesn't end w...
def strip_suffix(s, suffix, strict=False): """Removes the suffix, if it's there, otherwise returns input string unchanged. If strict is True, also ensures the suffix was present""" if s.endswith(suffix): return s[: len(s) - len(suffix)] elif strict: raise WimpyError("string doesn't end w...
[ "Removes", "the", "suffix", "if", "it", "s", "there", "otherwise", "returns", "input", "string", "unchanged", ".", "If", "strict", "is", "True", "also", "ensures", "the", "suffix", "was", "present" ]
wimglenn/wimpy
python
https://github.com/wimglenn/wimpy/blob/4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e/wimpy/util.py#L61-L68
[ "def", "strip_suffix", "(", "s", ",", "suffix", ",", "strict", "=", "False", ")", ":", "if", "s", ".", "endswith", "(", "suffix", ")", ":", "return", "s", "[", ":", "len", "(", "s", ")", "-", "len", "(", "suffix", ")", "]", "elif", "strict", ":...
4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e
test
is_subsequence
Are all the elements of needle contained in haystack, and in the same order? There may be other elements interspersed throughout
wimpy/util.py
def is_subsequence(needle, haystack): """Are all the elements of needle contained in haystack, and in the same order? There may be other elements interspersed throughout""" it = iter(haystack) for element in needle: if element not in it: return False return True
def is_subsequence(needle, haystack): """Are all the elements of needle contained in haystack, and in the same order? There may be other elements interspersed throughout""" it = iter(haystack) for element in needle: if element not in it: return False return True
[ "Are", "all", "the", "elements", "of", "needle", "contained", "in", "haystack", "and", "in", "the", "same", "order?", "There", "may", "be", "other", "elements", "interspersed", "throughout" ]
wimglenn/wimpy
python
https://github.com/wimglenn/wimpy/blob/4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e/wimpy/util.py#L110-L117
[ "def", "is_subsequence", "(", "needle", ",", "haystack", ")", ":", "it", "=", "iter", "(", "haystack", ")", "for", "element", "in", "needle", ":", "if", "element", "not", "in", "it", ":", "return", "False", "return", "True" ]
4e8ebe4e7052d88c9f88ac7dcaa1b587cc2cf86e
test
cube
Return an Ice application with a default home page. Create :class:`Ice` object, add a route to return the default page when a client requests the server root, i.e. /, using HTTP GET method, add an error handler to return HTTP error pages when an error occurs and return this object. The returned object ...
ice.py
def cube(): """Return an Ice application with a default home page. Create :class:`Ice` object, add a route to return the default page when a client requests the server root, i.e. /, using HTTP GET method, add an error handler to return HTTP error pages when an error occurs and return this object. T...
def cube(): """Return an Ice application with a default home page. Create :class:`Ice` object, add a route to return the default page when a client requests the server root, i.e. /, using HTTP GET method, add an error handler to return HTTP error pages when an error occurs and return this object. T...
[ "Return", "an", "Ice", "application", "with", "a", "default", "home", "page", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L50-L91
[ "def", "cube", "(", ")", ":", "app", "=", "Ice", "(", ")", "@", "app", ".", "get", "(", "'/'", ")", "def", "default_home_page", "(", ")", ":", "\"\"\"Return a default home page.\"\"\"", "return", "simple_html", "(", "'It works!'", ",", "'<h1>It works!</h1>\\n'...
532e685c504ea96f9e42833594585159ac1d2068
test
Ice.run
Run the application using a simple WSGI server. Arguments: host (str, optional): Host on which to listen. port (int, optional): Port number on which to listen.
ice.py
def run(self, host='127.0.0.1', port=8080): """Run the application using a simple WSGI server. Arguments: host (str, optional): Host on which to listen. port (int, optional): Port number on which to listen. """ from wsgiref import simple_server self._server =...
def run(self, host='127.0.0.1', port=8080): """Run the application using a simple WSGI server. Arguments: host (str, optional): Host on which to listen. port (int, optional): Port number on which to listen. """ from wsgiref import simple_server self._server =...
[ "Run", "the", "application", "using", "a", "simple", "WSGI", "server", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L108-L117
[ "def", "run", "(", "self", ",", "host", "=", "'127.0.0.1'", ",", "port", "=", "8080", ")", ":", "from", "wsgiref", "import", "simple_server", "self", ".", "_server", "=", "simple_server", ".", "make_server", "(", "host", ",", "port", ",", "self", ")", ...
532e685c504ea96f9e42833594585159ac1d2068
test
Ice.exit
Stop the simple WSGI server running the appliation.
ice.py
def exit(self): """Stop the simple WSGI server running the appliation.""" if self._server is not None: self._server.shutdown() self._server.server_close() self._server = None
def exit(self): """Stop the simple WSGI server running the appliation.""" if self._server is not None: self._server.shutdown() self._server.server_close() self._server = None
[ "Stop", "the", "simple", "WSGI", "server", "running", "the", "appliation", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L119-L124
[ "def", "exit", "(", "self", ")", ":", "if", "self", ".", "_server", "is", "not", "None", ":", "self", ".", "_server", ".", "shutdown", "(", ")", "self", ".", "_server", ".", "server_close", "(", ")", "self", ".", "_server", "=", "None" ]
532e685c504ea96f9e42833594585159ac1d2068
test
Ice.route
Decorator to add route for a request with any HTTP method. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. pattern (str): Routing pattern the path must match. Returns: function: Decorator function to add route.
ice.py
def route(self, method, pattern): """Decorator to add route for a request with any HTTP method. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. pattern (str): Routing pattern the path must match. Returns: function: Decorator function to add route. ...
def route(self, method, pattern): """Decorator to add route for a request with any HTTP method. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. pattern (str): Routing pattern the path must match. Returns: function: Decorator function to add route. ...
[ "Decorator", "to", "add", "route", "for", "a", "request", "with", "any", "HTTP", "method", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L157-L170
[ "def", "route", "(", "self", ",", "method", ",", "pattern", ")", ":", "def", "decorator", "(", "callback", ")", ":", "self", ".", "_router", ".", "add", "(", "method", ",", "pattern", ",", "callback", ")", "return", "callback", "return", "decorator" ]
532e685c504ea96f9e42833594585159ac1d2068
test
Ice.error
Decorator to add a callback that generates error page. The *status* parameter specifies the HTTP response status code for which the decorated callback should be invoked. If the *status* argument is not specified, then the decorated callable is considered to be a fallback callback. ...
ice.py
def error(self, status=None): """Decorator to add a callback that generates error page. The *status* parameter specifies the HTTP response status code for which the decorated callback should be invoked. If the *status* argument is not specified, then the decorated callable is co...
def error(self, status=None): """Decorator to add a callback that generates error page. The *status* parameter specifies the HTTP response status code for which the decorated callback should be invoked. If the *status* argument is not specified, then the decorated callable is co...
[ "Decorator", "to", "add", "a", "callback", "that", "generates", "error", "page", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L172-L194
[ "def", "error", "(", "self", ",", "status", "=", "None", ")", ":", "def", "decorator", "(", "callback", ")", ":", "self", ".", "_error_handlers", "[", "status", "]", "=", "callback", "return", "callback", "return", "decorator" ]
532e685c504ea96f9e42833594585159ac1d2068
test
Ice.static
Send content of a static file as response. The path to the document root directory should be specified as the root argument. This is very important to prevent directory traversal attack. This method guarantees that only files within the document root directory are served and no files ou...
ice.py
def static(self, root, path, media_type=None, charset='UTF-8'): """Send content of a static file as response. The path to the document root directory should be specified as the root argument. This is very important to prevent directory traversal attack. This method guarantees that only ...
def static(self, root, path, media_type=None, charset='UTF-8'): """Send content of a static file as response. The path to the document root directory should be specified as the root argument. This is very important to prevent directory traversal attack. This method guarantees that only ...
[ "Send", "content", "of", "a", "static", "file", "as", "response", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L196-L243
[ "def", "static", "(", "self", ",", "root", ",", "path", ",", "media_type", "=", "None", ",", "charset", "=", "'UTF-8'", ")", ":", "root", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "root", ",", "''", ")", ...
532e685c504ea96f9e42833594585159ac1d2068
test
Ice.download
Send content as attachment (downloadable file). The *content* is sent after setting Content-Disposition header such that the client prompts the user to save the content locally as a file. An HTTP response status code may be specified as *content*. If the status code is not ``200``, then...
ice.py
def download(self, content, filename=None, media_type=None, charset='UTF-8'): """Send content as attachment (downloadable file). The *content* is sent after setting Content-Disposition header such that the client prompts the user to save the content locally as a file. A...
def download(self, content, filename=None, media_type=None, charset='UTF-8'): """Send content as attachment (downloadable file). The *content* is sent after setting Content-Disposition header such that the client prompts the user to save the content locally as a file. A...
[ "Send", "content", "as", "attachment", "(", "downloadable", "file", ")", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L245-L308
[ "def", "download", "(", "self", ",", "content", ",", "filename", "=", "None", ",", "media_type", "=", "None", ",", "charset", "=", "'UTF-8'", ")", ":", "if", "isinstance", "(", "content", ",", "int", ")", "and", "content", "!=", "200", ":", "return", ...
532e685c504ea96f9e42833594585159ac1d2068
test
Ice._get_error_page_callback
Return an error page for the current response status.
ice.py
def _get_error_page_callback(self): """Return an error page for the current response status.""" if self.response.status in self._error_handlers: return self._error_handlers[self.response.status] elif None in self._error_handlers: return self._error_handlers[None] ...
def _get_error_page_callback(self): """Return an error page for the current response status.""" if self.response.status in self._error_handlers: return self._error_handlers[self.response.status] elif None in self._error_handlers: return self._error_handlers[None] ...
[ "Return", "an", "error", "page", "for", "the", "current", "response", "status", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L359-L368
[ "def", "_get_error_page_callback", "(", "self", ")", ":", "if", "self", ".", "response", ".", "status", "in", "self", ".", "_error_handlers", ":", "return", "self", ".", "_error_handlers", "[", "self", ".", "response", ".", "status", "]", "elif", "None", "...
532e685c504ea96f9e42833594585159ac1d2068
test
Router.add
Add a route. Arguments: method (str): HTTP method, e.g. GET, POST, etc. pattern (str): Pattern that request paths must match. callback (str): Route handler that is invoked when a request path matches the *pattern*.
ice.py
def add(self, method, pattern, callback): """Add a route. Arguments: method (str): HTTP method, e.g. GET, POST, etc. pattern (str): Pattern that request paths must match. callback (str): Route handler that is invoked when a request path matches the *pattern*. ...
def add(self, method, pattern, callback): """Add a route. Arguments: method (str): HTTP method, e.g. GET, POST, etc. pattern (str): Pattern that request paths must match. callback (str): Route handler that is invoked when a request path matches the *pattern*. ...
[ "Add", "a", "route", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L381-L396
[ "def", "add", "(", "self", ",", "method", ",", "pattern", ",", "callback", ")", ":", "pat_type", ",", "pat", "=", "self", ".", "_normalize_pattern", "(", "pattern", ")", "if", "pat_type", "==", "'literal'", ":", "self", ".", "_literal", "[", "method", ...
532e685c504ea96f9e42833594585159ac1d2068
test
Router.contains_method
Check if there is at least one handler for *method*. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. Returns: ``True`` if there is at least one route defined for *method*, ``False`` otherwise
ice.py
def contains_method(self, method): """Check if there is at least one handler for *method*. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. Returns: ``True`` if there is at least one route defined for *method*, ``False`` otherwise """ ...
def contains_method(self, method): """Check if there is at least one handler for *method*. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. Returns: ``True`` if there is at least one route defined for *method*, ``False`` otherwise """ ...
[ "Check", "if", "there", "is", "at", "least", "one", "handler", "for", "*", "method", "*", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L398-L409
[ "def", "contains_method", "(", "self", ",", "method", ")", ":", "return", "method", "in", "itertools", ".", "chain", "(", "self", ".", "_literal", ",", "self", ".", "_wildcard", ",", "self", ".", "_regex", ")" ]
532e685c504ea96f9e42833594585159ac1d2068
test
Router.resolve
Resolve a request to a route handler. Arguments: method (str): HTTP method, e.g. GET, POST, etc. (type: str) path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) 2. Positional arguments (list) ...
ice.py
def resolve(self, method, path): """Resolve a request to a route handler. Arguments: method (str): HTTP method, e.g. GET, POST, etc. (type: str) path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) ...
def resolve(self, method, path): """Resolve a request to a route handler. Arguments: method (str): HTTP method, e.g. GET, POST, etc. (type: str) path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) ...
[ "Resolve", "a", "request", "to", "a", "route", "handler", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L411-L430
[ "def", "resolve", "(", "self", ",", "method", ",", "path", ")", ":", "if", "method", "in", "self", ".", "_literal", "and", "path", "in", "self", ".", "_literal", "[", "method", "]", ":", "return", "self", ".", "_literal", "[", "method", "]", "[", "...
532e685c504ea96f9e42833594585159ac1d2068
test
Router._resolve_non_literal_route
Resolve a request to a wildcard or regex route handler. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) 2. Positional arguments (l...
ice.py
def _resolve_non_literal_route(self, method, path): """Resolve a request to a wildcard or regex route handler. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. path (str): Request path Returns: tuple or None: A tuple of three items: 1. ...
def _resolve_non_literal_route(self, method, path): """Resolve a request to a wildcard or regex route handler. Arguments: method (str): HTTP method name, e.g. GET, POST, etc. path (str): Request path Returns: tuple or None: A tuple of three items: 1. ...
[ "Resolve", "a", "request", "to", "a", "wildcard", "or", "regex", "route", "handler", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L433-L455
[ "def", "_resolve_non_literal_route", "(", "self", ",", "method", ",", "path", ")", ":", "for", "route_dict", "in", "(", "self", ".", "_wildcard", ",", "self", ".", "_regex", ")", ":", "if", "method", "in", "route_dict", ":", "for", "route", "in", "revers...
532e685c504ea96f9e42833594585159ac1d2068
test
Router._normalize_pattern
Return a normalized form of the pattern. Normalize the pattern by removing pattern type prefix if it exists in the pattern. Then return the pattern type and the pattern as a tuple of two strings. Arguments: pattern (str): Route pattern to match request paths Returns:...
ice.py
def _normalize_pattern(pattern): """Return a normalized form of the pattern. Normalize the pattern by removing pattern type prefix if it exists in the pattern. Then return the pattern type and the pattern as a tuple of two strings. Arguments: pattern (str): Route patt...
def _normalize_pattern(pattern): """Return a normalized form of the pattern. Normalize the pattern by removing pattern type prefix if it exists in the pattern. Then return the pattern type and the pattern as a tuple of two strings. Arguments: pattern (str): Route patt...
[ "Return", "a", "normalized", "form", "of", "the", "pattern", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L458-L486
[ "def", "_normalize_pattern", "(", "pattern", ")", ":", "if", "pattern", ".", "startswith", "(", "'regex:'", ")", ":", "pattern_type", "=", "'regex'", "pattern", "=", "pattern", "[", "len", "(", "'regex:'", ")", ":", "]", "elif", "pattern", ".", "startswith...
532e685c504ea96f9e42833594585159ac1d2068
test
WildcardRoute.match
Return route handler with arguments if path matches this route. Arguments: path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) 2. Positional arguments (list) 3. Keyword arguments (dict) ...
ice.py
def match(self, path): """Return route handler with arguments if path matches this route. Arguments: path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) 2. Positional arguments (list) 3. K...
def match(self, path): """Return route handler with arguments if path matches this route. Arguments: path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) 2. Positional arguments (list) 3. K...
[ "Return", "route", "handler", "with", "arguments", "if", "path", "matches", "this", "route", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L515-L543
[ "def", "match", "(", "self", ",", "path", ")", ":", "match", "=", "self", ".", "_re", ".", "search", "(", "path", ")", "if", "match", "is", "None", ":", "return", "None", "args", "=", "[", "]", "kwargs", "=", "{", "}", "for", "i", ",", "wildcar...
532e685c504ea96f9e42833594585159ac1d2068
test
RegexRoute.match
Return route handler with arguments if path matches this route. Arguments: path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) 2. Positional arguments (list) 3. Keyword arguments (dict) ...
ice.py
def match(self, path): """Return route handler with arguments if path matches this route. Arguments: path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) 2. Positional arguments (list) 3. K...
def match(self, path): """Return route handler with arguments if path matches this route. Arguments: path (str): Request path Returns: tuple or None: A tuple of three items: 1. Route handler (callable) 2. Positional arguments (list) 3. K...
[ "Return", "route", "handler", "with", "arguments", "if", "path", "matches", "this", "route", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L641-L666
[ "def", "match", "(", "self", ",", "path", ")", ":", "match", "=", "self", ".", "_re", ".", "search", "(", "path", ")", "if", "match", "is", "None", ":", "return", "None", "kwargs_indexes", "=", "match", ".", "re", ".", "groupindex", ".", "values", ...
532e685c504ea96f9e42833594585159ac1d2068
test
Response.response
Return the HTTP response body. Returns: bytes: HTTP response body as a sequence of bytes
ice.py
def response(self): """Return the HTTP response body. Returns: bytes: HTTP response body as a sequence of bytes """ if isinstance(self.body, bytes): out = self.body elif isinstance(self.body, str): out = self.body.encode(self.charset) el...
def response(self): """Return the HTTP response body. Returns: bytes: HTTP response body as a sequence of bytes """ if isinstance(self.body, bytes): out = self.body elif isinstance(self.body, str): out = self.body.encode(self.charset) el...
[ "Return", "the", "HTTP", "response", "body", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L766-L782
[ "def", "response", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "body", ",", "bytes", ")", ":", "out", "=", "self", ".", "body", "elif", "isinstance", "(", "self", ".", "body", ",", "str", ")", ":", "out", "=", "self", ".", "body"...
532e685c504ea96f9e42833594585159ac1d2068
test
Response.add_header
Add an HTTP header to response object. Arguments: name (str): HTTP header field name value (str): HTTP header field value
ice.py
def add_header(self, name, value): """Add an HTTP header to response object. Arguments: name (str): HTTP header field name value (str): HTTP header field value """ if value is not None: self._headers.append((name, value))
def add_header(self, name, value): """Add an HTTP header to response object. Arguments: name (str): HTTP header field name value (str): HTTP header field value """ if value is not None: self._headers.append((name, value))
[ "Add", "an", "HTTP", "header", "to", "response", "object", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L784-L792
[ "def", "add_header", "(", "self", ",", "name", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "self", ".", "_headers", ".", "append", "(", "(", "name", ",", "value", ")", ")" ]
532e685c504ea96f9e42833594585159ac1d2068
test
Response.set_cookie
Add a Set-Cookie header to response object. For a description about cookie attribute values, see https://docs.python.org/3/library/http.cookies.html#http.cookies.Morsel. Arguments: name (str): Name of the cookie value (str): Value of the cookie attrs (dict): Dicit...
ice.py
def set_cookie(self, name, value, attrs={}): """Add a Set-Cookie header to response object. For a description about cookie attribute values, see https://docs.python.org/3/library/http.cookies.html#http.cookies.Morsel. Arguments: name (str): Name of the cookie value ...
def set_cookie(self, name, value, attrs={}): """Add a Set-Cookie header to response object. For a description about cookie attribute values, see https://docs.python.org/3/library/http.cookies.html#http.cookies.Morsel. Arguments: name (str): Name of the cookie value ...
[ "Add", "a", "Set", "-", "Cookie", "header", "to", "response", "object", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L794-L810
[ "def", "set_cookie", "(", "self", ",", "name", ",", "value", ",", "attrs", "=", "{", "}", ")", ":", "cookie", "=", "http", ".", "cookies", ".", "SimpleCookie", "(", ")", "cookie", "[", "name", "]", "=", "value", "for", "key", ",", "value", "in", ...
532e685c504ea96f9e42833594585159ac1d2068
test
Response.status_line
Return the HTTP response status line. The status line is determined from :attr:`status` code. For example, if the status code is 200, then '200 OK' is returned. Returns: str: Status line
ice.py
def status_line(self): """Return the HTTP response status line. The status line is determined from :attr:`status` code. For example, if the status code is 200, then '200 OK' is returned. Returns: str: Status line """ return (str(self.status) + ' ' + ...
def status_line(self): """Return the HTTP response status line. The status line is determined from :attr:`status` code. For example, if the status code is 200, then '200 OK' is returned. Returns: str: Status line """ return (str(self.status) + ' ' + ...
[ "Return", "the", "HTTP", "response", "status", "line", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L813-L823
[ "def", "status_line", "(", "self", ")", ":", "return", "(", "str", "(", "self", ".", "status", ")", "+", "' '", "+", "Response", ".", "_responses", "[", "self", ".", "status", "]", ".", "phrase", ")" ]
532e685c504ea96f9e42833594585159ac1d2068
test
Response.content_type
Return the value of Content-Type header field. The value for the Content-Type header field is determined from the :attr:`media_type` and :attr:`charset` data attributes. Returns: str: Value of Content-Type header field
ice.py
def content_type(self): """Return the value of Content-Type header field. The value for the Content-Type header field is determined from the :attr:`media_type` and :attr:`charset` data attributes. Returns: str: Value of Content-Type header field """ if (self.m...
def content_type(self): """Return the value of Content-Type header field. The value for the Content-Type header field is determined from the :attr:`media_type` and :attr:`charset` data attributes. Returns: str: Value of Content-Type header field """ if (self.m...
[ "Return", "the", "value", "of", "Content", "-", "Type", "header", "field", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L835-L849
[ "def", "content_type", "(", "self", ")", ":", "if", "(", "self", ".", "media_type", "is", "not", "None", "and", "self", ".", "media_type", ".", "startswith", "(", "'text/'", ")", "and", "self", ".", "charset", "is", "not", "None", ")", ":", "return", ...
532e685c504ea96f9e42833594585159ac1d2068
test
MultiDict.getall
Return the list of all values for the specified key. Arguments: key (object): Key default (list): Default value to return if the key does not exist, defaults to ``[]``, i.e. an empty list. Returns: list: List of all values for the specified key if the key ...
ice.py
def getall(self, key, default=[]): """Return the list of all values for the specified key. Arguments: key (object): Key default (list): Default value to return if the key does not exist, defaults to ``[]``, i.e. an empty list. Returns: list: List of al...
def getall(self, key, default=[]): """Return the list of all values for the specified key. Arguments: key (object): Key default (list): Default value to return if the key does not exist, defaults to ``[]``, i.e. an empty list. Returns: list: List of al...
[ "Return", "the", "list", "of", "all", "values", "for", "the", "specified", "key", "." ]
susam/ice
python
https://github.com/susam/ice/blob/532e685c504ea96f9e42833594585159ac1d2068/ice.py#L884-L896
[ "def", "getall", "(", "self", ",", "key", ",", "default", "=", "[", "]", ")", ":", "return", "self", ".", "data", "[", "key", "]", "if", "key", "in", "self", ".", "data", "else", "default" ]
532e685c504ea96f9e42833594585159ac1d2068
test
rmtree
remove all files and directories below path, including path itself; works even when shutil.rmtree fails because of read-only files in NFS and Windows. Follows symlinks. `use_shutil` defaults to True; useful for testing `followlinks` defaults to False; if set to True, shutil.rmtree is not used.
streamcorpus_pipeline/_rmtree.py
def rmtree(path, use_shutil=True, followlinks=False, retries=10): '''remove all files and directories below path, including path itself; works even when shutil.rmtree fails because of read-only files in NFS and Windows. Follows symlinks. `use_shutil` defaults to True; useful for testing `followli...
def rmtree(path, use_shutil=True, followlinks=False, retries=10): '''remove all files and directories below path, including path itself; works even when shutil.rmtree fails because of read-only files in NFS and Windows. Follows symlinks. `use_shutil` defaults to True; useful for testing `followli...
[ "remove", "all", "files", "and", "directories", "below", "path", "including", "path", "itself", ";", "works", "even", "when", "shutil", ".", "rmtree", "fails", "because", "of", "read", "-", "only", "files", "in", "NFS", "and", "Windows", ".", "Follows", "s...
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_rmtree.py#L17-L64
[ "def", "rmtree", "(", "path", ",", "use_shutil", "=", "True", ",", "followlinks", "=", "False", ",", "retries", "=", "10", ")", ":", "if", "use_shutil", "and", "not", "followlinks", ":", "try", ":", "shutil", ".", "rmtree", "(", "path", ")", "return", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
get_open_fds
return list of open files for current process .. warning: will only work on UNIX-like os-es.
streamcorpus_pipeline/_rmtree.py
def get_open_fds(verbose=False): '''return list of open files for current process .. warning: will only work on UNIX-like os-es. ''' pid = os.getpid() procs = subprocess.check_output( [ "lsof", '-w', '-Ff', "-p", str( pid ) ] ) if verbose: oprocs = subprocess.check_output( ...
def get_open_fds(verbose=False): '''return list of open files for current process .. warning: will only work on UNIX-like os-es. ''' pid = os.getpid() procs = subprocess.check_output( [ "lsof", '-w', '-Ff', "-p", str( pid ) ] ) if verbose: oprocs = subprocess.check_output( ...
[ "return", "list", "of", "open", "files", "for", "current", "process" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_rmtree.py#L66-L81
[ "def", "get_open_fds", "(", "verbose", "=", "False", ")", ":", "pid", "=", "os", ".", "getpid", "(", ")", "procs", "=", "subprocess", ".", "check_output", "(", "[", "\"lsof\"", ",", "'-w'", ",", "'-Ff'", ",", "\"-p\"", ",", "str", "(", "pid", ")", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
file_type_stats
returns a kba.pipeline "transform" function that generates file type stats from the stream_items that it sees. Currently, these stats are just the first five non-whitespace characters.
streamcorpus_pipeline/_guess_media_type.py
def file_type_stats(config): ''' returns a kba.pipeline "transform" function that generates file type stats from the stream_items that it sees. Currently, these stats are just the first five non-whitespace characters. ''' ## make a closure around config def _file_type_stats(stream_item, con...
def file_type_stats(config): ''' returns a kba.pipeline "transform" function that generates file type stats from the stream_items that it sees. Currently, these stats are just the first five non-whitespace characters. ''' ## make a closure around config def _file_type_stats(stream_item, con...
[ "returns", "a", "kba", ".", "pipeline", "transform", "function", "that", "generates", "file", "type", "stats", "from", "the", "stream_items", "that", "it", "sees", ".", "Currently", "these", "stats", "are", "just", "the", "first", "five", "non", "-", "whites...
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_guess_media_type.py#L55-L100
[ "def", "file_type_stats", "(", "config", ")", ":", "## make a closure around config", "def", "_file_type_stats", "(", "stream_item", ",", "context", ")", ":", "if", "stream_item", ".", "body", "and", "stream_item", ".", "body", ".", "raw", ":", "#print repr(stream...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
rejester_run
get a rejester.WorkUnit with KBA s3 path, fetch it, and save some counts about it.
examples/verify_kba2014.py
def rejester_run(work_unit): '''get a rejester.WorkUnit with KBA s3 path, fetch it, and save some counts about it. ''' #fname = 'verify-chunks-%d-%d' % (os.getpid(), time.time()) fname = work_unit.key.strip().split('/')[-1] output_dir_path = work_unit.data.get('output_dir_path', '/mn...
def rejester_run(work_unit): '''get a rejester.WorkUnit with KBA s3 path, fetch it, and save some counts about it. ''' #fname = 'verify-chunks-%d-%d' % (os.getpid(), time.time()) fname = work_unit.key.strip().split('/')[-1] output_dir_path = work_unit.data.get('output_dir_path', '/mn...
[ "get", "a", "rejester", ".", "WorkUnit", "with", "KBA", "s3", "path", "fetch", "it", "and", "save", "some", "counts", "about", "it", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/examples/verify_kba2014.py#L34-L78
[ "def", "rejester_run", "(", "work_unit", ")", ":", "#fname = 'verify-chunks-%d-%d' % (os.getpid(), time.time())", "fname", "=", "work_unit", ".", "key", ".", "strip", "(", ")", ".", "split", "(", "'/'", ")", "[", "-", "1", "]", "output_dir_path", "=", "work_unit...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
attempt_fetch
attempt a fetch and iteration over a work_unit.key path in s3
examples/verify_kba2014.py
def attempt_fetch(work_unit, fpath): '''attempt a fetch and iteration over a work_unit.key path in s3 ''' url = 'http://s3.amazonaws.com/aws-publicdatasets/' + work_unit.key.strip() ## cheapest way to iterate over the corpus is a few stages of ## streamed child processes. Note that stderr nee...
def attempt_fetch(work_unit, fpath): '''attempt a fetch and iteration over a work_unit.key path in s3 ''' url = 'http://s3.amazonaws.com/aws-publicdatasets/' + work_unit.key.strip() ## cheapest way to iterate over the corpus is a few stages of ## streamed child processes. Note that stderr nee...
[ "attempt", "a", "fetch", "and", "iteration", "over", "a", "work_unit", ".", "key", "path", "in", "s3" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/examples/verify_kba2014.py#L80-L121
[ "def", "attempt_fetch", "(", "work_unit", ",", "fpath", ")", ":", "url", "=", "'http://s3.amazonaws.com/aws-publicdatasets/'", "+", "work_unit", ".", "key", ".", "strip", "(", ")", "## cheapest way to iterate over the corpus is a few stages of", "## streamed child processes. ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
get_file_lines
Return a list of non-empty lines from `file_path`.
adjspecies/__init__.py
def get_file_lines(file_name): """Return a list of non-empty lines from `file_path`.""" file_path = path.join(path.dirname(path.abspath(__file__)), file_name) with open(file_path) as file_obj: return [line for line in file_obj.read().splitlines() if line]
def get_file_lines(file_name): """Return a list of non-empty lines from `file_path`.""" file_path = path.join(path.dirname(path.abspath(__file__)), file_name) with open(file_path) as file_obj: return [line for line in file_obj.read().splitlines() if line]
[ "Return", "a", "list", "of", "non", "-", "empty", "lines", "from", "file_path", "." ]
hipikat/adjspecies
python
https://github.com/hipikat/adjspecies/blob/bffceceb08a868ea215f16dd341159d39ca75971/adjspecies/__init__.py#L25-L29
[ "def", "get_file_lines", "(", "file_name", ")", ":", "file_path", "=", "path", ".", "join", "(", "path", ".", "dirname", "(", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "file_name", ")", "with", "open", "(", "file_path", ")", "as", "file_o...
bffceceb08a868ea215f16dd341159d39ca75971
test
get_describers
Return a describer tuple in the form `(name, position)`, where position is either 'prefix' or 'suffix'.
adjspecies/__init__.py
def get_describers(): """ Return a describer tuple in the form `(name, position)`, where position is either 'prefix' or 'suffix'. """ adjectives = map(lambda x: (x, 'prefix'), get_file_lines('adjectives.txt')) animal_nouns = map(lambda x: (x, 'suffix'), get_file_lines('nouns.txt')) return li...
def get_describers(): """ Return a describer tuple in the form `(name, position)`, where position is either 'prefix' or 'suffix'. """ adjectives = map(lambda x: (x, 'prefix'), get_file_lines('adjectives.txt')) animal_nouns = map(lambda x: (x, 'suffix'), get_file_lines('nouns.txt')) return li...
[ "Return", "a", "describer", "tuple", "in", "the", "form", "(", "name", "position", ")", "where", "position", "is", "either", "prefix", "or", "suffix", "." ]
hipikat/adjspecies
python
https://github.com/hipikat/adjspecies/blob/bffceceb08a868ea215f16dd341159d39ca75971/adjspecies/__init__.py#L37-L44
[ "def", "get_describers", "(", ")", ":", "adjectives", "=", "map", "(", "lambda", "x", ":", "(", "x", ",", "'prefix'", ")", ",", "get_file_lines", "(", "'adjectives.txt'", ")", ")", "animal_nouns", "=", "map", "(", "lambda", "x", ":", "(", "x", ",", "...
bffceceb08a868ea215f16dd341159d39ca75971
test
_random_adjspecies_pair
Return an ordered 2-tuple containing a species and a describer.
adjspecies/__init__.py
def _random_adjspecies_pair(): """Return an ordered 2-tuple containing a species and a describer.""" describer, desc_position = random_describer() if desc_position == 'prefix': return (describer, random_species()) elif desc_position == 'suffix': return (random_species(), describer)
def _random_adjspecies_pair(): """Return an ordered 2-tuple containing a species and a describer.""" describer, desc_position = random_describer() if desc_position == 'prefix': return (describer, random_species()) elif desc_position == 'suffix': return (random_species(), describer)
[ "Return", "an", "ordered", "2", "-", "tuple", "containing", "a", "species", "and", "a", "describer", "." ]
hipikat/adjspecies
python
https://github.com/hipikat/adjspecies/blob/bffceceb08a868ea215f16dd341159d39ca75971/adjspecies/__init__.py#L52-L58
[ "def", "_random_adjspecies_pair", "(", ")", ":", "describer", ",", "desc_position", "=", "random_describer", "(", ")", "if", "desc_position", "==", "'prefix'", ":", "return", "(", "describer", ",", "random_species", "(", ")", ")", "elif", "desc_position", "==", ...
bffceceb08a868ea215f16dd341159d39ca75971
test
random_adjspecies_pair
Return an ordered 2-tuple containing a species and a describer. The letter-count of the pair is guarantee to not exceed `maxlen` if it is given. If `prevent_stutter` is True, the last letter of the first item of the pair will be different from the first letter of the second item.
adjspecies/__init__.py
def random_adjspecies_pair(maxlen=None, prevent_stutter=True): """ Return an ordered 2-tuple containing a species and a describer. The letter-count of the pair is guarantee to not exceed `maxlen` if it is given. If `prevent_stutter` is True, the last letter of the first item of the pair will be diff...
def random_adjspecies_pair(maxlen=None, prevent_stutter=True): """ Return an ordered 2-tuple containing a species and a describer. The letter-count of the pair is guarantee to not exceed `maxlen` if it is given. If `prevent_stutter` is True, the last letter of the first item of the pair will be diff...
[ "Return", "an", "ordered", "2", "-", "tuple", "containing", "a", "species", "and", "a", "describer", ".", "The", "letter", "-", "count", "of", "the", "pair", "is", "guarantee", "to", "not", "exceed", "maxlen", "if", "it", "is", "given", ".", "If", "pre...
hipikat/adjspecies
python
https://github.com/hipikat/adjspecies/blob/bffceceb08a868ea215f16dd341159d39ca75971/adjspecies/__init__.py#L61-L75
[ "def", "random_adjspecies_pair", "(", "maxlen", "=", "None", ",", "prevent_stutter", "=", "True", ")", ":", "while", "True", ":", "pair", "=", "_random_adjspecies_pair", "(", ")", "if", "maxlen", "and", "len", "(", "''", ".", "join", "(", "pair", ")", ")...
bffceceb08a868ea215f16dd341159d39ca75971
test
random_adjspecies
Return a random adjective/species, separated by `sep`. The keyword arguments `maxlen` and `prevent_stutter` are the same as for `random_adjspecies_pair`, but note that the maximum length argument is not affected by the separator.
adjspecies/__init__.py
def random_adjspecies(sep='', maxlen=8, prevent_stutter=True): """ Return a random adjective/species, separated by `sep`. The keyword arguments `maxlen` and `prevent_stutter` are the same as for `random_adjspecies_pair`, but note that the maximum length argument is not affected by the separator. ...
def random_adjspecies(sep='', maxlen=8, prevent_stutter=True): """ Return a random adjective/species, separated by `sep`. The keyword arguments `maxlen` and `prevent_stutter` are the same as for `random_adjspecies_pair`, but note that the maximum length argument is not affected by the separator. ...
[ "Return", "a", "random", "adjective", "/", "species", "separated", "by", "sep", ".", "The", "keyword", "arguments", "maxlen", "and", "prevent_stutter", "are", "the", "same", "as", "for", "random_adjspecies_pair", "but", "note", "that", "the", "maximum", "length"...
hipikat/adjspecies
python
https://github.com/hipikat/adjspecies/blob/bffceceb08a868ea215f16dd341159d39ca75971/adjspecies/__init__.py#L78-L86
[ "def", "random_adjspecies", "(", "sep", "=", "''", ",", "maxlen", "=", "8", ",", "prevent_stutter", "=", "True", ")", ":", "pair", "=", "random_adjspecies_pair", "(", "maxlen", ",", "prevent_stutter", ")", "return", "pair", "[", "0", "]", "+", "sep", "+"...
bffceceb08a868ea215f16dd341159d39ca75971
test
morph
Morphological analysis for Japanese.
goolabs/commands.py
def morph(ctx, app_id, sentence_file, json_flag, sentence, info_filter, pos_filter, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode, unicode) -> None # NOQA """ Morphological analysis for Japanese.""" app_id = clean_app_id(app_id) sentence = clean_senten...
def morph(ctx, app_id, sentence_file, json_flag, sentence, info_filter, pos_filter, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode, unicode) -> None # NOQA """ Morphological analysis for Japanese.""" app_id = clean_app_id(app_id) sentence = clean_senten...
[ "Morphological", "analysis", "for", "Japanese", "." ]
tell-k/goolabs
python
https://github.com/tell-k/goolabs/blob/3b87d0409e55c71290158ad6d5e2d8bb9a338c46/goolabs/commands.py#L107-L135
[ "def", "morph", "(", "ctx", ",", "app_id", ",", "sentence_file", ",", "json_flag", ",", "sentence", ",", "info_filter", ",", "pos_filter", ",", "request_id", ")", ":", "# type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode, unicode) -> None # NOQA", "app...
3b87d0409e55c71290158ad6d5e2d8bb9a338c46
test
similarity
Scoring the similarity of two words.
goolabs/commands.py
def similarity(ctx, app_id, json_flag, query_pair, request_id): # type: (Context, unicode, bool, List[unicode], unicode) -> None """ Scoring the similarity of two words. """ app_id = clean_app_id(app_id) api = GoolabsAPI(app_id) ret = api.similarity( query_pair=query_pair, request_...
def similarity(ctx, app_id, json_flag, query_pair, request_id): # type: (Context, unicode, bool, List[unicode], unicode) -> None """ Scoring the similarity of two words. """ app_id = clean_app_id(app_id) api = GoolabsAPI(app_id) ret = api.similarity( query_pair=query_pair, request_...
[ "Scoring", "the", "similarity", "of", "two", "words", "." ]
tell-k/goolabs
python
https://github.com/tell-k/goolabs/blob/3b87d0409e55c71290158ad6d5e2d8bb9a338c46/goolabs/commands.py#L144-L160
[ "def", "similarity", "(", "ctx", ",", "app_id", ",", "json_flag", ",", "query_pair", ",", "request_id", ")", ":", "# type: (Context, unicode, bool, List[unicode], unicode) -> None", "app_id", "=", "clean_app_id", "(", "app_id", ")", "api", "=", "GoolabsAPI", "(", "a...
3b87d0409e55c71290158ad6d5e2d8bb9a338c46
test
hiragana
Convert the Japanese to Hiragana or Katakana.
goolabs/commands.py
def hiragana(ctx, app_id, sentence_file, json_flag, sentence, output_type, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA """ Convert the Japanese to Hiragana or Katakana. """ app_id = clean_app_id(app_id) sentence = clean_sentence(sen...
def hiragana(ctx, app_id, sentence_file, json_flag, sentence, output_type, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA """ Convert the Japanese to Hiragana or Katakana. """ app_id = clean_app_id(app_id) sentence = clean_sentence(sen...
[ "Convert", "the", "Japanese", "to", "Hiragana", "or", "Katakana", "." ]
tell-k/goolabs
python
https://github.com/tell-k/goolabs/blob/3b87d0409e55c71290158ad6d5e2d8bb9a338c46/goolabs/commands.py#L172-L191
[ "def", "hiragana", "(", "ctx", ",", "app_id", ",", "sentence_file", ",", "json_flag", ",", "sentence", ",", "output_type", ",", "request_id", ")", ":", "# type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA", "app_id", "=", "clean_app_id",...
3b87d0409e55c71290158ad6d5e2d8bb9a338c46
test
entity
Extract unique representation from sentence.
goolabs/commands.py
def entity(ctx, app_id, sentence_file, json_flag, sentence, class_filter, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA """ Extract unique representation from sentence. """ app_id = clean_app_id(app_id) sentence = clean_sentence(sentenc...
def entity(ctx, app_id, sentence_file, json_flag, sentence, class_filter, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA """ Extract unique representation from sentence. """ app_id = clean_app_id(app_id) sentence = clean_sentence(sentenc...
[ "Extract", "unique", "representation", "from", "sentence", "." ]
tell-k/goolabs
python
https://github.com/tell-k/goolabs/blob/3b87d0409e55c71290158ad6d5e2d8bb9a338c46/goolabs/commands.py#L203-L226
[ "def", "entity", "(", "ctx", ",", "app_id", ",", "sentence_file", ",", "json_flag", ",", "sentence", ",", "class_filter", ",", "request_id", ")", ":", "# type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA", "app_id", "=", "clean_app_id", ...
3b87d0409e55c71290158ad6d5e2d8bb9a338c46
test
shortsum
Summarize reviews into a short summary.
goolabs/commands.py
def shortsum(ctx, app_id, review_file, json_flag, review, length, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA """Summarize reviews into a short summary.""" app_id = clean_app_id(app_id) review_list = clean_review(review, review_file...
def shortsum(ctx, app_id, review_file, json_flag, review, length, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA """Summarize reviews into a short summary.""" app_id = clean_app_id(app_id) review_list = clean_review(review, review_file...
[ "Summarize", "reviews", "into", "a", "short", "summary", "." ]
tell-k/goolabs
python
https://github.com/tell-k/goolabs/blob/3b87d0409e55c71290158ad6d5e2d8bb9a338c46/goolabs/commands.py#L237-L257
[ "def", "shortsum", "(", "ctx", ",", "app_id", ",", "review_file", ",", "json_flag", ",", "review", ",", "length", ",", "request_id", ")", ":", "# type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA", "app_id", "=", "clean_app_id", "(", ...
3b87d0409e55c71290158ad6d5e2d8bb9a338c46
test
keyword
Extract "keywords" from an input document.
goolabs/commands.py
def keyword(ctx, app_id, body_file, json_flag, title, body, max_num, forcus, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, int, unicode, unicode) -> None # NOQA """Extract "keywords" from an input document. """ app_id = clean_app_id(app_id) body = clean_body(...
def keyword(ctx, app_id, body_file, json_flag, title, body, max_num, forcus, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, int, unicode, unicode) -> None # NOQA """Extract "keywords" from an input document. """ app_id = clean_app_id(app_id) body = clean_body(...
[ "Extract", "keywords", "from", "an", "input", "document", "." ]
tell-k/goolabs
python
https://github.com/tell-k/goolabs/blob/3b87d0409e55c71290158ad6d5e2d8bb9a338c46/goolabs/commands.py#L270-L294
[ "def", "keyword", "(", "ctx", ",", "app_id", ",", "body_file", ",", "json_flag", ",", "title", ",", "body", ",", "max_num", ",", "forcus", ",", "request_id", ")", ":", "# type: (Context, unicode, Optional[IO], bool, unicode, unicode, int, unicode, unicode) -> None # NOQA"...
3b87d0409e55c71290158ad6d5e2d8bb9a338c46
test
chrono
Extract expression expressing date and time and normalize its value
goolabs/commands.py
def chrono(ctx, app_id, sentence_file, json_flag, sentence, doc_time, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA """Extract expression expressing date and time and normalize its value """ app_id = clean_app_id(app_id) sentence = cle...
def chrono(ctx, app_id, sentence_file, json_flag, sentence, doc_time, request_id): # type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA """Extract expression expressing date and time and normalize its value """ app_id = clean_app_id(app_id) sentence = cle...
[ "Extract", "expression", "expressing", "date", "and", "time", "and", "normalize", "its", "value" ]
tell-k/goolabs
python
https://github.com/tell-k/goolabs/blob/3b87d0409e55c71290158ad6d5e2d8bb9a338c46/goolabs/commands.py#L305-L325
[ "def", "chrono", "(", "ctx", ",", "app_id", ",", "sentence_file", ",", "json_flag", ",", "sentence", ",", "doc_time", ",", "request_id", ")", ":", "# type: (Context, unicode, Optional[IO], bool, unicode, unicode, unicode) -> None # NOQA", "app_id", "=", "clean_app_id", "...
3b87d0409e55c71290158ad6d5e2d8bb9a338c46
test
PipelineFactory.create
Create a pipeline stage. Instantiates `stage` with `config`. This essentially translates to ``stage(config)``, except that two keys from `scp_config` are injected into the configuration: ``tmp_dir_path`` is an execution-specific directory from combining the top-level ``tmp_dir_...
streamcorpus_pipeline/_pipeline.py
def create(self, stage, scp_config, config=None): '''Create a pipeline stage. Instantiates `stage` with `config`. This essentially translates to ``stage(config)``, except that two keys from `scp_config` are injected into the configuration: ``tmp_dir_path`` is an execution-speci...
def create(self, stage, scp_config, config=None): '''Create a pipeline stage. Instantiates `stage` with `config`. This essentially translates to ``stage(config)``, except that two keys from `scp_config` are injected into the configuration: ``tmp_dir_path`` is an execution-speci...
[ "Create", "a", "pipeline", "stage", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_pipeline.py#L233-L299
[ "def", "create", "(", "self", ",", "stage", ",", "scp_config", ",", "config", "=", "None", ")", ":", "# Figure out what we have for a stage and its name", "if", "isinstance", "(", "stage", ",", "basestring", ")", ":", "stage_name", "=", "stage", "stage_obj", "="...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
PipelineFactory._init_stages
Create a list of indirect stages. `name` should be the name of a config item that holds a list of names of stages, for instance, ``writers``. This looks up the names of those stages, then creates and returns the corresponding list of stage objects. For instance, if the config ...
streamcorpus_pipeline/_pipeline.py
def _init_stages(self, config, name): '''Create a list of indirect stages. `name` should be the name of a config item that holds a list of names of stages, for instance, ``writers``. This looks up the names of those stages, then creates and returns the corresponding list of sta...
def _init_stages(self, config, name): '''Create a list of indirect stages. `name` should be the name of a config item that holds a list of names of stages, for instance, ``writers``. This looks up the names of those stages, then creates and returns the corresponding list of sta...
[ "Create", "a", "list", "of", "indirect", "stages", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_pipeline.py#L326-L350
[ "def", "_init_stages", "(", "self", ",", "config", ",", "name", ")", ":", "if", "name", "not", "in", "config", ":", "return", "[", "]", "return", "[", "self", ".", "create", "(", "stage", ",", "config", ")", "for", "stage", "in", "config", "[", "na...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
PipelineFactory._init_all_stages
Create stages that are used for the pipeline. :param dict config: `streamcorpus_pipeline` configuration :return: tuple of (reader, incremental transforms, batch transforms, post-batch incremental transforms, writers, temporary directory)
streamcorpus_pipeline/_pipeline.py
def _init_all_stages(self, config): '''Create stages that are used for the pipeline. :param dict config: `streamcorpus_pipeline` configuration :return: tuple of (reader, incremental transforms, batch transforms, post-batch incremental transforms, writers, temporary directory...
def _init_all_stages(self, config): '''Create stages that are used for the pipeline. :param dict config: `streamcorpus_pipeline` configuration :return: tuple of (reader, incremental transforms, batch transforms, post-batch incremental transforms, writers, temporary directory...
[ "Create", "stages", "that", "are", "used", "for", "the", "pipeline", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_pipeline.py#L352-L371
[ "def", "_init_all_stages", "(", "self", ",", "config", ")", ":", "reader", "=", "self", ".", "_init_stage", "(", "config", ",", "'reader'", ")", "incremental_transforms", "=", "self", ".", "_init_stages", "(", "config", ",", "'incremental_transforms'", ")", "b...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
Pipeline._process_task
Process a :class:`coordinate.WorkUnit`. The work unit's key is taken as the input file name. The data should have ``start_count`` and ``start_chunk_time`` values, which are passed on to :meth:`run`. :param work_unit: work unit to process :paramtype work_unit: :class:`coordinat...
streamcorpus_pipeline/_pipeline.py
def _process_task(self, work_unit): '''Process a :class:`coordinate.WorkUnit`. The work unit's key is taken as the input file name. The data should have ``start_count`` and ``start_chunk_time`` values, which are passed on to :meth:`run`. :param work_unit: work unit to process ...
def _process_task(self, work_unit): '''Process a :class:`coordinate.WorkUnit`. The work unit's key is taken as the input file name. The data should have ``start_count`` and ``start_chunk_time`` values, which are passed on to :meth:`run`. :param work_unit: work unit to process ...
[ "Process", "a", ":", "class", ":", "coordinate", ".", "WorkUnit", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_pipeline.py#L496-L512
[ "def", "_process_task", "(", "self", ",", "work_unit", ")", ":", "self", ".", "work_unit", "=", "work_unit", "i_str", "=", "work_unit", ".", "key", "start_count", "=", "work_unit", ".", "data", "[", "'start_count'", "]", "start_chunk_time", "=", "work_unit", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
Pipeline.run
Run the pipeline. This runs all of the steps described in the pipeline constructor, reading from some input and writing to some output. :param str i_str: name of the input file, or other reader-specific description of where to get input :param int start_count: index of the fi...
streamcorpus_pipeline/_pipeline.py
def run(self, i_str, start_count=0, start_chunk_time=None): '''Run the pipeline. This runs all of the steps described in the pipeline constructor, reading from some input and writing to some output. :param str i_str: name of the input file, or other reader-specific descriptio...
def run(self, i_str, start_count=0, start_chunk_time=None): '''Run the pipeline. This runs all of the steps described in the pipeline constructor, reading from some input and writing to some output. :param str i_str: name of the input file, or other reader-specific descriptio...
[ "Run", "the", "pipeline", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_pipeline.py#L514-L650
[ "def", "run", "(", "self", ",", "i_str", ",", "start_count", "=", "0", ",", "start_chunk_time", "=", "None", ")", ":", "try", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "tmp_dir_path", ")", ":", "os", ".", "makedirs", "("...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
Pipeline._process_output_chunk
for the current output chunk (which should be open): 1. run batch transforms 2. run post-batch incremental transforms 3. run 'writers' to load-out the data to files or other storage return list of paths that writers wrote to
streamcorpus_pipeline/_pipeline.py
def _process_output_chunk(self, start_count, next_idx, sources, i_str, t_path): ''' for the current output chunk (which should be open): 1. run batch transforms 2. run post-batch incremental transforms 3. run 'writers' to load-out the data to f...
def _process_output_chunk(self, start_count, next_idx, sources, i_str, t_path): ''' for the current output chunk (which should be open): 1. run batch transforms 2. run post-batch incremental transforms 3. run 'writers' to load-out the data to f...
[ "for", "the", "current", "output", "chunk", "(", "which", "should", "be", "open", ")", ":", "1", ".", "run", "batch", "transforms", "2", ".", "run", "post", "-", "batch", "incremental", "transforms", "3", ".", "run", "writers", "to", "load", "-", "out"...
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_pipeline.py#L652-L694
[ "def", "_process_output_chunk", "(", "self", ",", "start_count", ",", "next_idx", ",", "sources", ",", "i_str", ",", "t_path", ")", ":", "if", "not", "self", ".", "t_chunk", ":", "# nothing to do", "return", "[", "]", "self", ".", "t_chunk", ".", "close", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
Pipeline._run_writers
Run all of the writers over some intermediate chunk. :param int start_count: index of the first item :param int next_idx: index of the next item (after the last item in this chunk) :param list sources: source strings included in this chunk (usually only one source) :...
streamcorpus_pipeline/_pipeline.py
def _run_writers(self, start_count, next_idx, sources, i_str, t_path): '''Run all of the writers over some intermediate chunk. :param int start_count: index of the first item :param int next_idx: index of the next item (after the last item in this chunk) :param list sources: s...
def _run_writers(self, start_count, next_idx, sources, i_str, t_path): '''Run all of the writers over some intermediate chunk. :param int start_count: index of the first item :param int next_idx: index of the next item (after the last item in this chunk) :param list sources: s...
[ "Run", "all", "of", "the", "writers", "over", "some", "intermediate", "chunk", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_pipeline.py#L718-L745
[ "def", "_run_writers", "(", "self", ",", "start_count", ",", "next_idx", ",", "sources", ",", "i_str", ",", "t_path", ")", ":", "# writers put the chunk somewhere, and could delete it", "name_info", "=", "dict", "(", "first", "=", "start_count", ",", "# num and md5 ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
Pipeline._run_incremental_transforms
Run transforms on stream item. Item may be discarded by some transform. Writes successful items out to current self.t_chunk Returns transformed item or None.
streamcorpus_pipeline/_pipeline.py
def _run_incremental_transforms(self, si, transforms): ''' Run transforms on stream item. Item may be discarded by some transform. Writes successful items out to current self.t_chunk Returns transformed item or None. ''' ## operate each transform on this one Strea...
def _run_incremental_transforms(self, si, transforms): ''' Run transforms on stream item. Item may be discarded by some transform. Writes successful items out to current self.t_chunk Returns transformed item or None. ''' ## operate each transform on this one Strea...
[ "Run", "transforms", "on", "stream", "item", ".", "Item", "may", "be", "discarded", "by", "some", "transform", ".", "Writes", "successful", "items", "out", "to", "current", "self", ".", "t_chunk", "Returns", "transformed", "item", "or", "None", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_pipeline.py#L747-L791
[ "def", "_run_incremental_transforms", "(", "self", ",", "si", ",", "transforms", ")", ":", "## operate each transform on this one StreamItem", "for", "transform", "in", "transforms", ":", "try", ":", "stream_id", "=", "si", ".", "stream_id", "si_new", "=", "transfor...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
get_name_info
takes a chunk blob and obtains the date_hour, md5, num makes fields: i_str input_fname input_md5 - parsed from input filename if it contains '-%(md5)s-' md5 num epoch_ticks target_names doc_ids_8 date_hour rand8 date_now time_now date_time_now
streamcorpus_pipeline/_get_name_info.py
def get_name_info(chunk_path, assert_one_date_hour=False, i_str=None, chunk_type=Chunk): ''' takes a chunk blob and obtains the date_hour, md5, num makes fields: i_str input_fname input_md5 - parsed from input filename if it contains '-%(md5)s-' md5 num epoch_ticks...
def get_name_info(chunk_path, assert_one_date_hour=False, i_str=None, chunk_type=Chunk): ''' takes a chunk blob and obtains the date_hour, md5, num makes fields: i_str input_fname input_md5 - parsed from input filename if it contains '-%(md5)s-' md5 num epoch_ticks...
[ "takes", "a", "chunk", "blob", "and", "obtains", "the", "date_hour", "md5", "num" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_get_name_info.py#L19-L123
[ "def", "get_name_info", "(", "chunk_path", ",", "assert_one_date_hour", "=", "False", ",", "i_str", "=", "None", ",", "chunk_type", "=", "Chunk", ")", ":", "assert", "i_str", "is", "not", "None", ",", "'must provide i_str as keyword arg'", "name_info", "=", "dic...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
replace_config
Replace the top-level pipeline configurable object. This investigates a number of sources, including `external_stages_path` and `external_stages_modules` configuration and `streamcorpus_pipeline.stages` entry points, and uses these to find the actual :data:`sub_modules` for :mod:`streamcorpus_pipel...
streamcorpus_pipeline/config.py
def replace_config(config, name): '''Replace the top-level pipeline configurable object. This investigates a number of sources, including `external_stages_path` and `external_stages_modules` configuration and `streamcorpus_pipeline.stages` entry points, and uses these to find the actual :data:`sub_...
def replace_config(config, name): '''Replace the top-level pipeline configurable object. This investigates a number of sources, including `external_stages_path` and `external_stages_modules` configuration and `streamcorpus_pipeline.stages` entry points, and uses these to find the actual :data:`sub_...
[ "Replace", "the", "top", "-", "level", "pipeline", "configurable", "object", "." ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/config.py#L62-L96
[ "def", "replace_config", "(", "config", ",", "name", ")", ":", "global", "static_stages", "if", "static_stages", "is", "None", ":", "static_stages", "=", "PipelineStages", "(", ")", "stages", "=", "static_stages", "if", "'external_stages_path'", "in", "config", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
make_app
Make a WSGI app that has all the HTTPie pieces baked in.
httpony/application.py
def make_app(): """Make a WSGI app that has all the HTTPie pieces baked in.""" env = Environment() # STDIN is ignored because HTTPony runs a server that doesn't care. # Additionally, it is needed or else pytest blows up. args = parser.parse_args(args=['/', '--ignore-stdin'], env=env) args.output...
def make_app(): """Make a WSGI app that has all the HTTPie pieces baked in.""" env = Environment() # STDIN is ignored because HTTPony runs a server that doesn't care. # Additionally, it is needed or else pytest blows up. args = parser.parse_args(args=['/', '--ignore-stdin'], env=env) args.output...
[ "Make", "a", "WSGI", "app", "that", "has", "all", "the", "HTTPie", "pieces", "baked", "in", "." ]
mblayman/httpony
python
https://github.com/mblayman/httpony/blob/5af404d647a8dac8a043b64ea09882589b3b5247/httpony/application.py#L15-L55
[ "def", "make_app", "(", ")", ":", "env", "=", "Environment", "(", ")", "# STDIN is ignored because HTTPony runs a server that doesn't care.", "# Additionally, it is needed or else pytest blows up.", "args", "=", "parser", ".", "parse_args", "(", "args", "=", "[", "'/'", "...
5af404d647a8dac8a043b64ea09882589b3b5247
test
make_chains_with_names
assemble in-doc coref chains by mapping equiv_id to tokens and their cleansed name strings :param sentences: iterator over token generators :returns dict: keys are equiv_ids, values are tuple(concatentated name string, list of tokens)
streamcorpus_pipeline/_taggers.py
def make_chains_with_names(sentences): ''' assemble in-doc coref chains by mapping equiv_id to tokens and their cleansed name strings :param sentences: iterator over token generators :returns dict: keys are equiv_ids, values are tuple(concatentated name string, list of tokens) '...
def make_chains_with_names(sentences): ''' assemble in-doc coref chains by mapping equiv_id to tokens and their cleansed name strings :param sentences: iterator over token generators :returns dict: keys are equiv_ids, values are tuple(concatentated name string, list of tokens) '...
[ "assemble", "in", "-", "doc", "coref", "chains", "by", "mapping", "equiv_id", "to", "tokens", "and", "their", "cleansed", "name", "strings" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L39-L76
[ "def", "make_chains_with_names", "(", "sentences", ")", ":", "## if an equiv_id is -1, then the token is classified into some", "## entity_type but has not other tokens in its chain. We don't", "## want these all lumped together, so we give them distinct \"fake\"", "## equiv_id other than -1 -- c...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
ALL_mentions
For each name string in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains the name. Returns True only if all of the target_mention strings appeared as substrings of at least one cleansed Token.token. Otherwise, returns False. :type ta...
streamcorpus_pipeline/_taggers.py
def ALL_mentions(target_mentions, chain_mentions): ''' For each name string in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains the name. Returns True only if all of the target_mention strings appeared as substrings of at least one cle...
def ALL_mentions(target_mentions, chain_mentions): ''' For each name string in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains the name. Returns True only if all of the target_mention strings appeared as substrings of at least one cle...
[ "For", "each", "name", "string", "in", "the", "target_mentions", "list", "searches", "through", "all", "chain_mentions", "looking", "for", "any", "cleansed", "Token", ".", "token", "that", "contains", "the", "name", ".", "Returns", "True", "only", "if", "all",...
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L78-L101
[ "def", "ALL_mentions", "(", "target_mentions", ",", "chain_mentions", ")", ":", "found_all", "=", "True", "for", "name", "in", "target_mentions", ":", "found_one", "=", "False", "for", "chain_ment", "in", "chain_mentions", ":", "if", "name", "in", "chain_ment", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
ANY_MULTI_TOKEN_mentions
For each name string (potentially consisting of multiple tokens) in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains all the tokens in the name. Returns True only if all of the target_mention strings appeared as substrings of at least one ...
streamcorpus_pipeline/_taggers.py
def ANY_MULTI_TOKEN_mentions(multi_token_target_mentions, chain_mentions): ''' For each name string (potentially consisting of multiple tokens) in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains all the tokens in the name. Returns Tru...
def ANY_MULTI_TOKEN_mentions(multi_token_target_mentions, chain_mentions): ''' For each name string (potentially consisting of multiple tokens) in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains all the tokens in the name. Returns Tru...
[ "For", "each", "name", "string", "(", "potentially", "consisting", "of", "multiple", "tokens", ")", "in", "the", "target_mentions", "list", "searches", "through", "all", "chain_mentions", "looking", "for", "any", "cleansed", "Token", ".", "token", "that", "conta...
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L104-L120
[ "def", "ANY_MULTI_TOKEN_mentions", "(", "multi_token_target_mentions", ",", "chain_mentions", ")", ":", "for", "multi_token_name", "in", "multi_token_target_mentions", ":", "if", "ALL_mentions", "(", "multi_token_name", ".", "split", "(", ")", ",", "chain_mentions", ")"...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
ANY_mentions
For each name string in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains the name. Returns True if any of the target_mention strings appeared as substrings of any cleansed Token.token. Otherwise, returns False. :type target_mentions: ...
streamcorpus_pipeline/_taggers.py
def ANY_mentions(target_mentions, chain_mentions): ''' For each name string in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains the name. Returns True if any of the target_mention strings appeared as substrings of any cleansed Token.to...
def ANY_mentions(target_mentions, chain_mentions): ''' For each name string in the target_mentions list, searches through all chain_mentions looking for any cleansed Token.token that contains the name. Returns True if any of the target_mention strings appeared as substrings of any cleansed Token.to...
[ "For", "each", "name", "string", "in", "the", "target_mentions", "list", "searches", "through", "all", "chain_mentions", "looking", "for", "any", "cleansed", "Token", ".", "token", "that", "contains", "the", "name", ".", "Returns", "True", "if", "any", "of", ...
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L123-L140
[ "def", "ANY_mentions", "(", "target_mentions", ",", "chain_mentions", ")", ":", "for", "name", "in", "target_mentions", ":", "for", "chain_ment", "in", "chain_mentions", ":", "if", "name", "in", "chain_ment", ":", "return", "True", "return", "False" ]
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
names_in_chains
Convert doc-level Rating object into a Label, and add that Label to all Token in all coref chains identified by aligner_data["chain_selector"] :param stream_item: document that has a doc-level Rating to translate into token-level Labels. :param aligner_data: dict containing: chain_selector: ALL o...
streamcorpus_pipeline/_taggers.py
def names_in_chains(stream_item, aligner_data): ''' Convert doc-level Rating object into a Label, and add that Label to all Token in all coref chains identified by aligner_data["chain_selector"] :param stream_item: document that has a doc-level Rating to translate into token-level Labels. :para...
def names_in_chains(stream_item, aligner_data): ''' Convert doc-level Rating object into a Label, and add that Label to all Token in all coref chains identified by aligner_data["chain_selector"] :param stream_item: document that has a doc-level Rating to translate into token-level Labels. :para...
[ "Convert", "doc", "-", "level", "Rating", "object", "into", "a", "Label", "and", "add", "that", "Label", "to", "all", "Token", "in", "all", "coref", "chains", "identified", "by", "aligner_data", "[", "chain_selector", "]" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L148-L195
[ "def", "names_in_chains", "(", "stream_item", ",", "aligner_data", ")", ":", "chain_selector", "=", "aligner_data", ".", "get", "(", "'chain_selector'", ",", "''", ")", "assert", "chain_selector", "in", "_CHAIN_SELECTORS", ",", "'chain_selector: %r not in %r'", "%", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
look_ahead_match
iterate through all tokens looking for matches of cleansed tokens or token regexes, skipping tokens left empty by cleansing and coping with Token objects that produce multiple space-separated strings when cleansed. Yields tokens that match.
streamcorpus_pipeline/_taggers.py
def look_ahead_match(rating, tokens): '''iterate through all tokens looking for matches of cleansed tokens or token regexes, skipping tokens left empty by cleansing and coping with Token objects that produce multiple space-separated strings when cleansed. Yields tokens that match. ''' ## this ...
def look_ahead_match(rating, tokens): '''iterate through all tokens looking for matches of cleansed tokens or token regexes, skipping tokens left empty by cleansing and coping with Token objects that produce multiple space-separated strings when cleansed. Yields tokens that match. ''' ## this ...
[ "iterate", "through", "all", "tokens", "looking", "for", "matches", "of", "cleansed", "tokens", "or", "token", "regexes", "skipping", "tokens", "left", "empty", "by", "cleansing", "and", "coping", "with", "Token", "objects", "that", "produce", "multiple", "space...
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L348-L413
[ "def", "look_ahead_match", "(", "rating", ",", "tokens", ")", ":", "## this ensures that all cleansed tokens are non-zero length", "all_mregexes", "=", "[", "]", "for", "m", "in", "rating", ".", "mentions", ":", "mregexes", "=", "[", "]", "mpatterns", "=", "m", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
multi_token_match
iterate through tokens looking for near-exact matches to strings in si.ratings...mentions
streamcorpus_pipeline/_taggers.py
def multi_token_match(stream_item, aligner_data): ''' iterate through tokens looking for near-exact matches to strings in si.ratings...mentions ''' tagger_id = _get_tagger_id(stream_item, aligner_data) sentences = stream_item.body.sentences.get(tagger_id) if not sentences: return...
def multi_token_match(stream_item, aligner_data): ''' iterate through tokens looking for near-exact matches to strings in si.ratings...mentions ''' tagger_id = _get_tagger_id(stream_item, aligner_data) sentences = stream_item.body.sentences.get(tagger_id) if not sentences: return...
[ "iterate", "through", "tokens", "looking", "for", "near", "-", "exact", "matches", "to", "strings", "in", "si", ".", "ratings", "...", "mentions" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L415-L451
[ "def", "multi_token_match", "(", "stream_item", ",", "aligner_data", ")", ":", "tagger_id", "=", "_get_tagger_id", "(", "stream_item", ",", "aligner_data", ")", "sentences", "=", "stream_item", ".", "body", ".", "sentences", ".", "get", "(", "tagger_id", ")", ...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
TaggerBatchTransform.make_ner_file
run tagger a child process to get XML output
streamcorpus_pipeline/_taggers.py
def make_ner_file(self, clean_visible_path, ner_xml_path): '''run tagger a child process to get XML output''' if self.template is None: raise exceptions.NotImplementedError(''' Subclasses must specify a class property "template" that provides command string format for running a tagger. It s...
def make_ner_file(self, clean_visible_path, ner_xml_path): '''run tagger a child process to get XML output''' if self.template is None: raise exceptions.NotImplementedError(''' Subclasses must specify a class property "template" that provides command string format for running a tagger. It s...
[ "run", "tagger", "a", "child", "process", "to", "get", "XML", "output" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L619-L664
[ "def", "make_ner_file", "(", "self", ",", "clean_visible_path", ",", "ner_xml_path", ")", ":", "if", "self", ".", "template", "is", "None", ":", "raise", "exceptions", ".", "NotImplementedError", "(", "'''\nSubclasses must specify a class property \"template\" that provid...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a
test
TaggerBatchTransform.align_chunk_with_ner
iterate through ner_xml_path to fuse with i_chunk into o_chunk
streamcorpus_pipeline/_taggers.py
def align_chunk_with_ner(self, ner_xml_path, i_chunk, o_chunk): ''' iterate through ner_xml_path to fuse with i_chunk into o_chunk ''' ## prepare to iterate over the input chunk input_iter = i_chunk.__iter__() all_ner = xml.dom.minidom.parse(open(ner_xml_path)) ## this converts...
def align_chunk_with_ner(self, ner_xml_path, i_chunk, o_chunk): ''' iterate through ner_xml_path to fuse with i_chunk into o_chunk ''' ## prepare to iterate over the input chunk input_iter = i_chunk.__iter__() all_ner = xml.dom.minidom.parse(open(ner_xml_path)) ## this converts...
[ "iterate", "through", "ner_xml_path", "to", "fuse", "with", "i_chunk", "into", "o_chunk" ]
trec-kba/streamcorpus-pipeline
python
https://github.com/trec-kba/streamcorpus-pipeline/blob/8bb82ea1beb83c6b40ed03fa1659df2897c2292a/streamcorpus_pipeline/_taggers.py#L669-L757
[ "def", "align_chunk_with_ner", "(", "self", ",", "ner_xml_path", ",", "i_chunk", ",", "o_chunk", ")", ":", "## prepare to iterate over the input chunk", "input_iter", "=", "i_chunk", ".", "__iter__", "(", ")", "all_ner", "=", "xml", ".", "dom", ".", "minidom", "...
8bb82ea1beb83c6b40ed03fa1659df2897c2292a