repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
molmod/molmod | molmod/graphs.py | GraphSearch._iter_matches | def _iter_matches(self, input_match, subject_graph, one_match, level=0):
"""Given an onset for a match, iterate over all completions of that match
This iterator works recursively. At each level the match is extended
with a new set of relations based on vertices in the pattern graph
... | python | def _iter_matches(self, input_match, subject_graph, one_match, level=0):
"""Given an onset for a match, iterate over all completions of that match
This iterator works recursively. At each level the match is extended
with a new set of relations based on vertices in the pattern graph
... | [
"def",
"_iter_matches",
"(",
"self",
",",
"input_match",
",",
"subject_graph",
",",
"one_match",
",",
"level",
"=",
"0",
")",
":",
"self",
".",
"print_debug",
"(",
"\"ENTERING _ITER_MATCHES\"",
",",
"1",
")",
"self",
".",
"print_debug",
"(",
"\"input_match: %s... | Given an onset for a match, iterate over all completions of that match
This iterator works recursively. At each level the match is extended
with a new set of relations based on vertices in the pattern graph
that are at a distances 'level' from the starting vertex | [
"Given",
"an",
"onset",
"for",
"a",
"match",
"iterate",
"over",
"all",
"completions",
"of",
"that",
"match"
] | a7b5b4364ed514ad4c465856c05b5eda1cb561e0 | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/graphs.py#L1696-L1741 | train |
molmod/molmod | molmod/io/pdb.py | dump_pdb | def dump_pdb(filename, molecule, atomnames=None, resnames=None, chain_ids=None, occupancies=None, betas=None):
"""Writes a single molecule to a pdb file.
This function is based on the pdb file specification:
http://www.wwpdb.org/documentation/format32/sect9.html
For convenience, the relevant t... | python | def dump_pdb(filename, molecule, atomnames=None, resnames=None, chain_ids=None, occupancies=None, betas=None):
"""Writes a single molecule to a pdb file.
This function is based on the pdb file specification:
http://www.wwpdb.org/documentation/format32/sect9.html
For convenience, the relevant t... | [
"def",
"dump_pdb",
"(",
"filename",
",",
"molecule",
",",
"atomnames",
"=",
"None",
",",
"resnames",
"=",
"None",
",",
"chain_ids",
"=",
"None",
",",
"occupancies",
"=",
"None",
",",
"betas",
"=",
"None",
")",
":",
"with",
"open",
"(",
"filename",
",",... | Writes a single molecule to a pdb file.
This function is based on the pdb file specification:
http://www.wwpdb.org/documentation/format32/sect9.html
For convenience, the relevant table is copied and the character indexes are
transformed to C-style (starting from zero)
======= ... | [
"Writes",
"a",
"single",
"molecule",
"to",
"a",
"pdb",
"file",
"."
] | a7b5b4364ed514ad4c465856c05b5eda1cb561e0 | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/pdb.py#L40-L105 | train |
molmod/molmod | molmod/io/pdb.py | load_pdb | def load_pdb(filename):
"""Loads a single molecule from a pdb file.
This function does support only a small fragment from the pdb specification.
It assumes that there is only one molecular geometry in the pdb file.
"""
with open(filename) as f:
numbers = []
coordinates = []
... | python | def load_pdb(filename):
"""Loads a single molecule from a pdb file.
This function does support only a small fragment from the pdb specification.
It assumes that there is only one molecular geometry in the pdb file.
"""
with open(filename) as f:
numbers = []
coordinates = []
... | [
"def",
"load_pdb",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"numbers",
"=",
"[",
"]",
"coordinates",
"=",
"[",
"]",
"occupancies",
"=",
"[",
"]",
"betas",
"=",
"[",
"]",
"for",
"line",
"in",
"f",
":",
"if",... | Loads a single molecule from a pdb file.
This function does support only a small fragment from the pdb specification.
It assumes that there is only one molecular geometry in the pdb file. | [
"Loads",
"a",
"single",
"molecule",
"from",
"a",
"pdb",
"file",
"."
] | a7b5b4364ed514ad4c465856c05b5eda1cb561e0 | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/pdb.py#L108-L132 | train |
molmod/molmod | molmod/zmatrix.py | zmat_to_cart | def zmat_to_cart(zmat):
"""Converts a ZMatrix back to cartesian coordinates."""
numbers = zmat["number"]
N = len(numbers)
coordinates = np.zeros((N, 3), float)
# special cases for the first coordinates
coordinates[1, 2] = zmat["distance"][1]
if zmat["rel1"][2] == 1:
sign = -1
e... | python | def zmat_to_cart(zmat):
"""Converts a ZMatrix back to cartesian coordinates."""
numbers = zmat["number"]
N = len(numbers)
coordinates = np.zeros((N, 3), float)
# special cases for the first coordinates
coordinates[1, 2] = zmat["distance"][1]
if zmat["rel1"][2] == 1:
sign = -1
e... | [
"def",
"zmat_to_cart",
"(",
"zmat",
")",
":",
"numbers",
"=",
"zmat",
"[",
"\"number\"",
"]",
"N",
"=",
"len",
"(",
"numbers",
")",
"coordinates",
"=",
"np",
".",
"zeros",
"(",
"(",
"N",
",",
"3",
")",
",",
"float",
")",
"# special cases for the first ... | Converts a ZMatrix back to cartesian coordinates. | [
"Converts",
"a",
"ZMatrix",
"back",
"to",
"cartesian",
"coordinates",
"."
] | a7b5b4364ed514ad4c465856c05b5eda1cb561e0 | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/zmatrix.py#L157-L209 | train |
molmod/molmod | molmod/zmatrix.py | ZMatrixGenerator._get_new_ref | def _get_new_ref(self, existing_refs):
"""Get a new reference atom for a row in the ZMatrix
The reference atoms should obey the following conditions:
- They must be different
- They must be neighbours in the bond graph
- They must have an index lower than the c... | python | def _get_new_ref(self, existing_refs):
"""Get a new reference atom for a row in the ZMatrix
The reference atoms should obey the following conditions:
- They must be different
- They must be neighbours in the bond graph
- They must have an index lower than the c... | [
"def",
"_get_new_ref",
"(",
"self",
",",
"existing_refs",
")",
":",
"# ref0 is the atom whose position is defined by the current row in the",
"# zmatrix.",
"ref0",
"=",
"existing_refs",
"[",
"0",
"]",
"for",
"ref",
"in",
"existing_refs",
":",
"# try to find a neighbor of th... | Get a new reference atom for a row in the ZMatrix
The reference atoms should obey the following conditions:
- They must be different
- They must be neighbours in the bond graph
- They must have an index lower than the current atom
If multiple candidate refs... | [
"Get",
"a",
"new",
"reference",
"atom",
"for",
"a",
"row",
"in",
"the",
"ZMatrix"
] | a7b5b4364ed514ad4c465856c05b5eda1cb561e0 | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/zmatrix.py#L89-L118 | train |
molmod/molmod | molmod/zmatrix.py | ZMatrixGenerator.cart_to_zmat | def cart_to_zmat(self, coordinates):
"""Convert cartesian coordinates to ZMatrix format
Argument:
coordinates -- Cartesian coordinates (numpy array Nx3)
The coordinates must match with the graph that was used to initialize
the ZMatrixGenerator object.
""... | python | def cart_to_zmat(self, coordinates):
"""Convert cartesian coordinates to ZMatrix format
Argument:
coordinates -- Cartesian coordinates (numpy array Nx3)
The coordinates must match with the graph that was used to initialize
the ZMatrixGenerator object.
""... | [
"def",
"cart_to_zmat",
"(",
"self",
",",
"coordinates",
")",
":",
"N",
"=",
"len",
"(",
"self",
".",
"graph",
".",
"numbers",
")",
"if",
"coordinates",
".",
"shape",
"!=",
"(",
"N",
",",
"3",
")",
":",
"raise",
"ValueError",
"(",
"\"The shape of the co... | Convert cartesian coordinates to ZMatrix format
Argument:
coordinates -- Cartesian coordinates (numpy array Nx3)
The coordinates must match with the graph that was used to initialize
the ZMatrixGenerator object. | [
"Convert",
"cartesian",
"coordinates",
"to",
"ZMatrix",
"format"
] | a7b5b4364ed514ad4c465856c05b5eda1cb561e0 | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/zmatrix.py#L120-L154 | train |
pettarin/ipapy | ipapy/mapper.py | Mapper.can_map_ipa_string | def can_map_ipa_string(self, ipa_string):
"""
Return ``True`` if the mapper can map all the IPA characters
in the given IPA string.
:param IPAString ipa_string: the IPAString to be parsed
:rtype: bool
"""
canonical = [(c.canonical_representation, ) for c in ipa_s... | python | def can_map_ipa_string(self, ipa_string):
"""
Return ``True`` if the mapper can map all the IPA characters
in the given IPA string.
:param IPAString ipa_string: the IPAString to be parsed
:rtype: bool
"""
canonical = [(c.canonical_representation, ) for c in ipa_s... | [
"def",
"can_map_ipa_string",
"(",
"self",
",",
"ipa_string",
")",
":",
"canonical",
"=",
"[",
"(",
"c",
".",
"canonical_representation",
",",
")",
"for",
"c",
"in",
"ipa_string",
"]",
"split",
"=",
"split_using_dictionary",
"(",
"canonical",
",",
"self",
","... | Return ``True`` if the mapper can map all the IPA characters
in the given IPA string.
:param IPAString ipa_string: the IPAString to be parsed
:rtype: bool | [
"Return",
"True",
"if",
"the",
"mapper",
"can",
"map",
"all",
"the",
"IPA",
"characters",
"in",
"the",
"given",
"IPA",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/mapper.py#L93-L106 | train |
pettarin/ipapy | ipapy/mapper.py | Mapper.map_ipa_string | def map_ipa_string(self, ipa_string, ignore=False, return_as_list=False, return_can_map=False):
"""
Convert the given IPAString to a string
containing the corresponding ASCII IPA representation.
:param IPAString ipa_string: the IPAString to be parsed
:param bool ignore: if ``Tru... | python | def map_ipa_string(self, ipa_string, ignore=False, return_as_list=False, return_can_map=False):
"""
Convert the given IPAString to a string
containing the corresponding ASCII IPA representation.
:param IPAString ipa_string: the IPAString to be parsed
:param bool ignore: if ``Tru... | [
"def",
"map_ipa_string",
"(",
"self",
",",
"ipa_string",
",",
"ignore",
"=",
"False",
",",
"return_as_list",
"=",
"False",
",",
"return_can_map",
"=",
"False",
")",
":",
"acc",
"=",
"[",
"]",
"can_map",
"=",
"True",
"canonical",
"=",
"[",
"(",
"c",
"."... | Convert the given IPAString to a string
containing the corresponding ASCII IPA representation.
:param IPAString ipa_string: the IPAString to be parsed
:param bool ignore: if ``True``, ignore Unicode characters that are not IPA valid
:param bool return_as_list: if ``True``, return as a l... | [
"Convert",
"the",
"given",
"IPAString",
"to",
"a",
"string",
"containing",
"the",
"corresponding",
"ASCII",
"IPA",
"representation",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/mapper.py#L108-L137 | train |
pettarin/ipapy | ipapy/mapper.py | Mapper.map_unicode_string | def map_unicode_string(self, unicode_string, ignore=False, single_char_parsing=False, return_as_list=False, return_can_map=False):
"""
Convert the given Unicode string, representing an IPA string,
to a string containing the corresponding mapped representation.
Return ``None`` if ``unico... | python | def map_unicode_string(self, unicode_string, ignore=False, single_char_parsing=False, return_as_list=False, return_can_map=False):
"""
Convert the given Unicode string, representing an IPA string,
to a string containing the corresponding mapped representation.
Return ``None`` if ``unico... | [
"def",
"map_unicode_string",
"(",
"self",
",",
"unicode_string",
",",
"ignore",
"=",
"False",
",",
"single_char_parsing",
"=",
"False",
",",
"return_as_list",
"=",
"False",
",",
"return_can_map",
"=",
"False",
")",
":",
"if",
"unicode_string",
"is",
"None",
":... | Convert the given Unicode string, representing an IPA string,
to a string containing the corresponding mapped representation.
Return ``None`` if ``unicode_string`` is ``None``.
:param str unicode_string: the Unicode string to be parsed
:param bool ignore: if ``True``, ignore Unicode ch... | [
"Convert",
"the",
"given",
"Unicode",
"string",
"representing",
"an",
"IPA",
"string",
"to",
"a",
"string",
"containing",
"the",
"corresponding",
"mapped",
"representation",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/mapper.py#L139-L164 | train |
pettarin/ipapy | ipapy/__main__.py | print_invalid_chars | def print_invalid_chars(invalid_chars, vargs):
"""
Print Unicode characterss that are not IPA valid,
if requested by the user.
:param list invalid_chars: a list (possibly empty) of invalid Unicode characters
:param dict vargs: the command line parameters
"""
if len(invalid_chars) > 0:
... | python | def print_invalid_chars(invalid_chars, vargs):
"""
Print Unicode characterss that are not IPA valid,
if requested by the user.
:param list invalid_chars: a list (possibly empty) of invalid Unicode characters
:param dict vargs: the command line parameters
"""
if len(invalid_chars) > 0:
... | [
"def",
"print_invalid_chars",
"(",
"invalid_chars",
",",
"vargs",
")",
":",
"if",
"len",
"(",
"invalid_chars",
")",
">",
"0",
":",
"if",
"vargs",
"[",
"\"print_invalid\"",
"]",
":",
"print",
"(",
"u\"\"",
".",
"join",
"(",
"invalid_chars",
")",
")",
"if"... | Print Unicode characterss that are not IPA valid,
if requested by the user.
:param list invalid_chars: a list (possibly empty) of invalid Unicode characters
:param dict vargs: the command line parameters | [
"Print",
"Unicode",
"characterss",
"that",
"are",
"not",
"IPA",
"valid",
"if",
"requested",
"by",
"the",
"user",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__main__.py#L91-L104 | train |
pettarin/ipapy | ipapy/__main__.py | command_canonize | def command_canonize(string, vargs):
"""
Print the canonical representation of the given string.
It will replace non-canonical compound characters
with their canonical synonym.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
try:
ipa... | python | def command_canonize(string, vargs):
"""
Print the canonical representation of the given string.
It will replace non-canonical compound characters
with their canonical synonym.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
try:
ipa... | [
"def",
"command_canonize",
"(",
"string",
",",
"vargs",
")",
":",
"try",
":",
"ipa_string",
"=",
"IPAString",
"(",
"unicode_string",
"=",
"string",
",",
"ignore",
"=",
"vargs",
"[",
"\"ignore\"",
"]",
",",
"single_char_parsing",
"=",
"vargs",
"[",
"\"single_... | Print the canonical representation of the given string.
It will replace non-canonical compound characters
with their canonical synonym.
:param str string: the string to act upon
:param dict vargs: the command line arguments | [
"Print",
"the",
"canonical",
"representation",
"of",
"the",
"given",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__main__.py#L106-L124 | train |
pettarin/ipapy | ipapy/__main__.py | command_chars | def command_chars(string, vargs):
"""
Print a list of all IPA characters in the given string.
It will print the Unicode representation, the full IPA name,
and the Unicode "U+"-prefixed hexadecimal codepoint representation
of each IPA character.
:param str string: the string to act upon
:pa... | python | def command_chars(string, vargs):
"""
Print a list of all IPA characters in the given string.
It will print the Unicode representation, the full IPA name,
and the Unicode "U+"-prefixed hexadecimal codepoint representation
of each IPA character.
:param str string: the string to act upon
:pa... | [
"def",
"command_chars",
"(",
"string",
",",
"vargs",
")",
":",
"try",
":",
"ipa_string",
"=",
"IPAString",
"(",
"unicode_string",
"=",
"string",
",",
"ignore",
"=",
"vargs",
"[",
"\"ignore\"",
"]",
",",
"single_char_parsing",
"=",
"vargs",
"[",
"\"single_cha... | Print a list of all IPA characters in the given string.
It will print the Unicode representation, the full IPA name,
and the Unicode "U+"-prefixed hexadecimal codepoint representation
of each IPA character.
:param str string: the string to act upon
:param dict vargs: the command line arguments | [
"Print",
"a",
"list",
"of",
"all",
"IPA",
"characters",
"in",
"the",
"given",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__main__.py#L126-L146 | train |
pettarin/ipapy | ipapy/__main__.py | command_check | def command_check(string, vargs):
"""
Check if the given string is IPA valid.
If the given string is not IPA valid,
print the invalid characters.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
is_valid = is_valid_ipa(string)
print(is_val... | python | def command_check(string, vargs):
"""
Check if the given string is IPA valid.
If the given string is not IPA valid,
print the invalid characters.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
is_valid = is_valid_ipa(string)
print(is_val... | [
"def",
"command_check",
"(",
"string",
",",
"vargs",
")",
":",
"is_valid",
"=",
"is_valid_ipa",
"(",
"string",
")",
"print",
"(",
"is_valid",
")",
"if",
"not",
"is_valid",
":",
"valid_chars",
",",
"invalid_chars",
"=",
"remove_invalid_ipa_characters",
"(",
"un... | Check if the given string is IPA valid.
If the given string is not IPA valid,
print the invalid characters.
:param str string: the string to act upon
:param dict vargs: the command line arguments | [
"Check",
"if",
"the",
"given",
"string",
"is",
"IPA",
"valid",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__main__.py#L148-L165 | train |
pettarin/ipapy | ipapy/__main__.py | command_clean | def command_clean(string, vargs):
"""
Remove characters that are not IPA valid from the given string,
and print the remaining string.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
valid_chars, invalid_chars = remove_invalid_ipa_characters(
... | python | def command_clean(string, vargs):
"""
Remove characters that are not IPA valid from the given string,
and print the remaining string.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
valid_chars, invalid_chars = remove_invalid_ipa_characters(
... | [
"def",
"command_clean",
"(",
"string",
",",
"vargs",
")",
":",
"valid_chars",
",",
"invalid_chars",
"=",
"remove_invalid_ipa_characters",
"(",
"unicode_string",
"=",
"string",
",",
"return_invalid",
"=",
"True",
",",
"single_char_parsing",
"=",
"vargs",
"[",
"\"si... | Remove characters that are not IPA valid from the given string,
and print the remaining string.
:param str string: the string to act upon
:param dict vargs: the command line arguments | [
"Remove",
"characters",
"that",
"are",
"not",
"IPA",
"valid",
"from",
"the",
"given",
"string",
"and",
"print",
"the",
"remaining",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__main__.py#L167-L181 | train |
pettarin/ipapy | ipapy/__main__.py | command_u2a | def command_u2a(string, vargs):
"""
Print the ARPABEY ASCII string corresponding to the given Unicode IPA string.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
try:
l = ARPABETMapper().map_unicode_string(
unicode_string=string,
... | python | def command_u2a(string, vargs):
"""
Print the ARPABEY ASCII string corresponding to the given Unicode IPA string.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
try:
l = ARPABETMapper().map_unicode_string(
unicode_string=string,
... | [
"def",
"command_u2a",
"(",
"string",
",",
"vargs",
")",
":",
"try",
":",
"l",
"=",
"ARPABETMapper",
"(",
")",
".",
"map_unicode_string",
"(",
"unicode_string",
"=",
"string",
",",
"ignore",
"=",
"vargs",
"[",
"\"ignore\"",
"]",
",",
"single_char_parsing",
... | Print the ARPABEY ASCII string corresponding to the given Unicode IPA string.
:param str string: the string to act upon
:param dict vargs: the command line arguments | [
"Print",
"the",
"ARPABEY",
"ASCII",
"string",
"corresponding",
"to",
"the",
"given",
"Unicode",
"IPA",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__main__.py#L183-L199 | train |
pettarin/ipapy | ipapy/__main__.py | command_u2k | def command_u2k(string, vargs):
"""
Print the Kirshenbaum ASCII string corresponding to the given Unicode IPA string.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
try:
l = KirshenbaumMapper().map_unicode_string(
unicode_string=... | python | def command_u2k(string, vargs):
"""
Print the Kirshenbaum ASCII string corresponding to the given Unicode IPA string.
:param str string: the string to act upon
:param dict vargs: the command line arguments
"""
try:
l = KirshenbaumMapper().map_unicode_string(
unicode_string=... | [
"def",
"command_u2k",
"(",
"string",
",",
"vargs",
")",
":",
"try",
":",
"l",
"=",
"KirshenbaumMapper",
"(",
")",
".",
"map_unicode_string",
"(",
"unicode_string",
"=",
"string",
",",
"ignore",
"=",
"vargs",
"[",
"\"ignore\"",
"]",
",",
"single_char_parsing"... | Print the Kirshenbaum ASCII string corresponding to the given Unicode IPA string.
:param str string: the string to act upon
:param dict vargs: the command line arguments | [
"Print",
"the",
"Kirshenbaum",
"ASCII",
"string",
"corresponding",
"to",
"the",
"given",
"Unicode",
"IPA",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__main__.py#L201-L217 | train |
pettarin/ipapy | ipapy/__main__.py | main | def main():
"""
Entry point.
"""
parser = argparse.ArgumentParser(description=DESCRIPTION)
for arg in ARGUMENTS:
if "action" in arg:
if arg["short"] is not None:
parser.add_argument(arg["short"], arg["long"], action=arg["action"], help=arg["help"])
els... | python | def main():
"""
Entry point.
"""
parser = argparse.ArgumentParser(description=DESCRIPTION)
for arg in ARGUMENTS:
if "action" in arg:
if arg["short"] is not None:
parser.add_argument(arg["short"], arg["long"], action=arg["action"], help=arg["help"])
els... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"DESCRIPTION",
")",
"for",
"arg",
"in",
"ARGUMENTS",
":",
"if",
"\"action\"",
"in",
"arg",
":",
"if",
"arg",
"[",
"\"short\"",
"]",
"is",
"not",
"N... | Entry point. | [
"Entry",
"point",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__main__.py#L228-L251 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.ipa_chars | def ipa_chars(self, value):
"""
Set the list of IPAChar objects composing the IPA string
:param list value: list of IPAChar objects
"""
if value is None:
self.__ipa_chars = []
else:
if is_list_of_ipachars(value):
self.__ipa_chars =... | python | def ipa_chars(self, value):
"""
Set the list of IPAChar objects composing the IPA string
:param list value: list of IPAChar objects
"""
if value is None:
self.__ipa_chars = []
else:
if is_list_of_ipachars(value):
self.__ipa_chars =... | [
"def",
"ipa_chars",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"self",
".",
"__ipa_chars",
"=",
"[",
"]",
"else",
":",
"if",
"is_list_of_ipachars",
"(",
"value",
")",
":",
"self",
".",
"__ipa_chars",
"=",
"value",
"else",
... | Set the list of IPAChar objects composing the IPA string
:param list value: list of IPAChar objects | [
"Set",
"the",
"list",
"of",
"IPAChar",
"objects",
"composing",
"the",
"IPA",
"string"
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L111-L123 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.is_equivalent | def is_equivalent(self, other, ignore=False):
"""
Return ``True`` if the IPA string is equivalent to the ``other`` object.
The ``other`` object can be:
1. a Unicode string,
2. a list of IPAChar objects, and
3. another IPAString.
:param variant other: the object... | python | def is_equivalent(self, other, ignore=False):
"""
Return ``True`` if the IPA string is equivalent to the ``other`` object.
The ``other`` object can be:
1. a Unicode string,
2. a list of IPAChar objects, and
3. another IPAString.
:param variant other: the object... | [
"def",
"is_equivalent",
"(",
"self",
",",
"other",
",",
"ignore",
"=",
"False",
")",
":",
"def",
"is_equivalent_to_list_of_ipachars",
"(",
"other",
")",
":",
"\"\"\"\n Return ``True`` if the list of IPAChar objects\n in the canonical representation of the st... | Return ``True`` if the IPA string is equivalent to the ``other`` object.
The ``other`` object can be:
1. a Unicode string,
2. a list of IPAChar objects, and
3. another IPAString.
:param variant other: the object to be compared against
:param bool ignore: if other is a ... | [
"Return",
"True",
"if",
"the",
"IPA",
"string",
"is",
"equivalent",
"to",
"the",
"other",
"object",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L125-L168 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.canonical_representation | def canonical_representation(self):
"""
Return a new IPAString, containing the canonical representation of the current string,
that is, the one composed by the (prefix) minimum number of IPAChar objects.
:rtype: IPAString
"""
return IPAString(unicode_string=u"".join([c._... | python | def canonical_representation(self):
"""
Return a new IPAString, containing the canonical representation of the current string,
that is, the one composed by the (prefix) minimum number of IPAChar objects.
:rtype: IPAString
"""
return IPAString(unicode_string=u"".join([c._... | [
"def",
"canonical_representation",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"unicode_string",
"=",
"u\"\"",
".",
"join",
"(",
"[",
"c",
".",
"__unicode__",
"(",
")",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"]",
")",
")"
] | Return a new IPAString, containing the canonical representation of the current string,
that is, the one composed by the (prefix) minimum number of IPAChar objects.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"the",
"canonical",
"representation",
"of",
"the",
"current",
"string",
"that",
"is",
"the",
"one",
"composed",
"by",
"the",
"(",
"prefix",
")",
"minimum",
"number",
"of",
"IPAChar",
"objects",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L171-L178 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.filter_chars | def filter_chars(self, chars=u""):
"""
Return a new IPAString, containing only the IPA characters specified
by the ``chars`` string.
Valid values for ``chars`` are:
* ``consonants`` or ``cns``
* ``vowels`` or ``vwl``
* ``letters`` or ``cns_vwl``
* ``cns_... | python | def filter_chars(self, chars=u""):
"""
Return a new IPAString, containing only the IPA characters specified
by the ``chars`` string.
Valid values for ``chars`` are:
* ``consonants`` or ``cns``
* ``vowels`` or ``vwl``
* ``letters`` or ``cns_vwl``
* ``cns_... | [
"def",
"filter_chars",
"(",
"self",
",",
"chars",
"=",
"u\"\"",
")",
":",
"if",
"chars",
"in",
"[",
"u\"cns\"",
",",
"u\"consonants\"",
"]",
":",
"return",
"self",
".",
"consonants",
"elif",
"chars",
"in",
"[",
"u\"vwl\"",
",",
"u\"vowels\"",
"]",
":",
... | Return a new IPAString, containing only the IPA characters specified
by the ``chars`` string.
Valid values for ``chars`` are:
* ``consonants`` or ``cns``
* ``vowels`` or ``vwl``
* ``letters`` or ``cns_vwl``
* ``cns_vwl_pstr`` or ``cvp``
* ``cns_vwl_pstr_long`` o... | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
"the",
"IPA",
"characters",
"specified",
"by",
"the",
"chars",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L180-L217 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.consonants | def consonants(self):
"""
Return a new IPAString, containing only the consonants in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_chars if c.is_consonant]) | python | def consonants(self):
"""
Return a new IPAString, containing only the consonants in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_chars if c.is_consonant]) | [
"def",
"consonants",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"c",
".",
"is_consonant",
"]",
")"
] | Return a new IPAString, containing only the consonants in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
"the",
"consonants",
"in",
"the",
"current",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L220-L226 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.vowels | def vowels(self):
"""
Return a new IPAString, containing only the vowels in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_chars if c.is_vowel]) | python | def vowels(self):
"""
Return a new IPAString, containing only the vowels in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_chars if c.is_vowel]) | [
"def",
"vowels",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"c",
".",
"is_vowel",
"]",
")"
] | Return a new IPAString, containing only the vowels in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
"the",
"vowels",
"in",
"the",
"current",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L229-L235 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.cns_vwl | def cns_vwl(self):
"""
Return a new IPAString, containing only:
1. the consonants, and
2. the vowels
in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_chars if c.is_letter]) | python | def cns_vwl(self):
"""
Return a new IPAString, containing only:
1. the consonants, and
2. the vowels
in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_chars if c.is_letter]) | [
"def",
"cns_vwl",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"c",
".",
"is_letter",
"]",
")"
] | Return a new IPAString, containing only:
1. the consonants, and
2. the vowels
in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
":",
"1",
".",
"the",
"consonants",
"and",
"2",
".",
"the",
"vowels"
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L249-L260 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.cns_vwl_pstr | def cns_vwl_pstr(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the primary stress diacritics
in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_char... | python | def cns_vwl_pstr(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the primary stress diacritics
in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_char... | [
"def",
"cns_vwl_pstr",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"(",
"c",
".",
"is_letter",
")",
"or",
"(",
"c",
".",
"is_suprasegmental",
"and",
"c",
".",
"is_pr... | Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the primary stress diacritics
in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
":",
"1",
".",
"the",
"consonants",
"2",
".",
"the",
"vowels",
"and",
"3",
".",
"the",
"primary",
"stress",
"diacritics"
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L263-L275 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.cns_vwl_str | def cns_vwl_str(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics
in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_chars if (c.i... | python | def cns_vwl_str(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics
in the current string.
:rtype: IPAString
"""
return IPAString(ipa_chars=[c for c in self.ipa_chars if (c.i... | [
"def",
"cns_vwl_str",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"(",
"c",
".",
"is_letter",
")",
"or",
"(",
"c",
".",
"is_suprasegmental",
"and",
"c",
".",
"is_str... | Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics
in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
":",
"1",
".",
"the",
"consonants",
"2",
".",
"the",
"vowels",
"and",
"3",
".",
"the",
"stress",
"diacritics"
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L278-L290 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.cns_vwl_str_len | def cns_vwl_str_len(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics, and
4. the length diacritics
in the current string.
:rtype: IPAString
"""
return IPAString(ip... | python | def cns_vwl_str_len(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics, and
4. the length diacritics
in the current string.
:rtype: IPAString
"""
return IPAString(ip... | [
"def",
"cns_vwl_str_len",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"(",
"c",
".",
"is_letter",
")",
"or",
"(",
"c",
".",
"is_suprasegmental",
"and",
"(",
"c",
"."... | Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics, and
4. the length diacritics
in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
":",
"1",
".",
"the",
"consonants",
"2",
".",
"the",
"vowels",
"and",
"3",
".",
"the",
"stress",
"diacritics",
"and",
"4",
".",
"the",
"length",
"diacritics"
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L293-L306 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.cns_vwl_pstr_long | def cns_vwl_pstr_long(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the primary stress diacritics, and
4. the long suprasegmental
in the current string.
:rtype: IPAString
"""
return ... | python | def cns_vwl_pstr_long(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the primary stress diacritics, and
4. the long suprasegmental
in the current string.
:rtype: IPAString
"""
return ... | [
"def",
"cns_vwl_pstr_long",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"(",
"c",
".",
"is_letter",
")",
"or",
"(",
"c",
".",
"is_suprasegmental",
"and",
"(",
"c",
"... | Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the primary stress diacritics, and
4. the long suprasegmental
in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
":",
"1",
".",
"the",
"consonants",
"2",
".",
"the",
"vowels",
"and",
"3",
".",
"the",
"primary",
"stress",
"diacritics",
"and",
"4",
".",
"the",
"long",
"suprasegmental"
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L309-L322 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.cns_vwl_str_len_wb | def cns_vwl_str_len_wb(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics,
4. the length diacritics, and
5. the word breaks
in the current string.
:rtype: IPAString
... | python | def cns_vwl_str_len_wb(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics,
4. the length diacritics, and
5. the word breaks
in the current string.
:rtype: IPAString
... | [
"def",
"cns_vwl_str_len_wb",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"(",
"c",
".",
"is_letter",
")",
"or",
"(",
"c",
".",
"is_suprasegmental",
"and",
"(",
"c",
... | Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics,
4. the length diacritics, and
5. the word breaks
in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
":",
"1",
".",
"the",
"consonants",
"2",
".",
"the",
"vowels",
"and",
"3",
".",
"the",
"stress",
"diacritics",
"4",
".",
"the",
"length",
"diacritics",
"and",
"5",
".",
"the",
"word",
"breaks"
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L325-L339 | train |
pettarin/ipapy | ipapy/ipastring.py | IPAString.cns_vwl_str_len_wb_sb | def cns_vwl_str_len_wb_sb(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics,
4. the length diacritics,
5. the word breaks, and
6. the syllable breaks
in the current string.
... | python | def cns_vwl_str_len_wb_sb(self):
"""
Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics,
4. the length diacritics,
5. the word breaks, and
6. the syllable breaks
in the current string.
... | [
"def",
"cns_vwl_str_len_wb_sb",
"(",
"self",
")",
":",
"return",
"IPAString",
"(",
"ipa_chars",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"ipa_chars",
"if",
"(",
"c",
".",
"is_letter",
")",
"or",
"(",
"c",
".",
"is_suprasegmental",
"and",
"(",
"c",... | Return a new IPAString, containing only:
1. the consonants,
2. the vowels, and
3. the stress diacritics,
4. the length diacritics,
5. the word breaks, and
6. the syllable breaks
in the current string.
:rtype: IPAString | [
"Return",
"a",
"new",
"IPAString",
"containing",
"only",
":",
"1",
".",
"the",
"consonants",
"2",
".",
"the",
"vowels",
"and",
"3",
".",
"the",
"stress",
"diacritics",
"4",
".",
"the",
"length",
"diacritics",
"5",
".",
"the",
"word",
"breaks",
"and",
"... | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipastring.py#L342-L357 | train |
pettarin/ipapy | ipapy/data/__init__.py | convert_unicode_field | def convert_unicode_field(string):
"""
Convert a Unicode field into the corresponding list of Unicode strings.
The (input) Unicode field is a Unicode string containing
one or more Unicode codepoints (``xxxx`` or ``U+xxxx`` or ``xxxx_yyyy``),
separated by a space.
:param str string: the (input)... | python | def convert_unicode_field(string):
"""
Convert a Unicode field into the corresponding list of Unicode strings.
The (input) Unicode field is a Unicode string containing
one or more Unicode codepoints (``xxxx`` or ``U+xxxx`` or ``xxxx_yyyy``),
separated by a space.
:param str string: the (input)... | [
"def",
"convert_unicode_field",
"(",
"string",
")",
":",
"values",
"=",
"[",
"]",
"for",
"codepoint",
"in",
"[",
"s",
"for",
"s",
"in",
"string",
".",
"split",
"(",
"DATA_FILE_CODEPOINT_SEPARATOR",
")",
"if",
"(",
"s",
"!=",
"DATA_FILE_VALUE_NOT_AVAILABLE",
... | Convert a Unicode field into the corresponding list of Unicode strings.
The (input) Unicode field is a Unicode string containing
one or more Unicode codepoints (``xxxx`` or ``U+xxxx`` or ``xxxx_yyyy``),
separated by a space.
:param str string: the (input) Unicode field
:rtype: list of Unicode stri... | [
"Convert",
"a",
"Unicode",
"field",
"into",
"the",
"corresponding",
"list",
"of",
"Unicode",
"strings",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/data/__init__.py#L55-L69 | train |
pettarin/ipapy | ipapy/data/__init__.py | convert_ascii_field | def convert_ascii_field(string):
"""
Convert an ASCII field into the corresponding list of Unicode strings.
The (input) ASCII field is a Unicode string containing
one or more ASCII codepoints (``00xx`` or ``U+00xx`` or
an ASCII string not starting with ``00`` or ``U+``),
separated by a space.
... | python | def convert_ascii_field(string):
"""
Convert an ASCII field into the corresponding list of Unicode strings.
The (input) ASCII field is a Unicode string containing
one or more ASCII codepoints (``00xx`` or ``U+00xx`` or
an ASCII string not starting with ``00`` or ``U+``),
separated by a space.
... | [
"def",
"convert_ascii_field",
"(",
"string",
")",
":",
"values",
"=",
"[",
"]",
"for",
"codepoint",
"in",
"[",
"s",
"for",
"s",
"in",
"string",
".",
"split",
"(",
"DATA_FILE_CODEPOINT_SEPARATOR",
")",
"if",
"(",
"s",
"!=",
"DATA_FILE_VALUE_NOT_AVAILABLE",
")... | Convert an ASCII field into the corresponding list of Unicode strings.
The (input) ASCII field is a Unicode string containing
one or more ASCII codepoints (``00xx`` or ``U+00xx`` or
an ASCII string not starting with ``00`` or ``U+``),
separated by a space.
:param str string: the (input) ASCII fiel... | [
"Convert",
"an",
"ASCII",
"field",
"into",
"the",
"corresponding",
"list",
"of",
"Unicode",
"strings",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/data/__init__.py#L71-L91 | train |
pettarin/ipapy | ipapy/data/__init__.py | convert_raw_tuple | def convert_raw_tuple(value_tuple, format_string):
"""
Convert a tuple of raw values, according to the given line format.
:param tuple value_tuple: the tuple of raw values
:param str format_string: the format of the tuple
:rtype: list of tuples
"""
values = []
for v, c in zip(value_tup... | python | def convert_raw_tuple(value_tuple, format_string):
"""
Convert a tuple of raw values, according to the given line format.
:param tuple value_tuple: the tuple of raw values
:param str format_string: the format of the tuple
:rtype: list of tuples
"""
values = []
for v, c in zip(value_tup... | [
"def",
"convert_raw_tuple",
"(",
"value_tuple",
",",
"format_string",
")",
":",
"values",
"=",
"[",
"]",
"for",
"v",
",",
"c",
"in",
"zip",
"(",
"value_tuple",
",",
"format_string",
")",
":",
"if",
"v",
"is",
"None",
":",
"# append None",
"values",
".",
... | Convert a tuple of raw values, according to the given line format.
:param tuple value_tuple: the tuple of raw values
:param str format_string: the format of the tuple
:rtype: list of tuples | [
"Convert",
"a",
"tuple",
"of",
"raw",
"values",
"according",
"to",
"the",
"given",
"line",
"format",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/data/__init__.py#L93-L124 | train |
pettarin/ipapy | ipapy/data/__init__.py | load_data_file | def load_data_file(
file_path,
file_path_is_relative=False,
comment_string=DATA_FILE_COMMENT,
field_separator=DATA_FILE_FIELD_SEPARATOR,
line_format=None
):
"""
Load a data file, with one record per line and
fields separated by ``field_separator``,
returning a list of tuples.
It... | python | def load_data_file(
file_path,
file_path_is_relative=False,
comment_string=DATA_FILE_COMMENT,
field_separator=DATA_FILE_FIELD_SEPARATOR,
line_format=None
):
"""
Load a data file, with one record per line and
fields separated by ``field_separator``,
returning a list of tuples.
It... | [
"def",
"load_data_file",
"(",
"file_path",
",",
"file_path_is_relative",
"=",
"False",
",",
"comment_string",
"=",
"DATA_FILE_COMMENT",
",",
"field_separator",
"=",
"DATA_FILE_FIELD_SEPARATOR",
",",
"line_format",
"=",
"None",
")",
":",
"raw_tuples",
"=",
"[",
"]",
... | Load a data file, with one record per line and
fields separated by ``field_separator``,
returning a list of tuples.
It ignores lines starting with ``comment_string`` or empty lines.
If ``values_per_line`` is not ``None``,
check that each line (tuple)
has the prescribed number of values.
:... | [
"Load",
"a",
"data",
"file",
"with",
"one",
"record",
"per",
"line",
"and",
"fields",
"separated",
"by",
"field_separator",
"returning",
"a",
"list",
"of",
"tuples",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/data/__init__.py#L126-L166 | train |
pettarin/ipapy | ipapy/data/__init__.py | load_ipa_data | def load_ipa_data():
"""
Load the IPA data from the built-in IPA database, creating the following globals:
1. ``IPA_CHARS``: list of all IPAChar objects
2. ``UNICODE_TO_IPA``: dict mapping a Unicode string (often, a single char) to an IPAChar
3. ``UNICODE_TO_IPA_MAX_KEY_LENGTH``: length of a longes... | python | def load_ipa_data():
"""
Load the IPA data from the built-in IPA database, creating the following globals:
1. ``IPA_CHARS``: list of all IPAChar objects
2. ``UNICODE_TO_IPA``: dict mapping a Unicode string (often, a single char) to an IPAChar
3. ``UNICODE_TO_IPA_MAX_KEY_LENGTH``: length of a longes... | [
"def",
"load_ipa_data",
"(",
")",
":",
"ipa_signs",
"=",
"[",
"]",
"unicode_to_ipa",
"=",
"{",
"}",
"ipa_to_unicode",
"=",
"{",
"}",
"max_key_length",
"=",
"0",
"for",
"line",
"in",
"load_data_file",
"(",
"file_path",
"=",
"u\"ipa.dat\"",
",",
"file_path_is_... | Load the IPA data from the built-in IPA database, creating the following globals:
1. ``IPA_CHARS``: list of all IPAChar objects
2. ``UNICODE_TO_IPA``: dict mapping a Unicode string (often, a single char) to an IPAChar
3. ``UNICODE_TO_IPA_MAX_KEY_LENGTH``: length of a longest key in ``UNICODE_TO_IPA``
4... | [
"Load",
"the",
"IPA",
"data",
"from",
"the",
"built",
"-",
"in",
"IPA",
"database",
"creating",
"the",
"following",
"globals",
":"
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/data/__init__.py#L168-L217 | train |
pettarin/ipapy | ipapy/__init__.py | split_using_dictionary | def split_using_dictionary(string, dictionary, max_key_length, single_char_parsing=False):
"""
Return a list of (non-empty) substrings of the given string,
where each substring is either:
1. the longest string starting at the current index
that is a key in the dictionary, or
2. a single ... | python | def split_using_dictionary(string, dictionary, max_key_length, single_char_parsing=False):
"""
Return a list of (non-empty) substrings of the given string,
where each substring is either:
1. the longest string starting at the current index
that is a key in the dictionary, or
2. a single ... | [
"def",
"split_using_dictionary",
"(",
"string",
",",
"dictionary",
",",
"max_key_length",
",",
"single_char_parsing",
"=",
"False",
")",
":",
"def",
"substring",
"(",
"string",
",",
"i",
",",
"j",
")",
":",
"if",
"isinstance",
"(",
"string",
"[",
"i",
"]",... | Return a list of (non-empty) substrings of the given string,
where each substring is either:
1. the longest string starting at the current index
that is a key in the dictionary, or
2. a single character that is not a key in the dictionary.
If ``single_char_parsing`` is ``False``,
parse ... | [
"Return",
"a",
"list",
"of",
"(",
"non",
"-",
"empty",
")",
"substrings",
"of",
"the",
"given",
"string",
"where",
"each",
"substring",
"is",
"either",
":",
"1",
".",
"the",
"longest",
"string",
"starting",
"at",
"the",
"current",
"index",
"that",
"is",
... | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__init__.py#L26-L70 | train |
pettarin/ipapy | ipapy/__init__.py | ipa_substrings | def ipa_substrings(unicode_string, single_char_parsing=False):
"""
Return a list of (non-empty) substrings of the given string,
where each substring is either:
1. the longest Unicode string starting at the current index
representing a (known) valid IPA character, or
2. a single Unicode c... | python | def ipa_substrings(unicode_string, single_char_parsing=False):
"""
Return a list of (non-empty) substrings of the given string,
where each substring is either:
1. the longest Unicode string starting at the current index
representing a (known) valid IPA character, or
2. a single Unicode c... | [
"def",
"ipa_substrings",
"(",
"unicode_string",
",",
"single_char_parsing",
"=",
"False",
")",
":",
"return",
"split_using_dictionary",
"(",
"string",
"=",
"unicode_string",
",",
"dictionary",
"=",
"UNICODE_TO_IPA",
",",
"max_key_length",
"=",
"UNICODE_TO_IPA_MAX_KEY_LE... | Return a list of (non-empty) substrings of the given string,
where each substring is either:
1. the longest Unicode string starting at the current index
representing a (known) valid IPA character, or
2. a single Unicode character (which is not IPA valid).
If ``single_char_parsing`` is ``Fal... | [
"Return",
"a",
"list",
"of",
"(",
"non",
"-",
"empty",
")",
"substrings",
"of",
"the",
"given",
"string",
"where",
"each",
"substring",
"is",
"either",
":",
"1",
".",
"the",
"longest",
"Unicode",
"string",
"starting",
"at",
"the",
"current",
"index",
"re... | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__init__.py#L72-L102 | train |
pettarin/ipapy | ipapy/__init__.py | invalid_ipa_characters | def invalid_ipa_characters(unicode_string, indices=False):
"""
Return the list of Unicode characters
in the given Unicode string
that are not IPA valid.
Return ``None`` if ``unicode_string`` is ``None``.
:param str unicode_string: the Unicode string to be parsed
:param bool indices: if ``T... | python | def invalid_ipa_characters(unicode_string, indices=False):
"""
Return the list of Unicode characters
in the given Unicode string
that are not IPA valid.
Return ``None`` if ``unicode_string`` is ``None``.
:param str unicode_string: the Unicode string to be parsed
:param bool indices: if ``T... | [
"def",
"invalid_ipa_characters",
"(",
"unicode_string",
",",
"indices",
"=",
"False",
")",
":",
"if",
"unicode_string",
"is",
"None",
":",
"return",
"None",
"if",
"indices",
":",
"return",
"[",
"(",
"i",
",",
"unicode_string",
"[",
"i",
"]",
")",
"for",
... | Return the list of Unicode characters
in the given Unicode string
that are not IPA valid.
Return ``None`` if ``unicode_string`` is ``None``.
:param str unicode_string: the Unicode string to be parsed
:param bool indices: if ``True``, return a list of pairs (index, invalid character),
... | [
"Return",
"the",
"list",
"of",
"Unicode",
"characters",
"in",
"the",
"given",
"Unicode",
"string",
"that",
"are",
"not",
"IPA",
"valid",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__init__.py#L104-L121 | train |
pettarin/ipapy | ipapy/__init__.py | remove_invalid_ipa_characters | def remove_invalid_ipa_characters(unicode_string, return_invalid=False, single_char_parsing=False):
"""
Remove all Unicode characters that are not IPA valid
from the given string,
and return a list of substrings of the given string,
each mapping to a (known) valid IPA character.
Return ``None``... | python | def remove_invalid_ipa_characters(unicode_string, return_invalid=False, single_char_parsing=False):
"""
Remove all Unicode characters that are not IPA valid
from the given string,
and return a list of substrings of the given string,
each mapping to a (known) valid IPA character.
Return ``None``... | [
"def",
"remove_invalid_ipa_characters",
"(",
"unicode_string",
",",
"return_invalid",
"=",
"False",
",",
"single_char_parsing",
"=",
"False",
")",
":",
"if",
"unicode_string",
"is",
"None",
":",
"return",
"None",
"substrings",
"=",
"ipa_substrings",
"(",
"unicode_st... | Remove all Unicode characters that are not IPA valid
from the given string,
and return a list of substrings of the given string,
each mapping to a (known) valid IPA character.
Return ``None`` if ``unicode_string`` is ``None``.
:param str unicode_string: the Unicode string to be parsed
:param b... | [
"Remove",
"all",
"Unicode",
"characters",
"that",
"are",
"not",
"IPA",
"valid",
"from",
"the",
"given",
"string",
"and",
"return",
"a",
"list",
"of",
"substrings",
"of",
"the",
"given",
"string",
"each",
"mapping",
"to",
"a",
"(",
"known",
")",
"valid",
... | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/__init__.py#L140-L162 | train |
pettarin/ipapy | ipapy/ipachar.py | variant_to_list | def variant_to_list(obj):
"""
Return a list containing the descriptors in the given object.
The ``obj`` can be a list or a set of descriptor strings, or a Unicode string.
If ``obj`` is a Unicode string, it will be split using spaces as delimiters.
:param variant obj: the object to be parsed
... | python | def variant_to_list(obj):
"""
Return a list containing the descriptors in the given object.
The ``obj`` can be a list or a set of descriptor strings, or a Unicode string.
If ``obj`` is a Unicode string, it will be split using spaces as delimiters.
:param variant obj: the object to be parsed
... | [
"def",
"variant_to_list",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"return",
"obj",
"elif",
"is_unicode_string",
"(",
"obj",
")",
":",
"return",
"[",
"s",
"for",
"s",
"in",
"obj",
".",
"split",
"(",
")",
"if",
"l... | Return a list containing the descriptors in the given object.
The ``obj`` can be a list or a set of descriptor strings, or a Unicode string.
If ``obj`` is a Unicode string, it will be split using spaces as delimiters.
:param variant obj: the object to be parsed
:rtype: list
:raise TypeError:... | [
"Return",
"a",
"list",
"containing",
"the",
"descriptors",
"in",
"the",
"given",
"object",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L311-L329 | train |
pettarin/ipapy | ipapy/ipachar.py | variant_to_canonical_string | def variant_to_canonical_string(obj):
"""
Return a list containing the canonical string for the given object.
The ``obj`` can be a list or a set of descriptor strings, or a Unicode string.
If ``obj`` is a Unicode string, it will be split using spaces as delimiters.
:param variant obj: the obj... | python | def variant_to_canonical_string(obj):
"""
Return a list containing the canonical string for the given object.
The ``obj`` can be a list or a set of descriptor strings, or a Unicode string.
If ``obj`` is a Unicode string, it will be split using spaces as delimiters.
:param variant obj: the obj... | [
"def",
"variant_to_canonical_string",
"(",
"obj",
")",
":",
"acc",
"=",
"[",
"DG_ALL_DESCRIPTORS",
".",
"canonical_value",
"(",
"p",
")",
"for",
"p",
"in",
"variant_to_list",
"(",
"obj",
")",
"]",
"acc",
"=",
"sorted",
"(",
"[",
"a",
"for",
"a",
"in",
... | Return a list containing the canonical string for the given object.
The ``obj`` can be a list or a set of descriptor strings, or a Unicode string.
If ``obj`` is a Unicode string, it will be split using spaces as delimiters.
:param variant obj: the object to be parsed
:rtype: str
:raise TypeE... | [
"Return",
"a",
"list",
"containing",
"the",
"canonical",
"string",
"for",
"the",
"given",
"object",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L331-L345 | train |
pettarin/ipapy | ipapy/ipachar.py | is_list_of_ipachars | def is_list_of_ipachars(obj):
"""
Return ``True`` if the given object is a list of IPAChar objects.
:param object obj: the object to test
:rtype: bool
"""
if isinstance(obj, list):
for e in obj:
if not isinstance(e, IPAChar):
return False
return True
... | python | def is_list_of_ipachars(obj):
"""
Return ``True`` if the given object is a list of IPAChar objects.
:param object obj: the object to test
:rtype: bool
"""
if isinstance(obj, list):
for e in obj:
if not isinstance(e, IPAChar):
return False
return True
... | [
"def",
"is_list_of_ipachars",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"for",
"e",
"in",
"obj",
":",
"if",
"not",
"isinstance",
"(",
"e",
",",
"IPAChar",
")",
":",
"return",
"False",
"return",
"True",
"return",
"Fa... | Return ``True`` if the given object is a list of IPAChar objects.
:param object obj: the object to test
:rtype: bool | [
"Return",
"True",
"if",
"the",
"given",
"object",
"is",
"a",
"list",
"of",
"IPAChar",
"objects",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L508-L520 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAChar.is_equivalent | def is_equivalent(self, other):
"""
Return ``True`` if the IPA character is equivalent to the ``other`` object.
The ``other`` object can be:
1. a Unicode string, containing the representation of the IPA character,
2. a Unicode string, containing a space-separated list of descri... | python | def is_equivalent(self, other):
"""
Return ``True`` if the IPA character is equivalent to the ``other`` object.
The ``other`` object can be:
1. a Unicode string, containing the representation of the IPA character,
2. a Unicode string, containing a space-separated list of descri... | [
"def",
"is_equivalent",
"(",
"self",
",",
"other",
")",
":",
"if",
"(",
"self",
".",
"unicode_repr",
"is",
"not",
"None",
")",
"and",
"(",
"is_unicode_string",
"(",
"other",
")",
")",
"and",
"(",
"self",
".",
"unicode_repr",
"==",
"other",
")",
":",
... | Return ``True`` if the IPA character is equivalent to the ``other`` object.
The ``other`` object can be:
1. a Unicode string, containing the representation of the IPA character,
2. a Unicode string, containing a space-separated list of descriptors,
3. a list of Unicode strings, contain... | [
"Return",
"True",
"if",
"the",
"IPA",
"character",
"is",
"equivalent",
"to",
"the",
"other",
"object",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L403-L423 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAChar.dg_value | def dg_value(self, descriptor_group):
"""
Return the canonical value of a descriptor of the character,
provided it is present in the given descriptor group.
If not present, return ``None``.
:param IPADescriptorGroup descriptor_group: the descriptor group to be checked against
... | python | def dg_value(self, descriptor_group):
"""
Return the canonical value of a descriptor of the character,
provided it is present in the given descriptor group.
If not present, return ``None``.
:param IPADescriptorGroup descriptor_group: the descriptor group to be checked against
... | [
"def",
"dg_value",
"(",
"self",
",",
"descriptor_group",
")",
":",
"for",
"p",
"in",
"self",
".",
"descriptors",
":",
"if",
"p",
"in",
"descriptor_group",
":",
"return",
"descriptor_group",
".",
"canonical_value",
"(",
"p",
")",
"return",
"None"
] | Return the canonical value of a descriptor of the character,
provided it is present in the given descriptor group.
If not present, return ``None``.
:param IPADescriptorGroup descriptor_group: the descriptor group to be checked against
:rtype: str | [
"Return",
"the",
"canonical",
"value",
"of",
"a",
"descriptor",
"of",
"the",
"character",
"provided",
"it",
"is",
"present",
"in",
"the",
"given",
"descriptor",
"group",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L480-L493 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAChar.has_descriptor | def has_descriptor(self, descriptor):
"""
Return ``True`` if the character has the given descriptor.
:param IPADescriptor descriptor: the descriptor to be checked against
:rtype: bool
"""
for p in self.descriptors:
if p in descriptor:
return T... | python | def has_descriptor(self, descriptor):
"""
Return ``True`` if the character has the given descriptor.
:param IPADescriptor descriptor: the descriptor to be checked against
:rtype: bool
"""
for p in self.descriptors:
if p in descriptor:
return T... | [
"def",
"has_descriptor",
"(",
"self",
",",
"descriptor",
")",
":",
"for",
"p",
"in",
"self",
".",
"descriptors",
":",
"if",
"p",
"in",
"descriptor",
":",
"return",
"True",
"return",
"False"
] | Return ``True`` if the character has the given descriptor.
:param IPADescriptor descriptor: the descriptor to be checked against
:rtype: bool | [
"Return",
"True",
"if",
"the",
"character",
"has",
"the",
"given",
"descriptor",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L495-L505 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAConsonant.voicing | def voicing(self, value):
"""
Set the voicing of the consonant.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_C_VOICING):
raise ValueError("Unrecognized value for voicing: '%s'" % value)
self.__voicing = value | python | def voicing(self, value):
"""
Set the voicing of the consonant.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_C_VOICING):
raise ValueError("Unrecognized value for voicing: '%s'" % value)
self.__voicing = value | [
"def",
"voicing",
"(",
"self",
",",
"value",
")",
":",
"if",
"(",
"value",
"is",
"not",
"None",
")",
"and",
"(",
"not",
"value",
"in",
"DG_C_VOICING",
")",
":",
"raise",
"ValueError",
"(",
"\"Unrecognized value for voicing: '%s'\"",
"%",
"value",
")",
"sel... | Set the voicing of the consonant.
:param str value: the value to be set | [
"Set",
"the",
"voicing",
"of",
"the",
"consonant",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L641-L649 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAConsonant.place | def place(self, value):
"""
Set the place of articulation of the consonant.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_C_PLACE):
raise ValueError("Unrecognized value for place: '%s'" % value)
self.__place = value | python | def place(self, value):
"""
Set the place of articulation of the consonant.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_C_PLACE):
raise ValueError("Unrecognized value for place: '%s'" % value)
self.__place = value | [
"def",
"place",
"(",
"self",
",",
"value",
")",
":",
"if",
"(",
"value",
"is",
"not",
"None",
")",
"and",
"(",
"not",
"value",
"in",
"DG_C_PLACE",
")",
":",
"raise",
"ValueError",
"(",
"\"Unrecognized value for place: '%s'\"",
"%",
"value",
")",
"self",
... | Set the place of articulation of the consonant.
:param str value: the value to be set | [
"Set",
"the",
"place",
"of",
"articulation",
"of",
"the",
"consonant",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L660-L668 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAConsonant.manner | def manner(self, value):
"""
Set the manner of articulation of the consonant.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_C_MANNER):
raise ValueError("Unrecognized value for manner: '%s'" % value)
self.__manner = valu... | python | def manner(self, value):
"""
Set the manner of articulation of the consonant.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_C_MANNER):
raise ValueError("Unrecognized value for manner: '%s'" % value)
self.__manner = valu... | [
"def",
"manner",
"(",
"self",
",",
"value",
")",
":",
"if",
"(",
"value",
"is",
"not",
"None",
")",
"and",
"(",
"not",
"value",
"in",
"DG_C_MANNER",
")",
":",
"raise",
"ValueError",
"(",
"\"Unrecognized value for manner: '%s'\"",
"%",
"value",
")",
"self",... | Set the manner of articulation of the consonant.
:param str value: the value to be set | [
"Set",
"the",
"manner",
"of",
"articulation",
"of",
"the",
"consonant",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L679-L687 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAVowel.height | def height(self, value):
"""
Set the height of the vowel.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_V_HEIGHT):
raise ValueError("Unrecognized value for height: '%s'" % value)
self.__height = value | python | def height(self, value):
"""
Set the height of the vowel.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_V_HEIGHT):
raise ValueError("Unrecognized value for height: '%s'" % value)
self.__height = value | [
"def",
"height",
"(",
"self",
",",
"value",
")",
":",
"if",
"(",
"value",
"is",
"not",
"None",
")",
"and",
"(",
"not",
"value",
"in",
"DG_V_HEIGHT",
")",
":",
"raise",
"ValueError",
"(",
"\"Unrecognized value for height: '%s'\"",
"%",
"value",
")",
"self",... | Set the height of the vowel.
:param str value: the value to be set | [
"Set",
"the",
"height",
"of",
"the",
"vowel",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L778-L786 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAVowel.backness | def backness(self, value):
"""
Set the backness of the vowel.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_V_BACKNESS):
raise ValueError("Unrecognized value for backness: '%s'" % value)
self.__backness = value | python | def backness(self, value):
"""
Set the backness of the vowel.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_V_BACKNESS):
raise ValueError("Unrecognized value for backness: '%s'" % value)
self.__backness = value | [
"def",
"backness",
"(",
"self",
",",
"value",
")",
":",
"if",
"(",
"value",
"is",
"not",
"None",
")",
"and",
"(",
"not",
"value",
"in",
"DG_V_BACKNESS",
")",
":",
"raise",
"ValueError",
"(",
"\"Unrecognized value for backness: '%s'\"",
"%",
"value",
")",
"... | Set the backness of the vowel.
:param str value: the value to be set | [
"Set",
"the",
"backness",
"of",
"the",
"vowel",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L797-L805 | train |
pettarin/ipapy | ipapy/ipachar.py | IPAVowel.roundness | def roundness(self, value):
"""
Set the roundness of the vowel.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_V_ROUNDNESS):
raise ValueError("Unrecognized value for roundness: '%s'" % value)
self.__roundness = value | python | def roundness(self, value):
"""
Set the roundness of the vowel.
:param str value: the value to be set
"""
if (value is not None) and (not value in DG_V_ROUNDNESS):
raise ValueError("Unrecognized value for roundness: '%s'" % value)
self.__roundness = value | [
"def",
"roundness",
"(",
"self",
",",
"value",
")",
":",
"if",
"(",
"value",
"is",
"not",
"None",
")",
"and",
"(",
"not",
"value",
"in",
"DG_V_ROUNDNESS",
")",
":",
"raise",
"ValueError",
"(",
"\"Unrecognized value for roundness: '%s'\"",
"%",
"value",
")",
... | Set the roundness of the vowel.
:param str value: the value to be set | [
"Set",
"the",
"roundness",
"of",
"the",
"vowel",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipachar.py#L816-L824 | train |
pettarin/ipapy | ipapy/kirshenbaummapper.py | KirshenbaumMapper._load_data | def _load_data(self):
"""
Load the Kirshenbaum ASCII IPA data from the built-in database.
"""
ipa_canonical_string_to_ascii_str = dict()
for line in load_data_file(
file_path=self.DATA_FILE_PATH,
file_path_is_relative=True,
line_format=u"sxA"
... | python | def _load_data(self):
"""
Load the Kirshenbaum ASCII IPA data from the built-in database.
"""
ipa_canonical_string_to_ascii_str = dict()
for line in load_data_file(
file_path=self.DATA_FILE_PATH,
file_path_is_relative=True,
line_format=u"sxA"
... | [
"def",
"_load_data",
"(",
"self",
")",
":",
"ipa_canonical_string_to_ascii_str",
"=",
"dict",
"(",
")",
"for",
"line",
"in",
"load_data_file",
"(",
"file_path",
"=",
"self",
".",
"DATA_FILE_PATH",
",",
"file_path_is_relative",
"=",
"True",
",",
"line_format",
"=... | Load the Kirshenbaum ASCII IPA data from the built-in database. | [
"Load",
"the",
"Kirshenbaum",
"ASCII",
"IPA",
"data",
"from",
"the",
"built",
"-",
"in",
"database",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/kirshenbaummapper.py#L29-L44 | train |
pettarin/ipapy | ipapy/ipadescriptor.py | IPADescriptorGroup.canonical_value | def canonical_value(self, query):
"""
Return the canonical value corresponding to the given query value.
Return ``None`` if the query value is not present in any descriptor of the group.
:param str query: the descriptor value to be checked against
"""
for d in self.desc... | python | def canonical_value(self, query):
"""
Return the canonical value corresponding to the given query value.
Return ``None`` if the query value is not present in any descriptor of the group.
:param str query: the descriptor value to be checked against
"""
for d in self.desc... | [
"def",
"canonical_value",
"(",
"self",
",",
"query",
")",
":",
"for",
"d",
"in",
"self",
".",
"descriptors",
":",
"if",
"query",
"in",
"d",
":",
"return",
"d",
".",
"canonical_label",
"return",
"None"
] | Return the canonical value corresponding to the given query value.
Return ``None`` if the query value is not present in any descriptor of the group.
:param str query: the descriptor value to be checked against | [
"Return",
"the",
"canonical",
"value",
"corresponding",
"to",
"the",
"given",
"query",
"value",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/ipadescriptor.py#L133-L144 | train |
pettarin/ipapy | ipapy/arpabetmapper.py | ARPABETMapper._load_data | def _load_data(self):
"""
Load the ARPABET ASCII IPA data from the built-in database.
"""
ipa_canonical_string_to_ascii_str = dict()
for line in load_data_file(
file_path=self.DATA_FILE_PATH,
file_path_is_relative=True,
line_format=u"UA"
... | python | def _load_data(self):
"""
Load the ARPABET ASCII IPA data from the built-in database.
"""
ipa_canonical_string_to_ascii_str = dict()
for line in load_data_file(
file_path=self.DATA_FILE_PATH,
file_path_is_relative=True,
line_format=u"UA"
... | [
"def",
"_load_data",
"(",
"self",
")",
":",
"ipa_canonical_string_to_ascii_str",
"=",
"dict",
"(",
")",
"for",
"line",
"in",
"load_data_file",
"(",
"file_path",
"=",
"self",
".",
"DATA_FILE_PATH",
",",
"file_path_is_relative",
"=",
"True",
",",
"line_format",
"=... | Load the ARPABET ASCII IPA data from the built-in database. | [
"Load",
"the",
"ARPABET",
"ASCII",
"IPA",
"data",
"from",
"the",
"built",
"-",
"in",
"database",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/arpabetmapper.py#L29-L46 | train |
pettarin/ipapy | ipapy/compatibility.py | is_unicode_string | def is_unicode_string(string):
"""
Return ``True`` if the given string is a Unicode string,
that is, of type ``unicode`` in Python 2 or ``str`` in Python 3.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to be checked
:rtype: bool
"""
if string is None:
... | python | def is_unicode_string(string):
"""
Return ``True`` if the given string is a Unicode string,
that is, of type ``unicode`` in Python 2 or ``str`` in Python 3.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to be checked
:rtype: bool
"""
if string is None:
... | [
"def",
"is_unicode_string",
"(",
"string",
")",
":",
"if",
"string",
"is",
"None",
":",
"return",
"None",
"if",
"PY2",
":",
"return",
"isinstance",
"(",
"string",
",",
"unicode",
")",
"return",
"isinstance",
"(",
"string",
",",
"str",
")"
] | Return ``True`` if the given string is a Unicode string,
that is, of type ``unicode`` in Python 2 or ``str`` in Python 3.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to be checked
:rtype: bool | [
"Return",
"True",
"if",
"the",
"given",
"string",
"is",
"a",
"Unicode",
"string",
"that",
"is",
"of",
"type",
"unicode",
"in",
"Python",
"2",
"or",
"str",
"in",
"Python",
"3",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/compatibility.py#L25-L39 | train |
pettarin/ipapy | ipapy/compatibility.py | to_unicode_string | def to_unicode_string(string):
"""
Return a Unicode string out of the given string.
On Python 2, it calls ``unicode`` with ``utf-8`` encoding.
On Python 3, it just returns the given string.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to convert to Unicode
... | python | def to_unicode_string(string):
"""
Return a Unicode string out of the given string.
On Python 2, it calls ``unicode`` with ``utf-8`` encoding.
On Python 3, it just returns the given string.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to convert to Unicode
... | [
"def",
"to_unicode_string",
"(",
"string",
")",
":",
"if",
"string",
"is",
"None",
":",
"return",
"None",
"if",
"is_unicode_string",
"(",
"string",
")",
":",
"return",
"string",
"# if reached here, string is a byte string ",
"if",
"PY2",
":",
"return",
"unicode",
... | Return a Unicode string out of the given string.
On Python 2, it calls ``unicode`` with ``utf-8`` encoding.
On Python 3, it just returns the given string.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to convert to Unicode
:rtype: (Unicode) str | [
"Return",
"a",
"Unicode",
"string",
"out",
"of",
"the",
"given",
"string",
".",
"On",
"Python",
"2",
"it",
"calls",
"unicode",
"with",
"utf",
"-",
"8",
"encoding",
".",
"On",
"Python",
"3",
"it",
"just",
"returns",
"the",
"given",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/compatibility.py#L41-L60 | train |
pettarin/ipapy | ipapy/compatibility.py | to_str | def to_str(string):
"""
Return the given string (either byte string or Unicode string)
converted to native-str, that is,
a byte string on Python 2, or a Unicode string on Python 3.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to convert to native-str
:rtype: nat... | python | def to_str(string):
"""
Return the given string (either byte string or Unicode string)
converted to native-str, that is,
a byte string on Python 2, or a Unicode string on Python 3.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to convert to native-str
:rtype: nat... | [
"def",
"to_str",
"(",
"string",
")",
":",
"if",
"string",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"string",
",",
"str",
")",
":",
"return",
"string",
"if",
"PY2",
":",
"return",
"string",
".",
"encode",
"(",
"\"utf-8\"",
")",
"r... | Return the given string (either byte string or Unicode string)
converted to native-str, that is,
a byte string on Python 2, or a Unicode string on Python 3.
Return ``None`` if ``string`` is ``None``.
:param str string: the string to convert to native-str
:rtype: native-str | [
"Return",
"the",
"given",
"string",
"(",
"either",
"byte",
"string",
"or",
"Unicode",
"string",
")",
"converted",
"to",
"native",
"-",
"str",
"that",
"is",
"a",
"byte",
"string",
"on",
"Python",
"2",
"or",
"a",
"Unicode",
"string",
"on",
"Python",
"3",
... | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/compatibility.py#L62-L79 | train |
pettarin/ipapy | ipapy/compatibility.py | hex_to_unichr | def hex_to_unichr(hex_string):
"""
Return the Unicode character with the given codepoint,
given as an hexadecimal string.
Return ``None`` if ``hex_string`` is ``None`` or is empty.
Example::
"0061" => a
"U+0061" => a
:param str hex_string: the Unicode codepoint of the desire... | python | def hex_to_unichr(hex_string):
"""
Return the Unicode character with the given codepoint,
given as an hexadecimal string.
Return ``None`` if ``hex_string`` is ``None`` or is empty.
Example::
"0061" => a
"U+0061" => a
:param str hex_string: the Unicode codepoint of the desire... | [
"def",
"hex_to_unichr",
"(",
"hex_string",
")",
":",
"if",
"(",
"hex_string",
"is",
"None",
")",
"or",
"(",
"len",
"(",
"hex_string",
")",
"<",
"1",
")",
":",
"return",
"None",
"if",
"hex_string",
".",
"startswith",
"(",
"\"U+\"",
")",
":",
"hex_string... | Return the Unicode character with the given codepoint,
given as an hexadecimal string.
Return ``None`` if ``hex_string`` is ``None`` or is empty.
Example::
"0061" => a
"U+0061" => a
:param str hex_string: the Unicode codepoint of the desired character
:rtype: (Unicode) str | [
"Return",
"the",
"Unicode",
"character",
"with",
"the",
"given",
"codepoint",
"given",
"as",
"an",
"hexadecimal",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/compatibility.py#L96-L114 | train |
pettarin/ipapy | ipapy/compatibility.py | unicode_to_hex | def unicode_to_hex(unicode_string):
"""
Return a string containing the Unicode hexadecimal codepoint
of each Unicode character in the given Unicode string.
Return ``None`` if ``unicode_string`` is ``None``.
Example::
a => U+0061
ab => U+0061 U+0062
:param str unicode_string: ... | python | def unicode_to_hex(unicode_string):
"""
Return a string containing the Unicode hexadecimal codepoint
of each Unicode character in the given Unicode string.
Return ``None`` if ``unicode_string`` is ``None``.
Example::
a => U+0061
ab => U+0061 U+0062
:param str unicode_string: ... | [
"def",
"unicode_to_hex",
"(",
"unicode_string",
")",
":",
"if",
"unicode_string",
"is",
"None",
":",
"return",
"None",
"acc",
"=",
"[",
"]",
"for",
"c",
"in",
"unicode_string",
":",
"s",
"=",
"hex",
"(",
"ord",
"(",
"c",
")",
")",
".",
"replace",
"("... | Return a string containing the Unicode hexadecimal codepoint
of each Unicode character in the given Unicode string.
Return ``None`` if ``unicode_string`` is ``None``.
Example::
a => U+0061
ab => U+0061 U+0062
:param str unicode_string: the Unicode string to convert
:rtype: (Unico... | [
"Return",
"a",
"string",
"containing",
"the",
"Unicode",
"hexadecimal",
"codepoint",
"of",
"each",
"Unicode",
"character",
"in",
"the",
"given",
"Unicode",
"string",
"."
] | ede4b3c40636f6eb90068369d31a2e75c7115324 | https://github.com/pettarin/ipapy/blob/ede4b3c40636f6eb90068369d31a2e75c7115324/ipapy/compatibility.py#L116-L136 | train |
TeamHG-Memex/html-text | html_text/html_text.py | parse_html | def parse_html(html):
""" Create an lxml.html.HtmlElement from a string with html.
XXX: mostly copy-pasted from parsel.selector.create_root_node
"""
body = html.strip().replace('\x00', '').encode('utf8') or b'<html/>'
parser = lxml.html.HTMLParser(recover=True, encoding='utf8')
root = lxml.etree... | python | def parse_html(html):
""" Create an lxml.html.HtmlElement from a string with html.
XXX: mostly copy-pasted from parsel.selector.create_root_node
"""
body = html.strip().replace('\x00', '').encode('utf8') or b'<html/>'
parser = lxml.html.HTMLParser(recover=True, encoding='utf8')
root = lxml.etree... | [
"def",
"parse_html",
"(",
"html",
")",
":",
"body",
"=",
"html",
".",
"strip",
"(",
")",
".",
"replace",
"(",
"'\\x00'",
",",
"''",
")",
".",
"encode",
"(",
"'utf8'",
")",
"or",
"b'<html/>'",
"parser",
"=",
"lxml",
".",
"html",
".",
"HTMLParser",
"... | Create an lxml.html.HtmlElement from a string with html.
XXX: mostly copy-pasted from parsel.selector.create_root_node | [
"Create",
"an",
"lxml",
".",
"html",
".",
"HtmlElement",
"from",
"a",
"string",
"with",
"html",
".",
"XXX",
":",
"mostly",
"copy",
"-",
"pasted",
"from",
"parsel",
".",
"selector",
".",
"create_root_node"
] | 871d4dbe9f4f99e5f041110c60458adcaae6fab4 | https://github.com/TeamHG-Memex/html-text/blob/871d4dbe9f4f99e5f041110c60458adcaae6fab4/html_text/html_text.py#L45-L54 | train |
TeamHG-Memex/html-text | html_text/html_text.py | etree_to_text | def etree_to_text(tree,
guess_punct_space=True,
guess_layout=True,
newline_tags=NEWLINE_TAGS,
double_newline_tags=DOUBLE_NEWLINE_TAGS):
"""
Convert a html tree to text. Tree should be cleaned with
``html_text.html_text.cleaner.clean_htm... | python | def etree_to_text(tree,
guess_punct_space=True,
guess_layout=True,
newline_tags=NEWLINE_TAGS,
double_newline_tags=DOUBLE_NEWLINE_TAGS):
"""
Convert a html tree to text. Tree should be cleaned with
``html_text.html_text.cleaner.clean_htm... | [
"def",
"etree_to_text",
"(",
"tree",
",",
"guess_punct_space",
"=",
"True",
",",
"guess_layout",
"=",
"True",
",",
"newline_tags",
"=",
"NEWLINE_TAGS",
",",
"double_newline_tags",
"=",
"DOUBLE_NEWLINE_TAGS",
")",
":",
"chunks",
"=",
"[",
"]",
"_NEWLINE",
"=",
... | Convert a html tree to text. Tree should be cleaned with
``html_text.html_text.cleaner.clean_html`` before passing to this
function.
See html_text.extract_text docstring for description of the
approach and options. | [
"Convert",
"a",
"html",
"tree",
"to",
"text",
".",
"Tree",
"should",
"be",
"cleaned",
"with",
"html_text",
".",
"html_text",
".",
"cleaner",
".",
"clean_html",
"before",
"passing",
"to",
"this",
"function",
"."
] | 871d4dbe9f4f99e5f041110c60458adcaae6fab4 | https://github.com/TeamHG-Memex/html-text/blob/871d4dbe9f4f99e5f041110c60458adcaae6fab4/html_text/html_text.py#L67-L137 | train |
TeamHG-Memex/html-text | html_text/html_text.py | selector_to_text | def selector_to_text(sel, guess_punct_space=True, guess_layout=True):
""" Convert a cleaned parsel.Selector to text.
See html_text.extract_text docstring for description of the approach
and options.
"""
import parsel
if isinstance(sel, parsel.SelectorList):
# if selecting a specific xpat... | python | def selector_to_text(sel, guess_punct_space=True, guess_layout=True):
""" Convert a cleaned parsel.Selector to text.
See html_text.extract_text docstring for description of the approach
and options.
"""
import parsel
if isinstance(sel, parsel.SelectorList):
# if selecting a specific xpat... | [
"def",
"selector_to_text",
"(",
"sel",
",",
"guess_punct_space",
"=",
"True",
",",
"guess_layout",
"=",
"True",
")",
":",
"import",
"parsel",
"if",
"isinstance",
"(",
"sel",
",",
"parsel",
".",
"SelectorList",
")",
":",
"# if selecting a specific xpath",
"text",... | Convert a cleaned parsel.Selector to text.
See html_text.extract_text docstring for description of the approach
and options. | [
"Convert",
"a",
"cleaned",
"parsel",
".",
"Selector",
"to",
"text",
".",
"See",
"html_text",
".",
"extract_text",
"docstring",
"for",
"description",
"of",
"the",
"approach",
"and",
"options",
"."
] | 871d4dbe9f4f99e5f041110c60458adcaae6fab4 | https://github.com/TeamHG-Memex/html-text/blob/871d4dbe9f4f99e5f041110c60458adcaae6fab4/html_text/html_text.py#L140-L161 | train |
TeamHG-Memex/html-text | html_text/html_text.py | cleaned_selector | def cleaned_selector(html):
""" Clean parsel.selector.
"""
import parsel
try:
tree = _cleaned_html_tree(html)
sel = parsel.Selector(root=tree, type='html')
except (lxml.etree.XMLSyntaxError,
lxml.etree.ParseError,
lxml.etree.ParserError,
UnicodeEnc... | python | def cleaned_selector(html):
""" Clean parsel.selector.
"""
import parsel
try:
tree = _cleaned_html_tree(html)
sel = parsel.Selector(root=tree, type='html')
except (lxml.etree.XMLSyntaxError,
lxml.etree.ParseError,
lxml.etree.ParserError,
UnicodeEnc... | [
"def",
"cleaned_selector",
"(",
"html",
")",
":",
"import",
"parsel",
"try",
":",
"tree",
"=",
"_cleaned_html_tree",
"(",
"html",
")",
"sel",
"=",
"parsel",
".",
"Selector",
"(",
"root",
"=",
"tree",
",",
"type",
"=",
"'html'",
")",
"except",
"(",
"lxm... | Clean parsel.selector. | [
"Clean",
"parsel",
".",
"selector",
"."
] | 871d4dbe9f4f99e5f041110c60458adcaae6fab4 | https://github.com/TeamHG-Memex/html-text/blob/871d4dbe9f4f99e5f041110c60458adcaae6fab4/html_text/html_text.py#L164-L177 | train |
TeamHG-Memex/html-text | html_text/html_text.py | extract_text | def extract_text(html,
guess_punct_space=True,
guess_layout=True,
newline_tags=NEWLINE_TAGS,
double_newline_tags=DOUBLE_NEWLINE_TAGS):
"""
Convert html to text, cleaning invisible content such as styles.
Almost the same as normalize-space ... | python | def extract_text(html,
guess_punct_space=True,
guess_layout=True,
newline_tags=NEWLINE_TAGS,
double_newline_tags=DOUBLE_NEWLINE_TAGS):
"""
Convert html to text, cleaning invisible content such as styles.
Almost the same as normalize-space ... | [
"def",
"extract_text",
"(",
"html",
",",
"guess_punct_space",
"=",
"True",
",",
"guess_layout",
"=",
"True",
",",
"newline_tags",
"=",
"NEWLINE_TAGS",
",",
"double_newline_tags",
"=",
"DOUBLE_NEWLINE_TAGS",
")",
":",
"if",
"html",
"is",
"None",
":",
"return",
... | Convert html to text, cleaning invisible content such as styles.
Almost the same as normalize-space xpath, but this also
adds spaces between inline elements (like <span>) which are
often used as block elements in html markup, and adds appropriate
newlines to make output better formatted.
html shou... | [
"Convert",
"html",
"to",
"text",
"cleaning",
"invisible",
"content",
"such",
"as",
"styles",
"."
] | 871d4dbe9f4f99e5f041110c60458adcaae6fab4 | https://github.com/TeamHG-Memex/html-text/blob/871d4dbe9f4f99e5f041110c60458adcaae6fab4/html_text/html_text.py#L180-L219 | train |
Schwanksta/python-arcgis-rest-query | arcgis/arcgis.py | ArcGIS.get_json | def get_json(self, layer, where="1 = 1", fields=[], count_only=False, srid='4326'):
"""
Gets the JSON file from ArcGIS
"""
params = {
'where': where,
'outFields': ", ".join(fields),
'returnGeometry': True,
'outSR': srid,
... | python | def get_json(self, layer, where="1 = 1", fields=[], count_only=False, srid='4326'):
"""
Gets the JSON file from ArcGIS
"""
params = {
'where': where,
'outFields': ", ".join(fields),
'returnGeometry': True,
'outSR': srid,
... | [
"def",
"get_json",
"(",
"self",
",",
"layer",
",",
"where",
"=",
"\"1 = 1\"",
",",
"fields",
"=",
"[",
"]",
",",
"count_only",
"=",
"False",
",",
"srid",
"=",
"'4326'",
")",
":",
"params",
"=",
"{",
"'where'",
":",
"where",
",",
"'outFields'",
":",
... | Gets the JSON file from ArcGIS | [
"Gets",
"the",
"JSON",
"file",
"from",
"ArcGIS"
] | 020d17f5dfb63d7be4e2e245771453f2ae9410aa | https://github.com/Schwanksta/python-arcgis-rest-query/blob/020d17f5dfb63d7be4e2e245771453f2ae9410aa/arcgis/arcgis.py#L86-L104 | train |
Schwanksta/python-arcgis-rest-query | arcgis/arcgis.py | ArcGIS.get_descriptor_for_layer | def get_descriptor_for_layer(self, layer):
"""
Returns the standard JSON descriptor for the layer. There is a lot of
usefule information in there.
"""
if not layer in self._layer_descriptor_cache:
params = {'f': 'pjson'}
if self.token:
para... | python | def get_descriptor_for_layer(self, layer):
"""
Returns the standard JSON descriptor for the layer. There is a lot of
usefule information in there.
"""
if not layer in self._layer_descriptor_cache:
params = {'f': 'pjson'}
if self.token:
para... | [
"def",
"get_descriptor_for_layer",
"(",
"self",
",",
"layer",
")",
":",
"if",
"not",
"layer",
"in",
"self",
".",
"_layer_descriptor_cache",
":",
"params",
"=",
"{",
"'f'",
":",
"'pjson'",
"}",
"if",
"self",
".",
"token",
":",
"params",
"[",
"'token'",
"]... | Returns the standard JSON descriptor for the layer. There is a lot of
usefule information in there. | [
"Returns",
"the",
"standard",
"JSON",
"descriptor",
"for",
"the",
"layer",
".",
"There",
"is",
"a",
"lot",
"of",
"usefule",
"information",
"in",
"there",
"."
] | 020d17f5dfb63d7be4e2e245771453f2ae9410aa | https://github.com/Schwanksta/python-arcgis-rest-query/blob/020d17f5dfb63d7be4e2e245771453f2ae9410aa/arcgis/arcgis.py#L106-L117 | train |
Schwanksta/python-arcgis-rest-query | arcgis/arcgis.py | ArcGIS.enumerate_layer_fields | def enumerate_layer_fields(self, layer):
"""
Pulls out all of the field names for a layer.
"""
descriptor = self.get_descriptor_for_layer(layer)
return [field['name'] for field in descriptor['fields']] | python | def enumerate_layer_fields(self, layer):
"""
Pulls out all of the field names for a layer.
"""
descriptor = self.get_descriptor_for_layer(layer)
return [field['name'] for field in descriptor['fields']] | [
"def",
"enumerate_layer_fields",
"(",
"self",
",",
"layer",
")",
":",
"descriptor",
"=",
"self",
".",
"get_descriptor_for_layer",
"(",
"layer",
")",
"return",
"[",
"field",
"[",
"'name'",
"]",
"for",
"field",
"in",
"descriptor",
"[",
"'fields'",
"]",
"]"
] | Pulls out all of the field names for a layer. | [
"Pulls",
"out",
"all",
"of",
"the",
"field",
"names",
"for",
"a",
"layer",
"."
] | 020d17f5dfb63d7be4e2e245771453f2ae9410aa | https://github.com/Schwanksta/python-arcgis-rest-query/blob/020d17f5dfb63d7be4e2e245771453f2ae9410aa/arcgis/arcgis.py#L119-L124 | train |
Schwanksta/python-arcgis-rest-query | arcgis/arcgis.py | ArcGIS.get | def get(self, layer, where="1 = 1", fields=[], count_only=False, srid='4326'):
"""
Gets a layer and returns it as honest to God GeoJSON.
WHERE 1 = 1 causes us to get everything. We use OBJECTID in the WHERE clause
to paginate, so don't use OBJECTID in your WHERE clause unless you're goi... | python | def get(self, layer, where="1 = 1", fields=[], count_only=False, srid='4326'):
"""
Gets a layer and returns it as honest to God GeoJSON.
WHERE 1 = 1 causes us to get everything. We use OBJECTID in the WHERE clause
to paginate, so don't use OBJECTID in your WHERE clause unless you're goi... | [
"def",
"get",
"(",
"self",
",",
"layer",
",",
"where",
"=",
"\"1 = 1\"",
",",
"fields",
"=",
"[",
"]",
",",
"count_only",
"=",
"False",
",",
"srid",
"=",
"'4326'",
")",
":",
"base_where",
"=",
"where",
"# By default we grab all of the fields. Technically I thi... | Gets a layer and returns it as honest to God GeoJSON.
WHERE 1 = 1 causes us to get everything. We use OBJECTID in the WHERE clause
to paginate, so don't use OBJECTID in your WHERE clause unless you're going to
query under 1000 objects. | [
"Gets",
"a",
"layer",
"and",
"returns",
"it",
"as",
"honest",
"to",
"God",
"GeoJSON",
"."
] | 020d17f5dfb63d7be4e2e245771453f2ae9410aa | https://github.com/Schwanksta/python-arcgis-rest-query/blob/020d17f5dfb63d7be4e2e245771453f2ae9410aa/arcgis/arcgis.py#L126-L173 | train |
Schwanksta/python-arcgis-rest-query | arcgis/arcgis.py | ArcGIS.getTable | def getTable(self, layer, where="1 = 1", fields=[], jsobj=None):
"""
Returns JSON for a Table type. You shouldn't use this directly -- it's
an automatic falback from .get if there is no geometry
"""
base_where = where
features = []
# We always want to run once, an... | python | def getTable(self, layer, where="1 = 1", fields=[], jsobj=None):
"""
Returns JSON for a Table type. You shouldn't use this directly -- it's
an automatic falback from .get if there is no geometry
"""
base_where = where
features = []
# We always want to run once, an... | [
"def",
"getTable",
"(",
"self",
",",
"layer",
",",
"where",
"=",
"\"1 = 1\"",
",",
"fields",
"=",
"[",
"]",
",",
"jsobj",
"=",
"None",
")",
":",
"base_where",
"=",
"where",
"features",
"=",
"[",
"]",
"# We always want to run once, and then break out as soon as... | Returns JSON for a Table type. You shouldn't use this directly -- it's
an automatic falback from .get if there is no geometry | [
"Returns",
"JSON",
"for",
"a",
"Table",
"type",
".",
"You",
"shouldn",
"t",
"use",
"this",
"directly",
"--",
"it",
"s",
"an",
"automatic",
"falback",
"from",
".",
"get",
"if",
"there",
"is",
"no",
"geometry"
] | 020d17f5dfb63d7be4e2e245771453f2ae9410aa | https://github.com/Schwanksta/python-arcgis-rest-query/blob/020d17f5dfb63d7be4e2e245771453f2ae9410aa/arcgis/arcgis.py#L175-L196 | train |
Schwanksta/python-arcgis-rest-query | arcgis/arcgis.py | ArcGIS.getMultiple | def getMultiple(self, layers, where="1 = 1", fields=[], srid='4326', layer_name_field=None):
"""
Get a bunch of layers and concatenate them together into one. This is useful if you
have a map with layers for, say, every year named stuff_2014, stuff_2013, stuff_2012. Etc.
Optionally, you... | python | def getMultiple(self, layers, where="1 = 1", fields=[], srid='4326', layer_name_field=None):
"""
Get a bunch of layers and concatenate them together into one. This is useful if you
have a map with layers for, say, every year named stuff_2014, stuff_2013, stuff_2012. Etc.
Optionally, you... | [
"def",
"getMultiple",
"(",
"self",
",",
"layers",
",",
"where",
"=",
"\"1 = 1\"",
",",
"fields",
"=",
"[",
"]",
",",
"srid",
"=",
"'4326'",
",",
"layer_name_field",
"=",
"None",
")",
":",
"features",
"=",
"[",
"]",
"for",
"layer",
"in",
"layers",
":"... | Get a bunch of layers and concatenate them together into one. This is useful if you
have a map with layers for, say, every year named stuff_2014, stuff_2013, stuff_2012. Etc.
Optionally, you can stuff the source layer name into a field of your choosing.
>>> arc.getMultiple([0, 3, 5], layer_nam... | [
"Get",
"a",
"bunch",
"of",
"layers",
"and",
"concatenate",
"them",
"together",
"into",
"one",
".",
"This",
"is",
"useful",
"if",
"you",
"have",
"a",
"map",
"with",
"layers",
"for",
"say",
"every",
"year",
"named",
"stuff_2014",
"stuff_2013",
"stuff_2012",
... | 020d17f5dfb63d7be4e2e245771453f2ae9410aa | https://github.com/Schwanksta/python-arcgis-rest-query/blob/020d17f5dfb63d7be4e2e245771453f2ae9410aa/arcgis/arcgis.py#L198-L221 | train |
common-workflow-language/workflow-service | wes_client/util.py | get_version | def get_version(extension, workflow_file):
'''Determines the version of a .py, .wdl, or .cwl file.'''
if extension == 'py' and two_seven_compatible(workflow_file):
return '2.7'
elif extension == 'cwl':
return yaml.load(open(workflow_file))['cwlVersion']
else: # Must be a wdl file.
... | python | def get_version(extension, workflow_file):
'''Determines the version of a .py, .wdl, or .cwl file.'''
if extension == 'py' and two_seven_compatible(workflow_file):
return '2.7'
elif extension == 'cwl':
return yaml.load(open(workflow_file))['cwlVersion']
else: # Must be a wdl file.
... | [
"def",
"get_version",
"(",
"extension",
",",
"workflow_file",
")",
":",
"if",
"extension",
"==",
"'py'",
"and",
"two_seven_compatible",
"(",
"workflow_file",
")",
":",
"return",
"'2.7'",
"elif",
"extension",
"==",
"'cwl'",
":",
"return",
"yaml",
".",
"load",
... | Determines the version of a .py, .wdl, or .cwl file. | [
"Determines",
"the",
"version",
"of",
"a",
".",
"py",
".",
"wdl",
"or",
".",
"cwl",
"file",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_client/util.py#L27-L38 | train |
common-workflow-language/workflow-service | wes_client/util.py | wf_info | def wf_info(workflow_path):
"""
Returns the version of the file and the file extension.
Assumes that the file path is to the file directly ie, ends with a valid file extension.Supports checking local
files as well as files at http:// and https:// locations. Files at these remote locations are recreated... | python | def wf_info(workflow_path):
"""
Returns the version of the file and the file extension.
Assumes that the file path is to the file directly ie, ends with a valid file extension.Supports checking local
files as well as files at http:// and https:// locations. Files at these remote locations are recreated... | [
"def",
"wf_info",
"(",
"workflow_path",
")",
":",
"supported_formats",
"=",
"[",
"'py'",
",",
"'wdl'",
",",
"'cwl'",
"]",
"file_type",
"=",
"workflow_path",
".",
"lower",
"(",
")",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
"# Grab the file exten... | Returns the version of the file and the file extension.
Assumes that the file path is to the file directly ie, ends with a valid file extension.Supports checking local
files as well as files at http:// and https:// locations. Files at these remote locations are recreated locally to
enable our approach to v... | [
"Returns",
"the",
"version",
"of",
"the",
"file",
"and",
"the",
"file",
"extension",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_client/util.py#L41-L69 | train |
common-workflow-language/workflow-service | wes_client/util.py | modify_jsonyaml_paths | def modify_jsonyaml_paths(jsonyaml_file):
"""
Changes relative paths in a json/yaml file to be relative
to where the json/yaml file is located.
:param jsonyaml_file: Path to a json/yaml file.
"""
loader = schema_salad.ref_resolver.Loader({
"location": {"@type": "@id"},
"path": {... | python | def modify_jsonyaml_paths(jsonyaml_file):
"""
Changes relative paths in a json/yaml file to be relative
to where the json/yaml file is located.
:param jsonyaml_file: Path to a json/yaml file.
"""
loader = schema_salad.ref_resolver.Loader({
"location": {"@type": "@id"},
"path": {... | [
"def",
"modify_jsonyaml_paths",
"(",
"jsonyaml_file",
")",
":",
"loader",
"=",
"schema_salad",
".",
"ref_resolver",
".",
"Loader",
"(",
"{",
"\"location\"",
":",
"{",
"\"@type\"",
":",
"\"@id\"",
"}",
",",
"\"path\"",
":",
"{",
"\"@type\"",
":",
"\"@id\"",
"... | Changes relative paths in a json/yaml file to be relative
to where the json/yaml file is located.
:param jsonyaml_file: Path to a json/yaml file. | [
"Changes",
"relative",
"paths",
"in",
"a",
"json",
"/",
"yaml",
"file",
"to",
"be",
"relative",
"to",
"where",
"the",
"json",
"/",
"yaml",
"file",
"is",
"located",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_client/util.py#L72-L98 | train |
common-workflow-language/workflow-service | wes_client/util.py | build_wes_request | def build_wes_request(workflow_file, json_path, attachments=None):
"""
:param str workflow_file: Path to cwl/wdl file. Can be http/https/file.
:param json_path: Path to accompanying json file.
:param attachments: Any other files needing to be uploaded to the server.
:return: A list of tuples forma... | python | def build_wes_request(workflow_file, json_path, attachments=None):
"""
:param str workflow_file: Path to cwl/wdl file. Can be http/https/file.
:param json_path: Path to accompanying json file.
:param attachments: Any other files needing to be uploaded to the server.
:return: A list of tuples forma... | [
"def",
"build_wes_request",
"(",
"workflow_file",
",",
"json_path",
",",
"attachments",
"=",
"None",
")",
":",
"workflow_file",
"=",
"\"file://\"",
"+",
"workflow_file",
"if",
"\":\"",
"not",
"in",
"workflow_file",
"else",
"workflow_file",
"wfbase",
"=",
"None",
... | :param str workflow_file: Path to cwl/wdl file. Can be http/https/file.
:param json_path: Path to accompanying json file.
:param attachments: Any other files needing to be uploaded to the server.
:return: A list of tuples formatted to be sent in a post to the wes-server (Swagger API). | [
":",
"param",
"str",
"workflow_file",
":",
"Path",
"to",
"cwl",
"/",
"wdl",
"file",
".",
"Can",
"be",
"http",
"/",
"https",
"/",
"file",
".",
":",
"param",
"json_path",
":",
"Path",
"to",
"accompanying",
"json",
"file",
".",
":",
"param",
"attachments"... | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_client/util.py#L101-L148 | train |
common-workflow-language/workflow-service | wes_client/util.py | WESClient.get_service_info | def get_service_info(self):
"""
Get information about Workflow Execution Service. May
include information related (but not limited to) the
workflow descriptor formats, versions supported, the
WES API versions supported, and information about general
the service availabili... | python | def get_service_info(self):
"""
Get information about Workflow Execution Service. May
include information related (but not limited to) the
workflow descriptor formats, versions supported, the
WES API versions supported, and information about general
the service availabili... | [
"def",
"get_service_info",
"(",
"self",
")",
":",
"postresult",
"=",
"requests",
".",
"get",
"(",
"\"%s://%s/ga4gh/wes/v1/service-info\"",
"%",
"(",
"self",
".",
"proto",
",",
"self",
".",
"host",
")",
",",
"headers",
"=",
"self",
".",
"auth",
")",
"return... | Get information about Workflow Execution Service. May
include information related (but not limited to) the
workflow descriptor formats, versions supported, the
WES API versions supported, and information about general
the service availability.
:param str auth: String to send in ... | [
"Get",
"information",
"about",
"Workflow",
"Execution",
"Service",
".",
"May",
"include",
"information",
"related",
"(",
"but",
"not",
"limited",
"to",
")",
"the",
"workflow",
"descriptor",
"formats",
"versions",
"supported",
"the",
"WES",
"API",
"versions",
"su... | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_client/util.py#L180-L195 | train |
common-workflow-language/workflow-service | wes_client/util.py | WESClient.run | def run(self, wf, jsonyaml, attachments):
"""
Composes and sends a post request that signals the wes server to run a workflow.
:param str workflow_file: A local/http/https path to a cwl/wdl/python workflow file.
:param str jsonyaml: A local path to a json or yaml file.
:param li... | python | def run(self, wf, jsonyaml, attachments):
"""
Composes and sends a post request that signals the wes server to run a workflow.
:param str workflow_file: A local/http/https path to a cwl/wdl/python workflow file.
:param str jsonyaml: A local path to a json or yaml file.
:param li... | [
"def",
"run",
"(",
"self",
",",
"wf",
",",
"jsonyaml",
",",
"attachments",
")",
":",
"attachments",
"=",
"list",
"(",
"expand_globs",
"(",
"attachments",
")",
")",
"parts",
"=",
"build_wes_request",
"(",
"wf",
",",
"jsonyaml",
",",
"attachments",
")",
"p... | Composes and sends a post request that signals the wes server to run a workflow.
:param str workflow_file: A local/http/https path to a cwl/wdl/python workflow file.
:param str jsonyaml: A local path to a json or yaml file.
:param list attachments: A list of local paths to files that will be up... | [
"Composes",
"and",
"sends",
"a",
"post",
"request",
"that",
"signals",
"the",
"wes",
"server",
"to",
"run",
"a",
"workflow",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_client/util.py#L213-L231 | train |
common-workflow-language/workflow-service | wes_client/util.py | WESClient.cancel | def cancel(self, run_id):
"""
Cancel a running workflow.
:param run_id: String (typically a uuid) identifying the run.
:param str auth: String to send in the auth header.
:param proto: Schema where the server resides (http, https)
:param host: Port where the post request... | python | def cancel(self, run_id):
"""
Cancel a running workflow.
:param run_id: String (typically a uuid) identifying the run.
:param str auth: String to send in the auth header.
:param proto: Schema where the server resides (http, https)
:param host: Port where the post request... | [
"def",
"cancel",
"(",
"self",
",",
"run_id",
")",
":",
"postresult",
"=",
"requests",
".",
"post",
"(",
"\"%s://%s/ga4gh/wes/v1/runs/%s/cancel\"",
"%",
"(",
"self",
".",
"proto",
",",
"self",
".",
"host",
",",
"run_id",
")",
",",
"headers",
"=",
"self",
... | Cancel a running workflow.
:param run_id: String (typically a uuid) identifying the run.
:param str auth: String to send in the auth header.
:param proto: Schema where the server resides (http, https)
:param host: Port where the post request will be sent and the wes server listens at (d... | [
"Cancel",
"a",
"running",
"workflow",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_client/util.py#L233-L245 | train |
common-workflow-language/workflow-service | wes_client/util.py | WESClient.get_run_log | def get_run_log(self, run_id):
"""
Get detailed info about a running workflow.
:param run_id: String (typically a uuid) identifying the run.
:param str auth: String to send in the auth header.
:param proto: Schema where the server resides (http, https)
:param host: Port ... | python | def get_run_log(self, run_id):
"""
Get detailed info about a running workflow.
:param run_id: String (typically a uuid) identifying the run.
:param str auth: String to send in the auth header.
:param proto: Schema where the server resides (http, https)
:param host: Port ... | [
"def",
"get_run_log",
"(",
"self",
",",
"run_id",
")",
":",
"postresult",
"=",
"requests",
".",
"get",
"(",
"\"%s://%s/ga4gh/wes/v1/runs/%s\"",
"%",
"(",
"self",
".",
"proto",
",",
"self",
".",
"host",
",",
"run_id",
")",
",",
"headers",
"=",
"self",
"."... | Get detailed info about a running workflow.
:param run_id: String (typically a uuid) identifying the run.
:param str auth: String to send in the auth header.
:param proto: Schema where the server resides (http, https)
:param host: Port where the post request will be sent and the wes ser... | [
"Get",
"detailed",
"info",
"about",
"a",
"running",
"workflow",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_client/util.py#L247-L259 | train |
common-workflow-language/workflow-service | wes_service/cwl_runner.py | Workflow.run | def run(self, request, tempdir, opts):
"""
Constructs a command to run a cwl/json from requests and opts,
runs it, and deposits the outputs in outdir.
Runner:
opts.getopt("runner", default="cwl-runner")
CWL (url):
request["workflow_url"] == a url to a cwl file
... | python | def run(self, request, tempdir, opts):
"""
Constructs a command to run a cwl/json from requests and opts,
runs it, and deposits the outputs in outdir.
Runner:
opts.getopt("runner", default="cwl-runner")
CWL (url):
request["workflow_url"] == a url to a cwl file
... | [
"def",
"run",
"(",
"self",
",",
"request",
",",
"tempdir",
",",
"opts",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"workdir",
",",
"\"request.json\"",
")",
",",
"\"w\"",
")",
"as",
"f",
":",
"json",
".",
"dum... | Constructs a command to run a cwl/json from requests and opts,
runs it, and deposits the outputs in outdir.
Runner:
opts.getopt("runner", default="cwl-runner")
CWL (url):
request["workflow_url"] == a url to a cwl file
or
request["workflow_attachment"] == input c... | [
"Constructs",
"a",
"command",
"to",
"run",
"a",
"cwl",
"/",
"json",
"from",
"requests",
"and",
"opts",
"runs",
"it",
"and",
"deposits",
"the",
"outputs",
"in",
"outdir",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/cwl_runner.py#L19-L79 | train |
common-workflow-language/workflow-service | wes_service/cwl_runner.py | Workflow.getstate | def getstate(self):
"""
Returns RUNNING, -1
COMPLETE, 0
or
EXECUTOR_ERROR, 255
"""
state = "RUNNING"
exit_code = -1
exitcode_file = os.path.join(self.workdir, "exit_code")
pid_file = os.path.join(self.workdir, "pid"... | python | def getstate(self):
"""
Returns RUNNING, -1
COMPLETE, 0
or
EXECUTOR_ERROR, 255
"""
state = "RUNNING"
exit_code = -1
exitcode_file = os.path.join(self.workdir, "exit_code")
pid_file = os.path.join(self.workdir, "pid"... | [
"def",
"getstate",
"(",
"self",
")",
":",
"state",
"=",
"\"RUNNING\"",
"exit_code",
"=",
"-",
"1",
"exitcode_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"workdir",
",",
"\"exit_code\"",
")",
"pid_file",
"=",
"os",
".",
"path",
".",
... | Returns RUNNING, -1
COMPLETE, 0
or
EXECUTOR_ERROR, 255 | [
"Returns",
"RUNNING",
"-",
"1",
"COMPLETE",
"0",
"or",
"EXECUTOR_ERROR",
"255"
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/cwl_runner.py#L81-L116 | train |
common-workflow-language/workflow-service | wes_service/toil_wes.py | ToilWorkflow.write_workflow | def write_workflow(self, request, opts, cwd, wftype='cwl'):
"""Writes a cwl, wdl, or python file as appropriate from the request dictionary."""
workflow_url = request.get("workflow_url")
# link the cwl and json into the cwd
if workflow_url.startswith('file://'):
os.link(wor... | python | def write_workflow(self, request, opts, cwd, wftype='cwl'):
"""Writes a cwl, wdl, or python file as appropriate from the request dictionary."""
workflow_url = request.get("workflow_url")
# link the cwl and json into the cwd
if workflow_url.startswith('file://'):
os.link(wor... | [
"def",
"write_workflow",
"(",
"self",
",",
"request",
",",
"opts",
",",
"cwd",
",",
"wftype",
"=",
"'cwl'",
")",
":",
"workflow_url",
"=",
"request",
".",
"get",
"(",
"\"workflow_url\"",
")",
"# link the cwl and json into the cwd",
"if",
"workflow_url",
".",
"... | Writes a cwl, wdl, or python file as appropriate from the request dictionary. | [
"Writes",
"a",
"cwl",
"wdl",
"or",
"python",
"file",
"as",
"appropriate",
"from",
"the",
"request",
"dictionary",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/toil_wes.py#L68-L90 | train |
common-workflow-language/workflow-service | wes_service/toil_wes.py | ToilWorkflow.call_cmd | def call_cmd(self, cmd, cwd):
"""
Calls a command with Popen.
Writes stdout, stderr, and the command to separate files.
:param cmd: A string or array of strings.
:param tempdir:
:return: The pid of the command.
"""
with open(self.cmdfile, 'w') as f:
... | python | def call_cmd(self, cmd, cwd):
"""
Calls a command with Popen.
Writes stdout, stderr, and the command to separate files.
:param cmd: A string or array of strings.
:param tempdir:
:return: The pid of the command.
"""
with open(self.cmdfile, 'w') as f:
... | [
"def",
"call_cmd",
"(",
"self",
",",
"cmd",
",",
"cwd",
")",
":",
"with",
"open",
"(",
"self",
".",
"cmdfile",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"str",
"(",
"cmd",
")",
")",
"stdout",
"=",
"open",
"(",
"self",
".",
"out... | Calls a command with Popen.
Writes stdout, stderr, and the command to separate files.
:param cmd: A string or array of strings.
:param tempdir:
:return: The pid of the command. | [
"Calls",
"a",
"command",
"with",
"Popen",
".",
"Writes",
"stdout",
"stderr",
"and",
"the",
"command",
"to",
"separate",
"files",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/toil_wes.py#L98-L120 | train |
common-workflow-language/workflow-service | wes_service/toil_wes.py | ToilWorkflow.run | def run(self, request, tempdir, opts):
"""
Constructs a command to run a cwl/json from requests and opts,
runs it, and deposits the outputs in outdir.
Runner:
opts.getopt("runner", default="cwl-runner")
CWL (url):
request["workflow_url"] == a url to a cwl file
... | python | def run(self, request, tempdir, opts):
"""
Constructs a command to run a cwl/json from requests and opts,
runs it, and deposits the outputs in outdir.
Runner:
opts.getopt("runner", default="cwl-runner")
CWL (url):
request["workflow_url"] == a url to a cwl file
... | [
"def",
"run",
"(",
"self",
",",
"request",
",",
"tempdir",
",",
"opts",
")",
":",
"wftype",
"=",
"request",
"[",
"'workflow_type'",
"]",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
"version",
"=",
"request",
"[",
"'workflow_type_version'",
"]",
"if... | Constructs a command to run a cwl/json from requests and opts,
runs it, and deposits the outputs in outdir.
Runner:
opts.getopt("runner", default="cwl-runner")
CWL (url):
request["workflow_url"] == a url to a cwl file
or
request["workflow_attachment"] == input c... | [
"Constructs",
"a",
"command",
"to",
"run",
"a",
"cwl",
"/",
"json",
"from",
"requests",
"and",
"opts",
"runs",
"it",
"and",
"deposits",
"the",
"outputs",
"in",
"outdir",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/toil_wes.py#L173-L222 | train |
common-workflow-language/workflow-service | wes_service/toil_wes.py | ToilWorkflow.getstate | def getstate(self):
"""
Returns QUEUED, -1
INITIALIZING, -1
RUNNING, -1
COMPLETE, 0
or
EXECUTOR_ERROR, 255
"""
# the jobstore never existed
if not os.path.exists(self.jobst... | python | def getstate(self):
"""
Returns QUEUED, -1
INITIALIZING, -1
RUNNING, -1
COMPLETE, 0
or
EXECUTOR_ERROR, 255
"""
# the jobstore never existed
if not os.path.exists(self.jobst... | [
"def",
"getstate",
"(",
"self",
")",
":",
"# the jobstore never existed",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"jobstorefile",
")",
":",
"logging",
".",
"info",
"(",
"'Workflow '",
"+",
"self",
".",
"run_id",
"+",
"': QUEUED'",
... | Returns QUEUED, -1
INITIALIZING, -1
RUNNING, -1
COMPLETE, 0
or
EXECUTOR_ERROR, 255 | [
"Returns",
"QUEUED",
"-",
"1",
"INITIALIZING",
"-",
"1",
"RUNNING",
"-",
"1",
"COMPLETE",
"0",
"or",
"EXECUTOR_ERROR",
"255"
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/toil_wes.py#L224-L271 | train |
common-workflow-language/workflow-service | wes_service/util.py | visit | def visit(d, op):
"""Recursively call op(d) for all list subelements and dictionary 'values' that d may have."""
op(d)
if isinstance(d, list):
for i in d:
visit(i, op)
elif isinstance(d, dict):
for i in itervalues(d):
visit(i, op) | python | def visit(d, op):
"""Recursively call op(d) for all list subelements and dictionary 'values' that d may have."""
op(d)
if isinstance(d, list):
for i in d:
visit(i, op)
elif isinstance(d, dict):
for i in itervalues(d):
visit(i, op) | [
"def",
"visit",
"(",
"d",
",",
"op",
")",
":",
"op",
"(",
"d",
")",
"if",
"isinstance",
"(",
"d",
",",
"list",
")",
":",
"for",
"i",
"in",
"d",
":",
"visit",
"(",
"i",
",",
"op",
")",
"elif",
"isinstance",
"(",
"d",
",",
"dict",
")",
":",
... | Recursively call op(d) for all list subelements and dictionary 'values' that d may have. | [
"Recursively",
"call",
"op",
"(",
"d",
")",
"for",
"all",
"list",
"subelements",
"and",
"dictionary",
"values",
"that",
"d",
"may",
"have",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/util.py#L11-L19 | train |
common-workflow-language/workflow-service | wes_service/util.py | WESBackend.getopt | def getopt(self, p, default=None):
"""Returns the first option value stored that matches p or default."""
for k, v in self.pairs:
if k == p:
return v
return default | python | def getopt(self, p, default=None):
"""Returns the first option value stored that matches p or default."""
for k, v in self.pairs:
if k == p:
return v
return default | [
"def",
"getopt",
"(",
"self",
",",
"p",
",",
"default",
"=",
"None",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"pairs",
":",
"if",
"k",
"==",
"p",
":",
"return",
"v",
"return",
"default"
] | Returns the first option value stored that matches p or default. | [
"Returns",
"the",
"first",
"option",
"value",
"stored",
"that",
"matches",
"p",
"or",
"default",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/util.py#L31-L36 | train |
common-workflow-language/workflow-service | wes_service/util.py | WESBackend.getoptlist | def getoptlist(self, p):
"""Returns all option values stored that match p as a list."""
optlist = []
for k, v in self.pairs:
if k == p:
optlist.append(v)
return optlist | python | def getoptlist(self, p):
"""Returns all option values stored that match p as a list."""
optlist = []
for k, v in self.pairs:
if k == p:
optlist.append(v)
return optlist | [
"def",
"getoptlist",
"(",
"self",
",",
"p",
")",
":",
"optlist",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"self",
".",
"pairs",
":",
"if",
"k",
"==",
"p",
":",
"optlist",
".",
"append",
"(",
"v",
")",
"return",
"optlist"
] | Returns all option values stored that match p as a list. | [
"Returns",
"all",
"option",
"values",
"stored",
"that",
"match",
"p",
"as",
"a",
"list",
"."
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/util.py#L38-L44 | train |
common-workflow-language/workflow-service | wes_service/arvados_wes.py | catch_exceptions | def catch_exceptions(orig_func):
"""Catch uncaught exceptions and turn them into http errors"""
@functools.wraps(orig_func)
def catch_exceptions_wrapper(self, *args, **kwargs):
try:
return orig_func(self, *args, **kwargs)
except arvados.errors.ApiError as e:
logging.... | python | def catch_exceptions(orig_func):
"""Catch uncaught exceptions and turn them into http errors"""
@functools.wraps(orig_func)
def catch_exceptions_wrapper(self, *args, **kwargs):
try:
return orig_func(self, *args, **kwargs)
except arvados.errors.ApiError as e:
logging.... | [
"def",
"catch_exceptions",
"(",
"orig_func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"orig_func",
")",
"def",
"catch_exceptions_wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"orig_func",
"(",
"se... | Catch uncaught exceptions and turn them into http errors | [
"Catch",
"uncaught",
"exceptions",
"and",
"turn",
"them",
"into",
"http",
"errors"
] | e879604b65c55546e4f87be1c9df9903a3e0b896 | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/arvados_wes.py#L46-L65 | train |
pudo/normality | normality/paths.py | _safe_name | def _safe_name(file_name, sep):
"""Convert the file name to ASCII and normalize the string."""
file_name = stringify(file_name)
if file_name is None:
return
file_name = ascii_text(file_name)
file_name = category_replace(file_name, UNICODE_CATEGORIES)
file_name = collapse_spaces(file_name... | python | def _safe_name(file_name, sep):
"""Convert the file name to ASCII and normalize the string."""
file_name = stringify(file_name)
if file_name is None:
return
file_name = ascii_text(file_name)
file_name = category_replace(file_name, UNICODE_CATEGORIES)
file_name = collapse_spaces(file_name... | [
"def",
"_safe_name",
"(",
"file_name",
",",
"sep",
")",
":",
"file_name",
"=",
"stringify",
"(",
"file_name",
")",
"if",
"file_name",
"is",
"None",
":",
"return",
"file_name",
"=",
"ascii_text",
"(",
"file_name",
")",
"file_name",
"=",
"category_replace",
"(... | Convert the file name to ASCII and normalize the string. | [
"Convert",
"the",
"file",
"name",
"to",
"ASCII",
"and",
"normalize",
"the",
"string",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/paths.py#L11-L21 | train |
pudo/normality | normality/paths.py | safe_filename | def safe_filename(file_name, sep='_', default=None, extension=None):
"""Create a secure filename for plain file system storage."""
if file_name is None:
return decode_path(default)
file_name = decode_path(file_name)
file_name = os.path.basename(file_name)
file_name, _extension = os.path.spl... | python | def safe_filename(file_name, sep='_', default=None, extension=None):
"""Create a secure filename for plain file system storage."""
if file_name is None:
return decode_path(default)
file_name = decode_path(file_name)
file_name = os.path.basename(file_name)
file_name, _extension = os.path.spl... | [
"def",
"safe_filename",
"(",
"file_name",
",",
"sep",
"=",
"'_'",
",",
"default",
"=",
"None",
",",
"extension",
"=",
"None",
")",
":",
"if",
"file_name",
"is",
"None",
":",
"return",
"decode_path",
"(",
"default",
")",
"file_name",
"=",
"decode_path",
"... | Create a secure filename for plain file system storage. | [
"Create",
"a",
"secure",
"filename",
"for",
"plain",
"file",
"system",
"storage",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/paths.py#L24-L40 | train |
pudo/normality | normality/stringify.py | stringify | def stringify(value, encoding_default='utf-8', encoding=None):
"""Brute-force convert a given object to a string.
This will attempt an increasingly mean set of conversions to make a given
object into a unicode string. It is guaranteed to either return unicode or
None, if all conversions failed (or the ... | python | def stringify(value, encoding_default='utf-8', encoding=None):
"""Brute-force convert a given object to a string.
This will attempt an increasingly mean set of conversions to make a given
object into a unicode string. It is guaranteed to either return unicode or
None, if all conversions failed (or the ... | [
"def",
"stringify",
"(",
"value",
",",
"encoding_default",
"=",
"'utf-8'",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"text_type",
")",
":",
"if"... | Brute-force convert a given object to a string.
This will attempt an increasingly mean set of conversions to make a given
object into a unicode string. It is guaranteed to either return unicode or
None, if all conversions failed (or the value is indeed empty). | [
"Brute",
"-",
"force",
"convert",
"a",
"given",
"object",
"to",
"a",
"string",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/stringify.py#L10-L38 | train |
pudo/normality | normality/encoding.py | normalize_encoding | def normalize_encoding(encoding, default=DEFAULT_ENCODING):
"""Normalize the encoding name, replace ASCII w/ UTF-8."""
if encoding is None:
return default
encoding = encoding.lower().strip()
if encoding in ['', 'ascii']:
return default
try:
codecs.lookup(encoding)
ret... | python | def normalize_encoding(encoding, default=DEFAULT_ENCODING):
"""Normalize the encoding name, replace ASCII w/ UTF-8."""
if encoding is None:
return default
encoding = encoding.lower().strip()
if encoding in ['', 'ascii']:
return default
try:
codecs.lookup(encoding)
ret... | [
"def",
"normalize_encoding",
"(",
"encoding",
",",
"default",
"=",
"DEFAULT_ENCODING",
")",
":",
"if",
"encoding",
"is",
"None",
":",
"return",
"default",
"encoding",
"=",
"encoding",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
"if",
"encoding",
"in",
... | Normalize the encoding name, replace ASCII w/ UTF-8. | [
"Normalize",
"the",
"encoding",
"name",
"replace",
"ASCII",
"w",
"/",
"UTF",
"-",
"8",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L8-L19 | train |
pudo/normality | normality/encoding.py | normalize_result | def normalize_result(result, default, threshold=0.2):
"""Interpret a chardet result."""
if result is None:
return default
if result.get('confidence') is None:
return default
if result.get('confidence') < threshold:
return default
return normalize_encoding(result.get('encoding... | python | def normalize_result(result, default, threshold=0.2):
"""Interpret a chardet result."""
if result is None:
return default
if result.get('confidence') is None:
return default
if result.get('confidence') < threshold:
return default
return normalize_encoding(result.get('encoding... | [
"def",
"normalize_result",
"(",
"result",
",",
"default",
",",
"threshold",
"=",
"0.2",
")",
":",
"if",
"result",
"is",
"None",
":",
"return",
"default",
"if",
"result",
".",
"get",
"(",
"'confidence'",
")",
"is",
"None",
":",
"return",
"default",
"if",
... | Interpret a chardet result. | [
"Interpret",
"a",
"chardet",
"result",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L22-L31 | train |
pudo/normality | normality/encoding.py | guess_encoding | def guess_encoding(text, default=DEFAULT_ENCODING):
"""Guess string encoding.
Given a piece of text, apply character encoding detection to
guess the appropriate encoding of the text.
"""
result = chardet.detect(text)
return normalize_result(result, default=default) | python | def guess_encoding(text, default=DEFAULT_ENCODING):
"""Guess string encoding.
Given a piece of text, apply character encoding detection to
guess the appropriate encoding of the text.
"""
result = chardet.detect(text)
return normalize_result(result, default=default) | [
"def",
"guess_encoding",
"(",
"text",
",",
"default",
"=",
"DEFAULT_ENCODING",
")",
":",
"result",
"=",
"chardet",
".",
"detect",
"(",
"text",
")",
"return",
"normalize_result",
"(",
"result",
",",
"default",
"=",
"default",
")"
] | Guess string encoding.
Given a piece of text, apply character encoding detection to
guess the appropriate encoding of the text. | [
"Guess",
"string",
"encoding",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L34-L41 | train |
pudo/normality | normality/encoding.py | guess_file_encoding | def guess_file_encoding(fh, default=DEFAULT_ENCODING):
"""Guess encoding from a file handle."""
start = fh.tell()
detector = chardet.UniversalDetector()
while True:
data = fh.read(1024 * 10)
if not data:
detector.close()
break
detector.feed(data)
i... | python | def guess_file_encoding(fh, default=DEFAULT_ENCODING):
"""Guess encoding from a file handle."""
start = fh.tell()
detector = chardet.UniversalDetector()
while True:
data = fh.read(1024 * 10)
if not data:
detector.close()
break
detector.feed(data)
i... | [
"def",
"guess_file_encoding",
"(",
"fh",
",",
"default",
"=",
"DEFAULT_ENCODING",
")",
":",
"start",
"=",
"fh",
".",
"tell",
"(",
")",
"detector",
"=",
"chardet",
".",
"UniversalDetector",
"(",
")",
"while",
"True",
":",
"data",
"=",
"fh",
".",
"read",
... | Guess encoding from a file handle. | [
"Guess",
"encoding",
"from",
"a",
"file",
"handle",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L44-L58 | train |
pudo/normality | normality/encoding.py | guess_path_encoding | def guess_path_encoding(file_path, default=DEFAULT_ENCODING):
"""Wrapper to open that damn file for you, lazy bastard."""
with io.open(file_path, 'rb') as fh:
return guess_file_encoding(fh, default=default) | python | def guess_path_encoding(file_path, default=DEFAULT_ENCODING):
"""Wrapper to open that damn file for you, lazy bastard."""
with io.open(file_path, 'rb') as fh:
return guess_file_encoding(fh, default=default) | [
"def",
"guess_path_encoding",
"(",
"file_path",
",",
"default",
"=",
"DEFAULT_ENCODING",
")",
":",
"with",
"io",
".",
"open",
"(",
"file_path",
",",
"'rb'",
")",
"as",
"fh",
":",
"return",
"guess_file_encoding",
"(",
"fh",
",",
"default",
"=",
"default",
"... | Wrapper to open that damn file for you, lazy bastard. | [
"Wrapper",
"to",
"open",
"that",
"damn",
"file",
"for",
"you",
"lazy",
"bastard",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/encoding.py#L61-L64 | train |
pudo/normality | normality/cleaning.py | decompose_nfkd | def decompose_nfkd(text):
"""Perform unicode compatibility decomposition.
This will replace some non-standard value representations in unicode and
normalise them, while also separating characters and their diacritics into
two separate codepoints.
"""
if text is None:
return None
if ... | python | def decompose_nfkd(text):
"""Perform unicode compatibility decomposition.
This will replace some non-standard value representations in unicode and
normalise them, while also separating characters and their diacritics into
two separate codepoints.
"""
if text is None:
return None
if ... | [
"def",
"decompose_nfkd",
"(",
"text",
")",
":",
"if",
"text",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"hasattr",
"(",
"decompose_nfkd",
",",
"'_tr'",
")",
":",
"decompose_nfkd",
".",
"_tr",
"=",
"Transliterator",
".",
"createInstance",
"(",
"'Any... | Perform unicode compatibility decomposition.
This will replace some non-standard value representations in unicode and
normalise them, while also separating characters and their diacritics into
two separate codepoints. | [
"Perform",
"unicode",
"compatibility",
"decomposition",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L17-L28 | train |
pudo/normality | normality/cleaning.py | compose_nfc | def compose_nfc(text):
"""Perform unicode composition."""
if text is None:
return None
if not hasattr(compose_nfc, '_tr'):
compose_nfc._tr = Transliterator.createInstance('Any-NFC')
return compose_nfc._tr.transliterate(text) | python | def compose_nfc(text):
"""Perform unicode composition."""
if text is None:
return None
if not hasattr(compose_nfc, '_tr'):
compose_nfc._tr = Transliterator.createInstance('Any-NFC')
return compose_nfc._tr.transliterate(text) | [
"def",
"compose_nfc",
"(",
"text",
")",
":",
"if",
"text",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"hasattr",
"(",
"compose_nfc",
",",
"'_tr'",
")",
":",
"compose_nfc",
".",
"_tr",
"=",
"Transliterator",
".",
"createInstance",
"(",
"'Any-NFC'",
... | Perform unicode composition. | [
"Perform",
"unicode",
"composition",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L31-L37 | train |
pudo/normality | normality/cleaning.py | category_replace | def category_replace(text, replacements=UNICODE_CATEGORIES):
"""Remove characters from a string based on unicode classes.
This is a method for removing non-text characters (such as punctuation,
whitespace, marks and diacritics) from a piece of text by class, rather
than specifying them individually.
... | python | def category_replace(text, replacements=UNICODE_CATEGORIES):
"""Remove characters from a string based on unicode classes.
This is a method for removing non-text characters (such as punctuation,
whitespace, marks and diacritics) from a piece of text by class, rather
than specifying them individually.
... | [
"def",
"category_replace",
"(",
"text",
",",
"replacements",
"=",
"UNICODE_CATEGORIES",
")",
":",
"if",
"text",
"is",
"None",
":",
"return",
"None",
"characters",
"=",
"[",
"]",
"for",
"character",
"in",
"decompose_nfkd",
"(",
"text",
")",
":",
"cat",
"=",... | Remove characters from a string based on unicode classes.
This is a method for removing non-text characters (such as punctuation,
whitespace, marks and diacritics) from a piece of text by class, rather
than specifying them individually. | [
"Remove",
"characters",
"from",
"a",
"string",
"based",
"on",
"unicode",
"classes",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L47-L62 | train |
pudo/normality | normality/cleaning.py | remove_unsafe_chars | def remove_unsafe_chars(text):
"""Remove unsafe unicode characters from a piece of text."""
if isinstance(text, six.string_types):
text = UNSAFE_RE.sub('', text)
return text | python | def remove_unsafe_chars(text):
"""Remove unsafe unicode characters from a piece of text."""
if isinstance(text, six.string_types):
text = UNSAFE_RE.sub('', text)
return text | [
"def",
"remove_unsafe_chars",
"(",
"text",
")",
":",
"if",
"isinstance",
"(",
"text",
",",
"six",
".",
"string_types",
")",
":",
"text",
"=",
"UNSAFE_RE",
".",
"sub",
"(",
"''",
",",
"text",
")",
"return",
"text"
] | Remove unsafe unicode characters from a piece of text. | [
"Remove",
"unsafe",
"unicode",
"characters",
"from",
"a",
"piece",
"of",
"text",
"."
] | b53cc2c6e5c6205573d2010f72d90808710a4b58 | https://github.com/pudo/normality/blob/b53cc2c6e5c6205573d2010f72d90808710a4b58/normality/cleaning.py#L70-L74 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.