hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
22daa6fd3548de117072d5268930d3ffdcd0d640 | Rfam/rfam-production | scripts/processing/threshold_selector.py | [
"Apache-2.0"
] | Python | extract_scores_dict_from_outlist_file | <not_specific> | def extract_scores_dict_from_outlist_file(scores_file):
"""
Parses the outlist or species file produced by rfsearch
and returns all bit_scores above the REVERSED cutoff
scores_file: The path to rfsearch outlist or species file
return: A list of all bit scores above REVERSED
"""
scores = {... |
Parses the outlist or species file produced by rfsearch
and returns all bit_scores above the REVERSED cutoff
scores_file: The path to rfsearch outlist or species file
return: A list of all bit scores above REVERSED
| Parses the outlist or species file produced by rfsearch
and returns all bit_scores above the REVERSED cutoff
The path to rfsearch outlist or species file
A list of all bit scores above REVERSED | [
"Parses",
"the",
"outlist",
"or",
"species",
"file",
"produced",
"by",
"rfsearch",
"and",
"returns",
"all",
"bit_scores",
"above",
"the",
"REVERSED",
"cutoff",
"The",
"path",
"to",
"rfsearch",
"outlist",
"or",
"species",
"file",
"A",
"list",
"of",
"all",
"bi... | def extract_scores_dict_from_outlist_file(scores_file):
scores = {'SEED': [], 'FULL': [], 'OTHER': [], "REV": -1}
outlist_fp = open(scores_file, 'r')
for line in outlist_fp:
if line[0] != '#':
line = [x for x in line.strip().split(' ') if x!='']
scores[line[2]].append(float(l... | [
"def",
"extract_scores_dict_from_outlist_file",
"(",
"scores_file",
")",
":",
"scores",
"=",
"{",
"'SEED'",
":",
"[",
"]",
",",
"'FULL'",
":",
"[",
"]",
",",
"'OTHER'",
":",
"[",
"]",
",",
"\"REV\"",
":",
"-",
"1",
"}",
"outlist_fp",
"=",
"open",
"(",
... | Parses the outlist or species file produced by rfsearch
and returns all bit_scores above the REVERSED cutoff | [
"Parses",
"the",
"outlist",
"or",
"species",
"file",
"produced",
"by",
"rfsearch",
"and",
"returns",
"all",
"bit_scores",
"above",
"the",
"REVERSED",
"cutoff"
] | [
"\"\"\"\n Parses the outlist or species file produced by rfsearch\n and returns all bit_scores above the REVERSED cutoff\n\n scores_file: The path to rfsearch outlist or species file\n\n return: A list of all bit scores above REVERSED\n \"\"\"",
"# if we reached REVERSED line, we treat everything a... | [
{
"param": "scores_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scores_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
22daa6fd3548de117072d5268930d3ffdcd0d640 | Rfam/rfam-production | scripts/processing/threshold_selector.py | [
"Apache-2.0"
] | Python | extract_bitscores_list_from_scores_file | <not_specific> | def extract_bitscores_list_from_scores_file(scores_file):
"""
Parses the outlist or species file produced by rfsearch
and returns all bit_scores above the REVERSED cutoff
scores_file: The path to rfsearch outlist or species file
return: A list of all bit scores above REVERSED
"""
scores =... |
Parses the outlist or species file produced by rfsearch
and returns all bit_scores above the REVERSED cutoff
scores_file: The path to rfsearch outlist or species file
return: A list of all bit scores above REVERSED
| Parses the outlist or species file produced by rfsearch
and returns all bit_scores above the REVERSED cutoff
The path to rfsearch outlist or species file
A list of all bit scores above REVERSED | [
"Parses",
"the",
"outlist",
"or",
"species",
"file",
"produced",
"by",
"rfsearch",
"and",
"returns",
"all",
"bit_scores",
"above",
"the",
"REVERSED",
"cutoff",
"The",
"path",
"to",
"rfsearch",
"outlist",
"or",
"species",
"file",
"A",
"list",
"of",
"all",
"bi... | def extract_bitscores_list_from_scores_file(scores_file):
scores = []
outlist_fp = open(scores_file, 'r')
for line in outlist_fp:
if line[0] != '#':
line = [x for x in line.strip().split(' ') if x!='']
scores.append([float(line[0])])
else:
if line.find("BE... | [
"def",
"extract_bitscores_list_from_scores_file",
"(",
"scores_file",
")",
":",
"scores",
"=",
"[",
"]",
"outlist_fp",
"=",
"open",
"(",
"scores_file",
",",
"'r'",
")",
"for",
"line",
"in",
"outlist_fp",
":",
"if",
"line",
"[",
"0",
"]",
"!=",
"'#'",
":",
... | Parses the outlist or species file produced by rfsearch
and returns all bit_scores above the REVERSED cutoff | [
"Parses",
"the",
"outlist",
"or",
"species",
"file",
"produced",
"by",
"rfsearch",
"and",
"returns",
"all",
"bit_scores",
"above",
"the",
"REVERSED",
"cutoff"
] | [
"\"\"\"\n Parses the outlist or species file produced by rfsearch\n and returns all bit_scores above the REVERSED cutoff\n\n scores_file: The path to rfsearch outlist or species file\n\n return: A list of all bit scores above REVERSED\n \"\"\"",
"# if we reached REVERSED line, we treat everything a... | [
{
"param": "scores_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scores_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
22daa6fd3548de117072d5268930d3ffdcd0d640 | Rfam/rfam-production | scripts/processing/threshold_selector.py | [
"Apache-2.0"
] | Python | is_seed_below_reversed | <not_specific> | def is_seed_below_reversed(scores_file):
"""
Checks if any SEED sequences score below REVERSED
scores_file: The path to rfsearch outlist or species file
return: True if SEEDs sequences are found below REVERSED. False
otherwise
"""
seen_rev = False
fp = open(scores_file, 'r')
for... |
Checks if any SEED sequences score below REVERSED
scores_file: The path to rfsearch outlist or species file
return: True if SEEDs sequences are found below REVERSED. False
otherwise
| Checks if any SEED sequences score below REVERSED
scores_file: The path to rfsearch outlist or species file
True if SEEDs sequences are found below REVERSED. False
otherwise | [
"Checks",
"if",
"any",
"SEED",
"sequences",
"score",
"below",
"REVERSED",
"scores_file",
":",
"The",
"path",
"to",
"rfsearch",
"outlist",
"or",
"species",
"file",
"True",
"if",
"SEEDs",
"sequences",
"are",
"found",
"below",
"REVERSED",
".",
"False",
"otherwise... | def is_seed_below_reversed(scores_file):
seen_rev = False
fp = open(scores_file, 'r')
for line in fp:
if line[0] != '#':
if seen_rev is False:
continue
else:
line = [x for x in line.strip().split('\t') if x!='']
if line[2] == 'S... | [
"def",
"is_seed_below_reversed",
"(",
"scores_file",
")",
":",
"seen_rev",
"=",
"False",
"fp",
"=",
"open",
"(",
"scores_file",
",",
"'r'",
")",
"for",
"line",
"in",
"fp",
":",
"if",
"line",
"[",
"0",
"]",
"!=",
"'#'",
":",
"if",
"seen_rev",
"is",
"F... | Checks if any SEED sequences score below REVERSED
scores_file: The path to rfsearch outlist or species file | [
"Checks",
"if",
"any",
"SEED",
"sequences",
"score",
"below",
"REVERSED",
"scores_file",
":",
"The",
"path",
"to",
"rfsearch",
"outlist",
"or",
"species",
"file"
] | [
"\"\"\"\n Checks if any SEED sequences score below REVERSED\n\n scores_file: The path to rfsearch outlist or species file\n\n return: True if SEEDs sequences are found below REVERSED. False\n otherwise\n \"\"\""
] | [
{
"param": "scores_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scores_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
22daa6fd3548de117072d5268930d3ffdcd0d640 | Rfam/rfam-production | scripts/processing/threshold_selector.py | [
"Apache-2.0"
] | Python | compute_possible_gathering_thresholds | <not_specific> | def compute_possible_gathering_thresholds(scores, chunks=4):
"""
Selects a number of probable gathering thresholds to try
building the model with.
param scores:
param chunks:
return:
"""
ga_thresholds = []
all_scores = scores["SEED"] + scores["FULL"]
# sorts scores in descend... |
Selects a number of probable gathering thresholds to try
building the model with.
param scores:
param chunks:
return:
| Selects a number of probable gathering thresholds to try
building the model with.
param scores:
param chunks:
return. | [
"Selects",
"a",
"number",
"of",
"probable",
"gathering",
"thresholds",
"to",
"try",
"building",
"the",
"model",
"with",
".",
"param",
"scores",
":",
"param",
"chunks",
":",
"return",
"."
] | def compute_possible_gathering_thresholds(scores, chunks=4):
ga_thresholds = []
all_scores = scores["SEED"] + scores["FULL"]
rev_scores = list(reversed(sorted(all_scores)))
median = statistics.median(rev_scores)
min_seed_score = sorted(scores["SEED"])[0]
index = 0
if min_seed_score < median:... | [
"def",
"compute_possible_gathering_thresholds",
"(",
"scores",
",",
"chunks",
"=",
"4",
")",
":",
"ga_thresholds",
"=",
"[",
"]",
"all_scores",
"=",
"scores",
"[",
"\"SEED\"",
"]",
"+",
"scores",
"[",
"\"FULL\"",
"]",
"rev_scores",
"=",
"list",
"(",
"reverse... | Selects a number of probable gathering thresholds to try
building the model with. | [
"Selects",
"a",
"number",
"of",
"probable",
"gathering",
"thresholds",
"to",
"try",
"building",
"the",
"model",
"with",
"."
] | [
"\"\"\"\n Selects a number of probable gathering thresholds to try\n building the model with.\n\n param scores:\n param chunks:\n return:\n \"\"\"",
"# sorts scores in descending order to match order in outlist",
"# a bit conservative, always chooses the highest value",
"# a bit conservative... | [
{
"param": "scores",
"type": null
},
{
"param": "chunks",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scores",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chunks",
"type": null,
"docstring": null,
"docstring_tokens... |
22daa6fd3548de117072d5268930d3ffdcd0d640 | Rfam/rfam-production | scripts/processing/threshold_selector.py | [
"Apache-2.0"
] | Python | threshold_family_with_rfmake | <not_specific> | def threshold_family_with_rfmake(family_dir, gathering_threshold, full_align=True):
"""
Calls rfmake.pl to set the gathering threshold of a family
family_dir: The path to an Rfam family directory
gathering_threshold: A float value specifying the gathering threshold for the
family
return: Full ... |
Calls rfmake.pl to set the gathering threshold of a family
family_dir: The path to an Rfam family directory
gathering_threshold: A float value specifying the gathering threshold for the
family
return: Full alignment path if it exists or None if not. True upon completion
and full_align=False
... | Calls rfmake.pl to set the gathering threshold of a family
family_dir: The path to an Rfam family directory
gathering_threshold: A float value specifying the gathering threshold for the
family
Full alignment path if it exists or None if not. True upon completion
and full_align=False | [
"Calls",
"rfmake",
".",
"pl",
"to",
"set",
"the",
"gathering",
"threshold",
"of",
"a",
"family",
"family_dir",
":",
"The",
"path",
"to",
"an",
"Rfam",
"family",
"directory",
"gathering_threshold",
":",
"A",
"float",
"value",
"specifying",
"the",
"gathering",
... | def threshold_family_with_rfmake(family_dir, gathering_threshold, full_align=True):
os.chdir(family_dir)
cmd = "rfmake.pl -t %f"
if full_align is True:
cmd = "rfmake.pl -t %f -a"
subprocess.call(cmd % gathering_threshold, shell=True)
if full_align is True:
full_align_path = os.path.j... | [
"def",
"threshold_family_with_rfmake",
"(",
"family_dir",
",",
"gathering_threshold",
",",
"full_align",
"=",
"True",
")",
":",
"os",
".",
"chdir",
"(",
"family_dir",
")",
"cmd",
"=",
"\"rfmake.pl -t %f\"",
"if",
"full_align",
"is",
"True",
":",
"cmd",
"=",
"\... | Calls rfmake.pl to set the gathering threshold of a family
family_dir: The path to an Rfam family directory
gathering_threshold: A float value specifying the gathering threshold for the
family | [
"Calls",
"rfmake",
".",
"pl",
"to",
"set",
"the",
"gathering",
"threshold",
"of",
"a",
"family",
"family_dir",
":",
"The",
"path",
"to",
"an",
"Rfam",
"family",
"directory",
"gathering_threshold",
":",
"A",
"float",
"value",
"specifying",
"the",
"gathering",
... | [
"\"\"\"\n Calls rfmake.pl to set the gathering threshold of a family\n\n family_dir: The path to an Rfam family directory\n gathering_threshold: A float value specifying the gathering threshold for the\n family\n\n return: Full alignment path if it exists or None if not. True upon completion\n and... | [
{
"param": "family_dir",
"type": null
},
{
"param": "gathering_threshold",
"type": null
},
{
"param": "full_align",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "family_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "gathering_threshold",
"type": null,
"docstring": null,
... |
22daa6fd3548de117072d5268930d3ffdcd0d640 | Rfam/rfam-production | scripts/processing/threshold_selector.py | [
"Apache-2.0"
] | Python | generate_family_ss_with_rscape | <not_specific> | def generate_family_ss_with_rscape(family_dir, file_type='SEED'):
"""
family_dir:
file_type: The type of the alignment SEED/FULL
return:
"""
alignment_path = os.path.join(family_dir, file_type)
if file_type == "FULL":
alignment_path = os.path.join(family_dir, "align")
ou... |
family_dir:
file_type: The type of the alignment SEED/FULL
return:
| The type of the alignment SEED/FULL
| [
"The",
"type",
"of",
"the",
"alignment",
"SEED",
"/",
"FULL"
] | def generate_family_ss_with_rscape(family_dir, file_type='SEED'):
alignment_path = os.path.join(family_dir, file_type)
if file_type == "FULL":
alignment_path = os.path.join(family_dir, "align")
outdir = os.path.join(family_dir, "rscape-" + file_type.lower())
if not os.path.exists(outdir):
... | [
"def",
"generate_family_ss_with_rscape",
"(",
"family_dir",
",",
"file_type",
"=",
"'SEED'",
")",
":",
"alignment_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"family_dir",
",",
"file_type",
")",
"if",
"file_type",
"==",
"\"FULL\"",
":",
"alignment_path",
... | family_dir:
file_type: The type of the alignment SEED/FULL | [
"family_dir",
":",
"file_type",
":",
"The",
"type",
"of",
"the",
"alignment",
"SEED",
"/",
"FULL"
] | [
"\"\"\"\n\n family_dir:\n file_type: The type of the alignment SEED/FULL\n\n return:\n \"\"\"",
"# create outdir if it does not exist"
] | [
{
"param": "family_dir",
"type": null
},
{
"param": "file_type",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "family_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file_type",
"type": null,
"docstring": null,
"docstring... |
22daa6fd3548de117072d5268930d3ffdcd0d640 | Rfam/rfam-production | scripts/processing/threshold_selector.py | [
"Apache-2.0"
] | Python | parse_arguments | <not_specific> | def parse_arguments():
"""
Basic argument parsing using Python's argparse
return: A valid argpase parser object
"""
parser = argparse.ArgumentParser()
parser.add_argument("--input", help='The path to an Rfam family directory or a multi searches directory',
action='stor... |
Basic argument parsing using Python's argparse
return: A valid argpase parser object
| Basic argument parsing using Python's argparse
return: A valid argpase parser object | [
"Basic",
"argument",
"parsing",
"using",
"Python",
"'",
"s",
"argparse",
"return",
":",
"A",
"valid",
"argpase",
"parser",
"object"
] | def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("--input", help='The path to an Rfam family directory or a multi searches directory',
action='store')
mutually_exclusive = parser.add_mutually_exclusive_group()
mutually_exclusive.add_argument("--multi"... | [
"def",
"parse_arguments",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"--input\"",
",",
"help",
"=",
"'The path to an Rfam family directory or a multi searches directory'",
",",
"action",
"=",
"'stor... | Basic argument parsing using Python's argparse
return: A valid argpase parser object | [
"Basic",
"argument",
"parsing",
"using",
"Python",
"'",
"s",
"argparse",
"return",
":",
"A",
"valid",
"argpase",
"parser",
"object"
] | [
"\"\"\"\n Basic argument parsing using Python's argparse\n\n return: A valid argpase parser object\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | checkout_family | null | def checkout_family(rfam_acc):
"""
Checks out a family from Rfam based on a valid Rfam accession.
rfam_acc: A valid Rfam accession
return: None
"""
cmd = "rfco.pl %s" % rfam_acc
subprocess.call(cmd, shell=True)
# add some checks here |
Checks out a family from Rfam based on a valid Rfam accession.
rfam_acc: A valid Rfam accession
return: None
| Checks out a family from Rfam based on a valid Rfam accession.
rfam_acc: A valid Rfam accession
return: None | [
"Checks",
"out",
"a",
"family",
"from",
"Rfam",
"based",
"on",
"a",
"valid",
"Rfam",
"accession",
".",
"rfam_acc",
":",
"A",
"valid",
"Rfam",
"accession",
"return",
":",
"None"
] | def checkout_family(rfam_acc):
cmd = "rfco.pl %s" % rfam_acc
subprocess.call(cmd, shell=True) | [
"def",
"checkout_family",
"(",
"rfam_acc",
")",
":",
"cmd",
"=",
"\"rfco.pl %s\"",
"%",
"rfam_acc",
"subprocess",
".",
"call",
"(",
"cmd",
",",
"shell",
"=",
"True",
")"
] | Checks out a family from Rfam based on a valid Rfam accession. | [
"Checks",
"out",
"a",
"family",
"from",
"Rfam",
"based",
"on",
"a",
"valid",
"Rfam",
"accession",
"."
] | [
"\"\"\"\n Checks out a family from Rfam based on a valid Rfam accession.\n\n rfam_acc: A valid Rfam accession\n return: None\n \"\"\"",
"# add some checks here"
] | [
{
"param": "rfam_acc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rfam_acc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | submit_new_rfsearch_job | null | def submit_new_rfsearch_job(family_dir, rfmake=False):
"""
Submits a new lsf job that runs rfsearch to update SCORES for a new release.
If no threshold is set with rfsearch.pl, it uses existing thresholds by default.
family_dir: The physical location of the family directory
rfmake: If True, run rfm... |
Submits a new lsf job that runs rfsearch to update SCORES for a new release.
If no threshold is set with rfsearch.pl, it uses existing thresholds by default.
family_dir: The physical location of the family directory
rfmake: If True, run rfmake after rfsearch completes. Default False
return: None
... | Submits a new lsf job that runs rfsearch to update SCORES for a new release.
If no threshold is set with rfsearch.pl, it uses existing thresholds by default.
The physical location of the family directory
rfmake: If True, run rfmake after rfsearch completes. Default False
None | [
"Submits",
"a",
"new",
"lsf",
"job",
"that",
"runs",
"rfsearch",
"to",
"update",
"SCORES",
"for",
"a",
"new",
"release",
".",
"If",
"no",
"threshold",
"is",
"set",
"with",
"rfsearch",
".",
"pl",
"it",
"uses",
"existing",
"thresholds",
"by",
"default",
".... | def submit_new_rfsearch_job(family_dir, rfmake=False):
rfam_acc = os.path.basename(family_dir)
lsf_err_file = os.path.join(family_dir, "auto_rfsearch.err")
lsf_out_file = os.path.join(family_dir, "auto_rfsearch.out")
cmd = ("bsub -M %s -R \"rusage[mem=%s]\" -o %s -e %s -n %s -g %s -q production-rh7 "
... | [
"def",
"submit_new_rfsearch_job",
"(",
"family_dir",
",",
"rfmake",
"=",
"False",
")",
":",
"rfam_acc",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"family_dir",
")",
"lsf_err_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"family_dir",
",",
"\"auto_rf... | Submits a new lsf job that runs rfsearch to update SCORES for a new release. | [
"Submits",
"a",
"new",
"lsf",
"job",
"that",
"runs",
"rfsearch",
"to",
"update",
"SCORES",
"for",
"a",
"new",
"release",
"."
] | [
"\"\"\"\n Submits a new lsf job that runs rfsearch to update SCORES for a new release.\n If no threshold is set with rfsearch.pl, it uses existing thresholds by default.\n\n family_dir: The physical location of the family directory\n rfmake: If True, run rfmake after rfsearch completes. Default False\n\... | [
{
"param": "family_dir",
"type": null
},
{
"param": "rfmake",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "family_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rfmake",
"type": null,
"docstring": null,
"docstring_to... |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | submit_new_rfmake_job | null | def submit_new_rfmake_job(family_dir):
"""
Submits a new lsf job that runs rfsearch to update SCORES for a new release.
If no threshold is set with rfsearch.pl, it uses existing thresholds by default.
family_dir: The physical location of the family directory
rfmake: If True, run rfmake after rfsear... |
Submits a new lsf job that runs rfsearch to update SCORES for a new release.
If no threshold is set with rfsearch.pl, it uses existing thresholds by default.
family_dir: The physical location of the family directory
rfmake: If True, run rfmake after rfsearch completes. Default False
return: None
... | Submits a new lsf job that runs rfsearch to update SCORES for a new release.
If no threshold is set with rfsearch.pl, it uses existing thresholds by default.
The physical location of the family directory
rfmake: If True, run rfmake after rfsearch completes. Default False
None | [
"Submits",
"a",
"new",
"lsf",
"job",
"that",
"runs",
"rfsearch",
"to",
"update",
"SCORES",
"for",
"a",
"new",
"release",
".",
"If",
"no",
"threshold",
"is",
"set",
"with",
"rfsearch",
".",
"pl",
"it",
"uses",
"existing",
"thresholds",
"by",
"default",
".... | def submit_new_rfmake_job(family_dir):
rfam_acc = os.path.basename(family_dir)
lsf_err_file = os.path.join(family_dir, "auto_rfmake.err")
lsf_out_file = os.path.join(family_dir, "auto_rfmake.out")
cmd = ("bsub -M %s -R \"rusage[mem=%s]\" -o %s -e %s -n %s -g %s -q production-rh7 "
"-J %s \"cd... | [
"def",
"submit_new_rfmake_job",
"(",
"family_dir",
")",
":",
"rfam_acc",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"family_dir",
")",
"lsf_err_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"family_dir",
",",
"\"auto_rfmake.err\"",
")",
"lsf_out_file",
... | Submits a new lsf job that runs rfsearch to update SCORES for a new release. | [
"Submits",
"a",
"new",
"lsf",
"job",
"that",
"runs",
"rfsearch",
"to",
"update",
"SCORES",
"for",
"a",
"new",
"release",
"."
] | [
"\"\"\"\n Submits a new lsf job that runs rfsearch to update SCORES for a new release.\n If no threshold is set with rfsearch.pl, it uses existing thresholds by default.\n\n family_dir: The physical location of the family directory\n rfmake: If True, run rfmake after rfsearch completes. Default False\n\... | [
{
"param": "family_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "family_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | load_rfam_accessions_from_file | <not_specific> | def load_rfam_accessions_from_file(accession_list):
"""
This function parses a .txt file containing Rfam accessions and returns those
accession_list: This is a .txt file containing a list of Rfam accessions
return: list of Rfam family accessions
"""
fp = open(accession_list, 'r')
accessions... |
This function parses a .txt file containing Rfam accessions and returns those
accession_list: This is a .txt file containing a list of Rfam accessions
return: list of Rfam family accessions
| This function parses a .txt file containing Rfam accessions and returns those
accession_list: This is a .txt file containing a list of Rfam accessions
list of Rfam family accessions | [
"This",
"function",
"parses",
"a",
".",
"txt",
"file",
"containing",
"Rfam",
"accessions",
"and",
"returns",
"those",
"accession_list",
":",
"This",
"is",
"a",
".",
"txt",
"file",
"containing",
"a",
"list",
"of",
"Rfam",
"accessions",
"list",
"of",
"Rfam",
... | def load_rfam_accessions_from_file(accession_list):
fp = open(accession_list, 'r')
accessions = [x.strip() for x in fp]
fp.close()
return accessions | [
"def",
"load_rfam_accessions_from_file",
"(",
"accession_list",
")",
":",
"fp",
"=",
"open",
"(",
"accession_list",
",",
"'r'",
")",
"accessions",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"in",
"fp",
"]",
"fp",
".",
"close",
"(",
")",
"return... | This function parses a .txt file containing Rfam accessions and returns those
accession_list: This is a .txt file containing a list of Rfam accessions | [
"This",
"function",
"parses",
"a",
".",
"txt",
"file",
"containing",
"Rfam",
"accessions",
"and",
"returns",
"those",
"accession_list",
":",
"This",
"is",
"a",
".",
"txt",
"file",
"containing",
"a",
"list",
"of",
"Rfam",
"accessions"
] | [
"\"\"\"\n This function parses a .txt file containing Rfam accessions and returns those\n accession_list: This is a .txt file containing a list of Rfam accessions\n\n return: list of Rfam family accessions\n \"\"\""
] | [
{
"param": "accession_list",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "accession_list",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | checkout_and_search_family | null | def checkout_and_search_family(rfam_acc, dest_dir, rfmake=False):
"""
This function combines family checkout (rfco.pl) and re-scoring of hits
using rfsearch.pl. If the family directory already exists, then the
checkout step will be ignored
rfam_acc: A valid Rfam family accession (RFXXXXX)
dest_... |
This function combines family checkout (rfco.pl) and re-scoring of hits
using rfsearch.pl. If the family directory already exists, then the
checkout step will be ignored
rfam_acc: A valid Rfam family accession (RFXXXXX)
dest_dir: A valid destination directory, where to checkout the family
rfma... | This function combines family checkout (rfco.pl) and re-scoring of hits
using rfsearch.pl. If the family directory already exists, then the
checkout step will be ignored
A valid Rfam family accession (RFXXXXX)
dest_dir: A valid destination directory, where to checkout the family
rfmake: If True, run rfmake after rfsea... | [
"This",
"function",
"combines",
"family",
"checkout",
"(",
"rfco",
".",
"pl",
")",
"and",
"re",
"-",
"scoring",
"of",
"hits",
"using",
"rfsearch",
".",
"pl",
".",
"If",
"the",
"family",
"directory",
"already",
"exists",
"then",
"the",
"checkout",
"step",
... | def checkout_and_search_family(rfam_acc, dest_dir, rfmake=False):
family_dir = os.path.join(dest_dir, rfam_acc)
if not os.path.exists(family_dir):
os.chdir(dest_dir)
checkout_family(rfam_acc)
submit_new_rfsearch_job(family_dir, rfmake) | [
"def",
"checkout_and_search_family",
"(",
"rfam_acc",
",",
"dest_dir",
",",
"rfmake",
"=",
"False",
")",
":",
"family_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dest_dir",
",",
"rfam_acc",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
... | This function combines family checkout (rfco.pl) and re-scoring of hits
using rfsearch.pl. | [
"This",
"function",
"combines",
"family",
"checkout",
"(",
"rfco",
".",
"pl",
")",
"and",
"re",
"-",
"scoring",
"of",
"hits",
"using",
"rfsearch",
".",
"pl",
"."
] | [
"\"\"\"\n This function combines family checkout (rfco.pl) and re-scoring of hits\n using rfsearch.pl. If the family directory already exists, then the\n checkout step will be ignored\n\n rfam_acc: A valid Rfam family accession (RFXXXXX)\n dest_dir: A valid destination directory, where to checkout th... | [
{
"param": "rfam_acc",
"type": null
},
{
"param": "dest_dir",
"type": null
},
{
"param": "rfmake",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rfam_acc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest_dir",
"type": null,
"docstring": null,
"docstring_to... |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | parse_arguments | <not_specific> | def parse_arguments():
"""
Uses python's argparse to parse the command line arguments
return: Argparse parser object
"""
# create a new argument parser object
parser = argparse.ArgumentParser(description='Update scores for new release')
# group required arguments together
req_args = p... |
Uses python's argparse to parse the command line arguments
return: Argparse parser object
| Uses python's argparse to parse the command line arguments
return: Argparse parser object | [
"Uses",
"python",
"'",
"s",
"argparse",
"to",
"parse",
"the",
"command",
"line",
"arguments",
"return",
":",
"Argparse",
"parser",
"object"
] | def parse_arguments():
parser = argparse.ArgumentParser(description='Update scores for new release')
req_args = parser.add_argument_group("required arguments")
req_args.add_argument('--dest-dir', help='destination directory where to checkout families',
type=str, required=True)
... | [
"def",
"parse_arguments",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Update scores for new release'",
")",
"req_args",
"=",
"parser",
".",
"add_argument_group",
"(",
"\"required arguments\"",
")",
"req_args",
".",
"ad... | Uses python's argparse to parse the command line arguments
return: Argparse parser object | [
"Uses",
"python",
"'",
"s",
"argparse",
"to",
"parse",
"the",
"command",
"line",
"arguments",
"return",
":",
"Argparse",
"parser",
"object"
] | [
"\"\"\"\n Uses python's argparse to parse the command line arguments\n\n return: Argparse parser object\n \"\"\"",
"# create a new argument parser object",
"# group required arguments together",
"# this is mutually exclusive with --acc option"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | is_valid_family | <not_specific> | def is_valid_family(dest_dir, rfam_acc):
"""
Checks if the job ran successfully by checking if .err file is empty and
that Success keyword exists in .out file. As an additional sanity check, we
look for the rfsearch.log file as an indication that rfsearch actually ran.
return: True if the family is... |
Checks if the job ran successfully by checking if .err file is empty and
that Success keyword exists in .out file. As an additional sanity check, we
look for the rfsearch.log file as an indication that rfsearch actually ran.
return: True if the family is valid, False otherwise
| Checks if the job ran successfully by checking if .err file is empty and
that Success keyword exists in .out file. As an additional sanity check, we
look for the rfsearch.log file as an indication that rfsearch actually ran.
True if the family is valid, False otherwise | [
"Checks",
"if",
"the",
"job",
"ran",
"successfully",
"by",
"checking",
"if",
".",
"err",
"file",
"is",
"empty",
"and",
"that",
"Success",
"keyword",
"exists",
"in",
".",
"out",
"file",
".",
"As",
"an",
"additional",
"sanity",
"check",
"we",
"look",
"for"... | def is_valid_family(dest_dir, rfam_acc):
family_dir = os.path.join(dest_dir, rfam_acc)
if not os.path.exists(os.path.join(family_dir, "rfsearch.log")):
return False
if not os.path.getsize(os.path.join(family_dir, "auto_rfsearch.err")) == 0:
return check_rfsearch_log_success(family_dir)
l... | [
"def",
"is_valid_family",
"(",
"dest_dir",
",",
"rfam_acc",
")",
":",
"family_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dest_dir",
",",
"rfam_acc",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"(",
... | Checks if the job ran successfully by checking if .err file is empty and
that Success keyword exists in .out file. | [
"Checks",
"if",
"the",
"job",
"ran",
"successfully",
"by",
"checking",
"if",
".",
"err",
"file",
"is",
"empty",
"and",
"that",
"Success",
"keyword",
"exists",
"in",
".",
"out",
"file",
"."
] | [
"\"\"\"\n Checks if the job ran successfully by checking if .err file is empty and\n that Success keyword exists in .out file. As an additional sanity check, we\n look for the rfsearch.log file as an indication that rfsearch actually ran.\n\n return: True if the family is valid, False otherwise\n \"\... | [
{
"param": "dest_dir",
"type": null
},
{
"param": "rfam_acc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dest_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rfam_acc",
"type": null,
"docstring": null,
"docstring_to... |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | check_rfsearch_log_success | <not_specific> | def check_rfsearch_log_success(family_dir):
"""
Checks if the rfsearch.log file contains the success string # [ok] in
order to mark the family as successfully completed.
"""
rfsearch_log_file = os.path.join(family_dir, "rfsearch.log")
process = Popen(['tail', '-1', rfsearch_log_file], stdin=PIP... |
Checks if the rfsearch.log file contains the success string # [ok] in
order to mark the family as successfully completed.
| Checks if the rfsearch.log file contains the success string # [ok] in
order to mark the family as successfully completed. | [
"Checks",
"if",
"the",
"rfsearch",
".",
"log",
"file",
"contains",
"the",
"success",
"string",
"#",
"[",
"ok",
"]",
"in",
"order",
"to",
"mark",
"the",
"family",
"as",
"successfully",
"completed",
"."
] | def check_rfsearch_log_success(family_dir):
rfsearch_log_file = os.path.join(family_dir, "rfsearch.log")
process = Popen(['tail', '-1', rfsearch_log_file], stdin=PIPE, stdout=PIPE, stderr=PIPE)
output, err = process.communicate()
if output.find("# [ok]") == -1:
return False
return True | [
"def",
"check_rfsearch_log_success",
"(",
"family_dir",
")",
":",
"rfsearch_log_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"family_dir",
",",
"\"rfsearch.log\"",
")",
"process",
"=",
"Popen",
"(",
"[",
"'tail'",
",",
"'-1'",
",",
"rfsearch_log_file",
"]"... | Checks if the rfsearch.log file contains the success string # [ok] in
order to mark the family as successfully completed. | [
"Checks",
"if",
"the",
"rfsearch",
".",
"log",
"file",
"contains",
"the",
"success",
"string",
"#",
"[",
"ok",
"]",
"in",
"order",
"to",
"mark",
"the",
"family",
"as",
"successfully",
"completed",
"."
] | [
"\"\"\"\n Checks if the rfsearch.log file contains the success string # [ok] in\n order to mark the family as successfully completed.\n \"\"\""
] | [
{
"param": "family_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "family_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | count_hits | <not_specific> | def count_hits(scores_file):
"""
Function to count SEED and FULL hits in outlist and species files at three
different thresholds (above ga, below ga, below rev)
scores_file: This is either the species or the outlist files from the family
directories
return: A dictionary with SEED and FULL coun... |
Function to count SEED and FULL hits in outlist and species files at three
different thresholds (above ga, below ga, below rev)
scores_file: This is either the species or the outlist files from the family
directories
return: A dictionary with SEED and FULL counts at different thresholds
| Function to count SEED and FULL hits in outlist and species files at three
different thresholds (above ga, below ga, below rev)
This is either the species or the outlist files from the family
directories
A dictionary with SEED and FULL counts at different thresholds | [
"Function",
"to",
"count",
"SEED",
"and",
"FULL",
"hits",
"in",
"outlist",
"and",
"species",
"files",
"at",
"three",
"different",
"thresholds",
"(",
"above",
"ga",
"below",
"ga",
"below",
"rev",
")",
"This",
"is",
"either",
"the",
"species",
"or",
"the",
... | def count_hits(scores_file):
flag_curr = 0
flag_rev = 0
counts = {"seed_above_ga": 0,
"full_above_ga": 0,
"full_below_ga": 0,
"seed_below_ga": 0,
"seed_below_rev": 0,
"full_below_rev": 0}
fp = open(scores_file, 'r')
for line in fp... | [
"def",
"count_hits",
"(",
"scores_file",
")",
":",
"flag_curr",
"=",
"0",
"flag_rev",
"=",
"0",
"counts",
"=",
"{",
"\"seed_above_ga\"",
":",
"0",
",",
"\"full_above_ga\"",
":",
"0",
",",
"\"full_below_ga\"",
":",
"0",
",",
"\"seed_below_ga\"",
":",
"0",
"... | Function to count SEED and FULL hits in outlist and species files at three
different thresholds (above ga, below ga, below rev) | [
"Function",
"to",
"count",
"SEED",
"and",
"FULL",
"hits",
"in",
"outlist",
"and",
"species",
"files",
"at",
"three",
"different",
"thresholds",
"(",
"above",
"ga",
"below",
"ga",
"below",
"rev",
")"
] | [
"\"\"\"\n Function to count SEED and FULL hits in outlist and species files at three\n different thresholds (above ga, below ga, below rev)\n\n scores_file: This is either the species or the outlist files from the family\n directories\n\n return: A dictionary with SEED and FULL counts at different th... | [
{
"param": "scores_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "scores_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | extract_unique_seeds_from_seedoutlist | <not_specific> | def extract_unique_seeds_from_seedoutlist(seedoutlist):
"""
Extracts all unique SEED accessions in the form of rfamseq_acc/start-end.
Ignores duplicated hits.
"""
seeds_found = {}
fp = open(seedoutlist, 'r')
for line in fp:
if line[0] != '#':
line = [x for x in line.s... |
Extracts all unique SEED accessions in the form of rfamseq_acc/start-end.
Ignores duplicated hits.
| Extracts all unique SEED accessions in the form of rfamseq_acc/start-end.
Ignores duplicated hits. | [
"Extracts",
"all",
"unique",
"SEED",
"accessions",
"in",
"the",
"form",
"of",
"rfamseq_acc",
"/",
"start",
"-",
"end",
".",
"Ignores",
"duplicated",
"hits",
"."
] | def extract_unique_seeds_from_seedoutlist(seedoutlist):
seeds_found = {}
fp = open(seedoutlist, 'r')
for line in fp:
if line[0] != '#':
line = [x for x in line.strip().split(' ') if x != '']
if line[3] not in seeds_found:
seeds_found[line[3]] = float(line[0])
... | [
"def",
"extract_unique_seeds_from_seedoutlist",
"(",
"seedoutlist",
")",
":",
"seeds_found",
"=",
"{",
"}",
"fp",
"=",
"open",
"(",
"seedoutlist",
",",
"'r'",
")",
"for",
"line",
"in",
"fp",
":",
"if",
"line",
"[",
"0",
"]",
"!=",
"'#'",
":",
"line",
"... | Extracts all unique SEED accessions in the form of rfamseq_acc/start-end. | [
"Extracts",
"all",
"unique",
"SEED",
"accessions",
"in",
"the",
"form",
"of",
"rfamseq_acc",
"/",
"start",
"-",
"end",
"."
] | [
"\"\"\"\n Extracts all unique SEED accessions in the form of rfamseq_acc/start-end.\n Ignores duplicated hits.\n\n \"\"\""
] | [
{
"param": "seedoutlist",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "seedoutlist",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | generate_search_stats | null | def generate_search_stats(family_dir, scores_file='species', tag_miRNA=True):
"""
Function to generate useful search stats per family
family_dir: A valid Rfam family checkout directory where pre-computed searches
were ran
scores_file: A string specifying the scores file to parse (outlist, species)
... |
Function to generate useful search stats per family
family_dir: A valid Rfam family checkout directory where pre-computed searches
were ran
scores_file: A string specifying the scores file to parse (outlist, species)
return: report string
| Function to generate useful search stats per family
family_dir: A valid Rfam family checkout directory where pre-computed searches
were ran
scores_file: A string specifying the scores file to parse (outlist, species)
report string | [
"Function",
"to",
"generate",
"useful",
"search",
"stats",
"per",
"family",
"family_dir",
":",
"A",
"valid",
"Rfam",
"family",
"checkout",
"directory",
"where",
"pre",
"-",
"computed",
"searches",
"were",
"ran",
"scores_file",
":",
"A",
"string",
"specifying",
... | def generate_search_stats(family_dir, scores_file='species', tag_miRNA=True):
rfam_acc = os.path.basename(family_dir)
flag_curr = 0
flag_rev = 0
elements = None
prev_line = None
seen_ga = False
seen_rev_before_ga = False
ga_bit_score = 0.0
rev_bit_score = 0.0
ga_rev_seq_gap = 0 ... | [
"def",
"generate_search_stats",
"(",
"family_dir",
",",
"scores_file",
"=",
"'species'",
",",
"tag_miRNA",
"=",
"True",
")",
":",
"rfam_acc",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"family_dir",
")",
"flag_curr",
"=",
"0",
"flag_rev",
"=",
"0",
"ele... | Function to generate useful search stats per family
family_dir: A valid Rfam family checkout directory where pre-computed searches
were ran
scores_file: A string specifying the scores file to parse (outlist, species) | [
"Function",
"to",
"generate",
"useful",
"search",
"stats",
"per",
"family",
"family_dir",
":",
"A",
"valid",
"Rfam",
"family",
"checkout",
"directory",
"where",
"pre",
"-",
"computed",
"searches",
"were",
"ran",
"scores_file",
":",
"A",
"string",
"specifying",
... | [
"\"\"\"\n Function to generate useful search stats per family\n\n family_dir: A valid Rfam family checkout directory where pre-computed searches\n were ran\n scores_file: A string specifying the scores file to parse (outlist, species)\n\n return: report string\n \"\"\"",
"# check point flags",
... | [
{
"param": "family_dir",
"type": null
},
{
"param": "scores_file",
"type": null
},
{
"param": "tag_miRNA",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "family_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "scores_file",
"type": null,
"docstring": null,
"docstri... |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | write_family_report_file | <not_specific> | def write_family_report_file(family_dir, scores_file="species"):
"""
Function to generate a report about the outcome of a new search
family_dir: A valid location of an Rfam family checkout
scores_file: This is a string which specifies the file to parse (outlist | species)
It parses species file by ... |
Function to generate a report about the outcome of a new search
family_dir: A valid location of an Rfam family checkout
scores_file: This is a string which specifies the file to parse (outlist | species)
It parses species file by default.
return (int): A number specifying the curation priority fo... | Function to generate a report about the outcome of a new search
family_dir: A valid location of an Rfam family checkout
scores_file: This is a string which specifies the file to parse (outlist | species)
It parses species file by default.
| [
"Function",
"to",
"generate",
"a",
"report",
"about",
"the",
"outcome",
"of",
"a",
"new",
"search",
"family_dir",
":",
"A",
"valid",
"location",
"of",
"an",
"Rfam",
"family",
"checkout",
"scores_file",
":",
"This",
"is",
"a",
"string",
"which",
"specifies",
... | def write_family_report_file(family_dir, scores_file="species"):
priority = 0
rfam_acc = os.path.basename(family_dir)
no_seed_seqs = db.get_number_of_seed_sequences(rfam_acc)
scores_file_loc = os.path.join(family_dir, scores_file)
counts = count_hits(scores_file_loc)
report_fp = open(os.path.joi... | [
"def",
"write_family_report_file",
"(",
"family_dir",
",",
"scores_file",
"=",
"\"species\"",
")",
":",
"priority",
"=",
"0",
"rfam_acc",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"family_dir",
")",
"no_seed_seqs",
"=",
"db",
".",
"get_number_of_seed_sequenc... | Function to generate a report about the outcome of a new search
family_dir: A valid location of an Rfam family checkout
scores_file: This is a string which specifies the file to parse (outlist | species)
It parses species file by default. | [
"Function",
"to",
"generate",
"a",
"report",
"about",
"the",
"outcome",
"of",
"a",
"new",
"search",
"family_dir",
":",
"A",
"valid",
"location",
"of",
"an",
"Rfam",
"family",
"checkout",
"scores_file",
":",
"This",
"is",
"a",
"string",
"which",
"specifies",
... | [
"\"\"\"\n Function to generate a report about the outcome of a new search\n\n family_dir: A valid location of an Rfam family checkout\n scores_file: This is a string which specifies the file to parse (outlist | species)\n It parses species file by default.\n\n return (int): A number specifying the cu... | [
{
"param": "family_dir",
"type": null
},
{
"param": "scores_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "family_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "scores_file",
"type": null,
"docstring": null,
"docstri... |
a841258f2bc63d91f69f920265ca15df961c5531 | Rfam/rfam-production | scripts/release/rethreshold_family.py | [
"Apache-2.0"
] | Python | print_report_header | null | def print_report_header(extended=True):
"""
Prints the report header
extended (boolean): If true, prints all the columns, otherwise just the
short version
returns: void
"""
if extended is True:
print (
"RFAM_ACC\tnum_seed_seqs\tseed_above_GA\tseed_below_ga\tseed_below_rev\... |
Prints the report header
extended (boolean): If true, prints all the columns, otherwise just the
short version
returns: void
| Prints the report header
extended (boolean): If true, prints all the columns, otherwise just the
short version
void | [
"Prints",
"the",
"report",
"header",
"extended",
"(",
"boolean",
")",
":",
"If",
"true",
"prints",
"all",
"the",
"columns",
"otherwise",
"just",
"the",
"short",
"version",
"void"
] | def print_report_header(extended=True):
if extended is True:
print (
"RFAM_ACC\tnum_seed_seqs\tseed_above_GA\tseed_below_ga\tseed_below_rev\tmissing_seeds_outlist\t".upper()),
print ("missing_seeds_seedoutlist\tnum_full_DB\tfull_above_ga\tUNIQUE_NCBI_ID_DB\tNOVEL_NCBI_IDs\t".upper()),
... | [
"def",
"print_report_header",
"(",
"extended",
"=",
"True",
")",
":",
"if",
"extended",
"is",
"True",
":",
"print",
"(",
"\"RFAM_ACC\\tnum_seed_seqs\\tseed_above_GA\\tseed_below_ga\\tseed_below_rev\\tmissing_seeds_outlist\\t\"",
".",
"upper",
"(",
")",
")",
",",
"print",
... | Prints the report header
extended (boolean): If true, prints all the columns, otherwise just the
short version | [
"Prints",
"the",
"report",
"header",
"extended",
"(",
"boolean",
")",
":",
"If",
"true",
"prints",
"all",
"the",
"columns",
"otherwise",
"just",
"the",
"short",
"version"
] | [
"\"\"\"\n Prints the report header\n\n extended (boolean): If true, prints all the columns, otherwise just the\n short version\n\n returns: void\n \"\"\""
] | [
{
"param": "extended",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "extended",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7af763cdd431bc4eab3ebf259ef271351c4b8234 | MarkDekker/CarND-Vehicle-Detection | imganalyser.py | [
"MIT"
] | Python | change_colorspace | null | def change_colorspace(self, new_colorspace):
"""Change the colorspace from RGB."""
image = self.image
old_colorspace = self.colorspace
possible_spaces = ['HSV', 'LUV', 'HLS', 'YUV', 'YCrCb']
if (new_colorspace in possible_spaces and
new_colorspace != old_colorspa... | Change the colorspace from RGB. | Change the colorspace from RGB. | [
"Change",
"the",
"colorspace",
"from",
"RGB",
"."
] | def change_colorspace(self, new_colorspace):
image = self.image
old_colorspace = self.colorspace
possible_spaces = ['HSV', 'LUV', 'HLS', 'YUV', 'YCrCb']
if (new_colorspace in possible_spaces and
new_colorspace != old_colorspace):
converter = getattr(cv2, "COLO... | [
"def",
"change_colorspace",
"(",
"self",
",",
"new_colorspace",
")",
":",
"image",
"=",
"self",
".",
"image",
"old_colorspace",
"=",
"self",
".",
"colorspace",
"possible_spaces",
"=",
"[",
"'HSV'",
",",
"'LUV'",
",",
"'HLS'",
",",
"'YUV'",
",",
"'YCrCb'",
... | Change the colorspace from RGB. | [
"Change",
"the",
"colorspace",
"from",
"RGB",
"."
] | [
"\"\"\"Change the colorspace from RGB.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "new_colorspace",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "new_colorspace",
"type": null,
"docstring": null,
"docstring_... |
7af763cdd431bc4eab3ebf259ef271351c4b8234 | MarkDekker/CarND-Vehicle-Detection | imganalyser.py | [
"MIT"
] | Python | extract_hog_features | <not_specific> | def extract_hog_features(self):
"""Extract the "Histogram of Oriented Gradients" for the region of
interest of the current image.
"""
img = self.image
orient = self.hog_params['orientations']
pix_per_cell = self.hog_params['pix_per_cell']
cell_per_block = self.hog... | Extract the "Histogram of Oriented Gradients" for the region of
interest of the current image.
| Extract the "Histogram of Oriented Gradients" for the region of
interest of the current image. | [
"Extract",
"the",
"\"",
"Histogram",
"of",
"Oriented",
"Gradients",
"\"",
"for",
"the",
"region",
"of",
"interest",
"of",
"the",
"current",
"image",
"."
] | def extract_hog_features(self):
img = self.image
orient = self.hog_params['orientations']
pix_per_cell = self.hog_params['pix_per_cell']
cell_per_block = self.hog_params['cell_per_block']
visualise = self.hog_params['visualise']
channels = img.shape[2]
hog_feature... | [
"def",
"extract_hog_features",
"(",
"self",
")",
":",
"img",
"=",
"self",
".",
"image",
"orient",
"=",
"self",
".",
"hog_params",
"[",
"'orientations'",
"]",
"pix_per_cell",
"=",
"self",
".",
"hog_params",
"[",
"'pix_per_cell'",
"]",
"cell_per_block",
"=",
"... | Extract the "Histogram of Oriented Gradients" for the region of
interest of the current image. | [
"Extract",
"the",
"\"",
"Histogram",
"of",
"Oriented",
"Gradients",
"\"",
"for",
"the",
"region",
"of",
"interest",
"of",
"the",
"current",
"image",
"."
] | [
"\"\"\"Extract the \"Histogram of Oriented Gradients\" for the region of\n interest of the current image.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7af763cdd431bc4eab3ebf259ef271351c4b8234 | MarkDekker/CarND-Vehicle-Detection | imganalyser.py | [
"MIT"
] | Python | plot_histogram | null | def plot_histogram(values, chart_title, series_labels):
"""Plots the supplied colour histogram as a barchart."""
x_val = np.arange(0, 260, 260/len(values[0]))
n_series = len(series_labels)
colors = [[0.88, 0.75, 0.35, 0.7],
[0.75, 0.63, 0.25, 0.7],
[0.60, 0.47, 0.10, 0.7]]
... | Plots the supplied colour histogram as a barchart. | Plots the supplied colour histogram as a barchart. | [
"Plots",
"the",
"supplied",
"colour",
"histogram",
"as",
"a",
"barchart",
"."
] | def plot_histogram(values, chart_title, series_labels):
x_val = np.arange(0, 260, 260/len(values[0]))
n_series = len(series_labels)
colors = [[0.88, 0.75, 0.35, 0.7],
[0.75, 0.63, 0.25, 0.7],
[0.60, 0.47, 0.10, 0.7]]
plt.subplots(1, n_series, figsize=(10, 3), dpi=120)
plt... | [
"def",
"plot_histogram",
"(",
"values",
",",
"chart_title",
",",
"series_labels",
")",
":",
"x_val",
"=",
"np",
".",
"arange",
"(",
"0",
",",
"260",
",",
"260",
"/",
"len",
"(",
"values",
"[",
"0",
"]",
")",
")",
"n_series",
"=",
"len",
"(",
"serie... | Plots the supplied colour histogram as a barchart. | [
"Plots",
"the",
"supplied",
"colour",
"histogram",
"as",
"a",
"barchart",
"."
] | [
"\"\"\"Plots the supplied colour histogram as a barchart.\"\"\""
] | [
{
"param": "values",
"type": null
},
{
"param": "chart_title",
"type": null
},
{
"param": "series_labels",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "values",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chart_title",
"type": null,
"docstring": null,
"docstring_t... |
86a7515977f4f1417218f61fe2ece6e0e58e9e48 | MarkDekker/CarND-Vehicle-Detection | datahandler.py | [
"MIT"
] | Python | import_training_data | <not_specific> | def import_training_data(self, data_path):
"""Import the training data from a given input path. Assuming that
the input path only contains folders where the folder name designates
the image label. All sub-directories are searched but their names are
ignored.
"""
folders =... | Import the training data from a given input path. Assuming that
the input path only contains folders where the folder name designates
the image label. All sub-directories are searched but their names are
ignored.
| Import the training data from a given input path. Assuming that
the input path only contains folders where the folder name designates
the image label. All sub-directories are searched but their names are
ignored. | [
"Import",
"the",
"training",
"data",
"from",
"a",
"given",
"input",
"path",
".",
"Assuming",
"that",
"the",
"input",
"path",
"only",
"contains",
"folders",
"where",
"the",
"folder",
"name",
"designates",
"the",
"image",
"label",
".",
"All",
"sub",
"-",
"di... | def import_training_data(self, data_path):
folders = os.listdir(data_path)
training_set = {}
for folder in folders:
folder_path = os.path.join(data_path, folder)
if os.path.isdir(folder_path):
new_images = self.search_folder_for_images(folder_path)
... | [
"def",
"import_training_data",
"(",
"self",
",",
"data_path",
")",
":",
"folders",
"=",
"os",
".",
"listdir",
"(",
"data_path",
")",
"training_set",
"=",
"{",
"}",
"for",
"folder",
"in",
"folders",
":",
"folder_path",
"=",
"os",
".",
"path",
".",
"join",... | Import the training data from a given input path. | [
"Import",
"the",
"training",
"data",
"from",
"a",
"given",
"input",
"path",
"."
] | [
"\"\"\"Import the training data from a given input path. Assuming that\n the input path only contains folders where the folder name designates\n the image label. All sub-directories are searched but their names are\n ignored.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "data_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data_path",
"type": null,
"docstring": null,
"docstring_token... |
86a7515977f4f1417218f61fe2ece6e0e58e9e48 | MarkDekker/CarND-Vehicle-Detection | datahandler.py | [
"MIT"
] | Python | search_folder_for_images | <not_specific> | def search_folder_for_images(self, folder):
"""Recursively search through and import all images that are found
in a folder.
"""
files = os.listdir(folder)
images = []
for file in files:
file_path = os.path.join(folder, file)
if self.get_extension(... | Recursively search through and import all images that are found
in a folder.
| Recursively search through and import all images that are found
in a folder. | [
"Recursively",
"search",
"through",
"and",
"import",
"all",
"images",
"that",
"are",
"found",
"in",
"a",
"folder",
"."
] | def search_folder_for_images(self, folder):
files = os.listdir(folder)
images = []
for file in files:
file_path = os.path.join(folder, file)
if self.get_extension(file) in self.img_extensions:
images.append(import_image(file_path))
elif os.path... | [
"def",
"search_folder_for_images",
"(",
"self",
",",
"folder",
")",
":",
"files",
"=",
"os",
".",
"listdir",
"(",
"folder",
")",
"images",
"=",
"[",
"]",
"for",
"file",
"in",
"files",
":",
"file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"folde... | Recursively search through and import all images that are found
in a folder. | [
"Recursively",
"search",
"through",
"and",
"import",
"all",
"images",
"that",
"are",
"found",
"in",
"a",
"folder",
"."
] | [
"\"\"\"Recursively search through and import all images that are found\n in a folder.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "folder",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "folder",
"type": null,
"docstring": null,
"docstring_tokens":... |
86a7515977f4f1417218f61fe2ece6e0e58e9e48 | MarkDekker/CarND-Vehicle-Detection | datahandler.py | [
"MIT"
] | Python | extract_features | null | def extract_features(self, image_analyser, hog_features=True, spatial=True,
histograms=True):
"""Extracts image features from all elements in the data set."""
self.training_set_features = {}
for label, images in self.training_set.items():
start = time.time()
... | Extracts image features from all elements in the data set. | Extracts image features from all elements in the data set. | [
"Extracts",
"image",
"features",
"from",
"all",
"elements",
"in",
"the",
"data",
"set",
"."
] | def extract_features(self, image_analyser, hog_features=True, spatial=True,
histograms=True):
self.training_set_features = {}
for label, images in self.training_set.items():
start = time.time()
self.training_set_features[label] = []
for image ... | [
"def",
"extract_features",
"(",
"self",
",",
"image_analyser",
",",
"hog_features",
"=",
"True",
",",
"spatial",
"=",
"True",
",",
"histograms",
"=",
"True",
")",
":",
"self",
".",
"training_set_features",
"=",
"{",
"}",
"for",
"label",
",",
"images",
"in"... | Extracts image features from all elements in the data set. | [
"Extracts",
"image",
"features",
"from",
"all",
"elements",
"in",
"the",
"data",
"set",
"."
] | [
"\"\"\"Extracts image features from all elements in the data set.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "image_analyser",
"type": null
},
{
"param": "hog_features",
"type": null
},
{
"param": "spatial",
"type": null
},
{
"param": "histograms",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "image_analyser",
"type": null,
"docstring": null,
"docstring_... |
d053f43220751a8b3d50320c9d08d3d15ed3707e | MarkDekker/CarND-Vehicle-Detection | utilityfun.py | [
"MIT"
] | Python | import_image | <not_specific> | def import_image(image_path):
"""Import an image from the supplied path.
Returns the image name and the image.
"""
img = cv2.imread(image_path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
#img_name = image_path.split('/')[-1].split('.')[0]
return img | Import an image from the supplied path.
Returns the image name and the image.
| Import an image from the supplied path.
Returns the image name and the image. | [
"Import",
"an",
"image",
"from",
"the",
"supplied",
"path",
".",
"Returns",
"the",
"image",
"name",
"and",
"the",
"image",
"."
] | def import_image(image_path):
img = cv2.imread(image_path)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
return img | [
"def",
"import_image",
"(",
"image_path",
")",
":",
"img",
"=",
"cv2",
".",
"imread",
"(",
"image_path",
")",
"img",
"=",
"cv2",
".",
"cvtColor",
"(",
"img",
",",
"cv2",
".",
"COLOR_BGR2RGB",
")",
"return",
"img"
] | Import an image from the supplied path. | [
"Import",
"an",
"image",
"from",
"the",
"supplied",
"path",
"."
] | [
"\"\"\"Import an image from the supplied path.\n Returns the image name and the image.\n \"\"\"",
"#img_name = image_path.split('/')[-1].split('.')[0]"
] | [
{
"param": "image_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "image_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
d053f43220751a8b3d50320c9d08d3d15ed3707e | MarkDekker/CarND-Vehicle-Detection | utilityfun.py | [
"MIT"
] | Python | plot_image | null | def plot_image(img, title=''):
"""Plot the supplied image and the corresponding title."""
if len(img.shape) == 2:
plt.imshow(img, cmap='gray')
else:
plt.imshow(img)
plt.axis('off')
plt.title(title, fontsize=20) | Plot the supplied image and the corresponding title. | Plot the supplied image and the corresponding title. | [
"Plot",
"the",
"supplied",
"image",
"and",
"the",
"corresponding",
"title",
"."
] | def plot_image(img, title=''):
if len(img.shape) == 2:
plt.imshow(img, cmap='gray')
else:
plt.imshow(img)
plt.axis('off')
plt.title(title, fontsize=20) | [
"def",
"plot_image",
"(",
"img",
",",
"title",
"=",
"''",
")",
":",
"if",
"len",
"(",
"img",
".",
"shape",
")",
"==",
"2",
":",
"plt",
".",
"imshow",
"(",
"img",
",",
"cmap",
"=",
"'gray'",
")",
"else",
":",
"plt",
".",
"imshow",
"(",
"img",
... | Plot the supplied image and the corresponding title. | [
"Plot",
"the",
"supplied",
"image",
"and",
"the",
"corresponding",
"title",
"."
] | [
"\"\"\"Plot the supplied image and the corresponding title.\"\"\""
] | [
{
"param": "img",
"type": null
},
{
"param": "title",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "title",
"type": null,
"docstring": null,
"docstring_tokens": [... |
d053f43220751a8b3d50320c9d08d3d15ed3707e | MarkDekker/CarND-Vehicle-Detection | utilityfun.py | [
"MIT"
] | Python | compare_images | null | def compare_images(img_org, img_undist, titles=None):
"""Display an image comparison in a subplot."""
if titles is None:
titles = ('Image Before', 'Image After')
plt.subplots(1, 2, figsize=(10, 5), dpi=80)
plt.subplot(1, 2, 1)
plot_image(img_org, titles[0])
plt.subplot(1, 2, 2)
plot... | Display an image comparison in a subplot. | Display an image comparison in a subplot. | [
"Display",
"an",
"image",
"comparison",
"in",
"a",
"subplot",
"."
] | def compare_images(img_org, img_undist, titles=None):
if titles is None:
titles = ('Image Before', 'Image After')
plt.subplots(1, 2, figsize=(10, 5), dpi=80)
plt.subplot(1, 2, 1)
plot_image(img_org, titles[0])
plt.subplot(1, 2, 2)
plot_image(img_undist, titles[1]) | [
"def",
"compare_images",
"(",
"img_org",
",",
"img_undist",
",",
"titles",
"=",
"None",
")",
":",
"if",
"titles",
"is",
"None",
":",
"titles",
"=",
"(",
"'Image Before'",
",",
"'Image After'",
")",
"plt",
".",
"subplots",
"(",
"1",
",",
"2",
",",
"figs... | Display an image comparison in a subplot. | [
"Display",
"an",
"image",
"comparison",
"in",
"a",
"subplot",
"."
] | [
"\"\"\"Display an image comparison in a subplot.\"\"\""
] | [
{
"param": "img_org",
"type": null
},
{
"param": "img_undist",
"type": null
},
{
"param": "titles",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "img_org",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "img_undist",
"type": null,
"docstring": null,
"docstring_t... |
d053f43220751a8b3d50320c9d08d3d15ed3707e | MarkDekker/CarND-Vehicle-Detection | utilityfun.py | [
"MIT"
] | Python | overlay_image | <not_specific> | def overlay_image(img, overlay_img, opacity=1.0):
"""Reliably combine two images based on the opacity. Black pixels are
treated as transparent. The method also takes in a grayscale base image.
"""
if len(img.shape) < 3:
img = np.stack((img, img, img), axis=-1)
if len(overlay_img.shape) < 3:
... | Reliably combine two images based on the opacity. Black pixels are
treated as transparent. The method also takes in a grayscale base image.
| Reliably combine two images based on the opacity. Black pixels are
treated as transparent. The method also takes in a grayscale base image. | [
"Reliably",
"combine",
"two",
"images",
"based",
"on",
"the",
"opacity",
".",
"Black",
"pixels",
"are",
"treated",
"as",
"transparent",
".",
"The",
"method",
"also",
"takes",
"in",
"a",
"grayscale",
"base",
"image",
"."
] | def overlay_image(img, overlay_img, opacity=1.0):
if len(img.shape) < 3:
img = np.stack((img, img, img), axis=-1)
if len(overlay_img.shape) < 3:
overlay_img = np.stack((overlay_img, overlay_img, overlay_img), axis=-1)
img_out = np.zeros(img.shape)
overlay_img = (overlay_img * opacity).as... | [
"def",
"overlay_image",
"(",
"img",
",",
"overlay_img",
",",
"opacity",
"=",
"1.0",
")",
":",
"if",
"len",
"(",
"img",
".",
"shape",
")",
"<",
"3",
":",
"img",
"=",
"np",
".",
"stack",
"(",
"(",
"img",
",",
"img",
",",
"img",
")",
",",
"axis",
... | Reliably combine two images based on the opacity. | [
"Reliably",
"combine",
"two",
"images",
"based",
"on",
"the",
"opacity",
"."
] | [
"\"\"\"Reliably combine two images based on the opacity. Black pixels are\n treated as transparent. The method also takes in a grayscale base image.\n \"\"\""
] | [
{
"param": "img",
"type": null
},
{
"param": "overlay_img",
"type": null
},
{
"param": "opacity",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "overlay_img",
"type": null,
"docstring": null,
"docstring_toke... |
d053f43220751a8b3d50320c9d08d3d15ed3707e | MarkDekker/CarND-Vehicle-Detection | utilityfun.py | [
"MIT"
] | Python | quick_rectangle | <not_specific> | def quick_rectangle(img, corners, color='green', opacity=0.9,
thickness=4, filled=False):
"""Draws a rectangle on the input image."""
colors = {'green': (30, 255, 120),
'blue': (20, 104, 229),
'red': (224, 52, 0),
'orange': (252, 163, 9),
... | Draws a rectangle on the input image. | Draws a rectangle on the input image. | [
"Draws",
"a",
"rectangle",
"on",
"the",
"input",
"image",
"."
] | def quick_rectangle(img, corners, color='green', opacity=0.9,
thickness=4, filled=False):
colors = {'green': (30, 255, 120),
'blue': (20, 104, 229),
'red': (224, 52, 0),
'orange': (252, 163, 9),
'yellow': (252, 228, 10)}
if color.lower(... | [
"def",
"quick_rectangle",
"(",
"img",
",",
"corners",
",",
"color",
"=",
"'green'",
",",
"opacity",
"=",
"0.9",
",",
"thickness",
"=",
"4",
",",
"filled",
"=",
"False",
")",
":",
"colors",
"=",
"{",
"'green'",
":",
"(",
"30",
",",
"255",
",",
"120"... | Draws a rectangle on the input image. | [
"Draws",
"a",
"rectangle",
"on",
"the",
"input",
"image",
"."
] | [
"\"\"\"Draws a rectangle on the input image.\"\"\""
] | [
{
"param": "img",
"type": null
},
{
"param": "corners",
"type": null
},
{
"param": "color",
"type": null
},
{
"param": "opacity",
"type": null
},
{
"param": "thickness",
"type": null
},
{
"param": "filled",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "corners",
"type": null,
"docstring": null,
"docstring_tokens":... |
d053f43220751a8b3d50320c9d08d3d15ed3707e | MarkDekker/CarND-Vehicle-Detection | utilityfun.py | [
"MIT"
] | Python | save_image | null | def save_image(image, output_folder='./output_images/',
name='Current_Image', colorspace='RGB'):
"""Save image to a file."""
save_path = os.path.join(output_folder, name) + '.jpg'
if colorspace != 'BGR':
converter = getattr(cv2, "COLOR_" + colorspace + "2BGR")
image = cv2.cvt... | Save image to a file. | Save image to a file. | [
"Save",
"image",
"to",
"a",
"file",
"."
] | def save_image(image, output_folder='./output_images/',
name='Current_Image', colorspace='RGB'):
save_path = os.path.join(output_folder, name) + '.jpg'
if colorspace != 'BGR':
converter = getattr(cv2, "COLOR_" + colorspace + "2BGR")
image = cv2.cvtColor(image, converter)
cv2.i... | [
"def",
"save_image",
"(",
"image",
",",
"output_folder",
"=",
"'./output_images/'",
",",
"name",
"=",
"'Current_Image'",
",",
"colorspace",
"=",
"'RGB'",
")",
":",
"save_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"output_folder",
",",
"name",
")",
"+... | Save image to a file. | [
"Save",
"image",
"to",
"a",
"file",
"."
] | [
"\"\"\"Save image to a file.\"\"\""
] | [
{
"param": "image",
"type": null
},
{
"param": "output_folder",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "colorspace",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "image",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "output_folder",
"type": null,
"docstring": null,
"docstring_... |
eecde2964217eec5eb5ac435033c3ea0fea3c1ac | MarkDekker/CarND-Vehicle-Detection | carsearch.py | [
"MIT"
] | Python | update_image_analyser | <not_specific> | def update_image_analyser(self, img, window):
"""Update the image frames with the supplied image."""
if self.image_analyser is None:
raise ValueError('No image analyser object exists.')
else:
area_of_interest = self.search_areas[window['search_area']]
area_of_... | Update the image frames with the supplied image. | Update the image frames with the supplied image. | [
"Update",
"the",
"image",
"frames",
"with",
"the",
"supplied",
"image",
"."
] | def update_image_analyser(self, img, window):
if self.image_analyser is None:
raise ValueError('No image analyser object exists.')
else:
area_of_interest = self.search_areas[window['search_area']]
area_of_interest = self.convert_to_px(area_of_interest)
img... | [
"def",
"update_image_analyser",
"(",
"self",
",",
"img",
",",
"window",
")",
":",
"if",
"self",
".",
"image_analyser",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'No image analyser object exists.'",
")",
"else",
":",
"area_of_interest",
"=",
"self",
".",
... | Update the image frames with the supplied image. | [
"Update",
"the",
"image",
"frames",
"with",
"the",
"supplied",
"image",
"."
] | [
"\"\"\"Update the image frames with the supplied image.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "img",
"type": null
},
{
"param": "window",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": []... |
eecde2964217eec5eb5ac435033c3ea0fea3c1ac | MarkDekker/CarND-Vehicle-Detection | carsearch.py | [
"MIT"
] | Python | convert_to_px | <not_specific> | def convert_to_px(self, coordinates):
"""Converts coordinates expressed in cells to pixels."""
converted = []
for entry in coordinates:
if isinstance(entry, list) or isinstance(entry, tuple):
converted_entry = self.convert_to_px(entry)
else:
... | Converts coordinates expressed in cells to pixels. | Converts coordinates expressed in cells to pixels. | [
"Converts",
"coordinates",
"expressed",
"in",
"cells",
"to",
"pixels",
"."
] | def convert_to_px(self, coordinates):
converted = []
for entry in coordinates:
if isinstance(entry, list) or isinstance(entry, tuple):
converted_entry = self.convert_to_px(entry)
else:
converted_entry = entry * self.pix_in_cell
converte... | [
"def",
"convert_to_px",
"(",
"self",
",",
"coordinates",
")",
":",
"converted",
"=",
"[",
"]",
"for",
"entry",
"in",
"coordinates",
":",
"if",
"isinstance",
"(",
"entry",
",",
"list",
")",
"or",
"isinstance",
"(",
"entry",
",",
"tuple",
")",
":",
"conv... | Converts coordinates expressed in cells to pixels. | [
"Converts",
"coordinates",
"expressed",
"in",
"cells",
"to",
"pixels",
"."
] | [
"\"\"\"Converts coordinates expressed in cells to pixels.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "coordinates",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "coordinates",
"type": null,
"docstring": null,
"docstring_tok... |
eecde2964217eec5eb5ac435033c3ea0fea3c1ac | MarkDekker/CarND-Vehicle-Detection | carsearch.py | [
"MIT"
] | Python | sliding_search | <not_specific> | def sliding_search(self, img, classifier):
"""Returns a list of windows where a vehicle was found."""
windows_with_vehicles = []
analyser = self.image_analyser
for name, window in self.search_windows.items():
n_steps = self.get_nsteps(window)
self.update_image_an... | Returns a list of windows where a vehicle was found. | Returns a list of windows where a vehicle was found. | [
"Returns",
"a",
"list",
"of",
"windows",
"where",
"a",
"vehicle",
"was",
"found",
"."
] | def sliding_search(self, img, classifier):
windows_with_vehicles = []
analyser = self.image_analyser
for name, window in self.search_windows.items():
n_steps = self.get_nsteps(window)
self.update_image_analyser(img, window)
for step in range(n_steps):
... | [
"def",
"sliding_search",
"(",
"self",
",",
"img",
",",
"classifier",
")",
":",
"windows_with_vehicles",
"=",
"[",
"]",
"analyser",
"=",
"self",
".",
"image_analyser",
"for",
"name",
",",
"window",
"in",
"self",
".",
"search_windows",
".",
"items",
"(",
")"... | Returns a list of windows where a vehicle was found. | [
"Returns",
"a",
"list",
"of",
"windows",
"where",
"a",
"vehicle",
"was",
"found",
"."
] | [
"\"\"\"Returns a list of windows where a vehicle was found.\"\"\"",
"# current_window = (position, (position[0] + 8 * window['size'][0],",
"# position[1] + 8 * window['size'][1]))",
"# window_name = \"temp_\" + name + \"_\" + str(step)",
"# #save_image(self.get_area_of_interest(... | [
{
"param": "self",
"type": null
},
{
"param": "img",
"type": null
},
{
"param": "classifier",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": []... |
eecde2964217eec5eb5ac435033c3ea0fea3c1ac | MarkDekker/CarND-Vehicle-Detection | carsearch.py | [
"MIT"
] | Python | highlight_windows | <not_specific> | def highlight_windows(self, img, search_results, color='yellow'):
"""Draws a rectangle around windows in the search result."""
annotated_img = np.copy(img)
for result in search_results:
window = self.search_windows[result['window']]
window_dimensions = self.convert_to_px(... | Draws a rectangle around windows in the search result. | Draws a rectangle around windows in the search result. | [
"Draws",
"a",
"rectangle",
"around",
"windows",
"in",
"the",
"search",
"result",
"."
] | def highlight_windows(self, img, search_results, color='yellow'):
annotated_img = np.copy(img)
for result in search_results:
window = self.search_windows[result['window']]
window_dimensions = self.convert_to_px(window['size'])
width, height = (window_dimensions[0], wi... | [
"def",
"highlight_windows",
"(",
"self",
",",
"img",
",",
"search_results",
",",
"color",
"=",
"'yellow'",
")",
":",
"annotated_img",
"=",
"np",
".",
"copy",
"(",
"img",
")",
"for",
"result",
"in",
"search_results",
":",
"window",
"=",
"self",
".",
"sear... | Draws a rectangle around windows in the search result. | [
"Draws",
"a",
"rectangle",
"around",
"windows",
"in",
"the",
"search",
"result",
"."
] | [
"\"\"\"Draws a rectangle around windows in the search result.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "img",
"type": null
},
{
"param": "search_results",
"type": null
},
{
"param": "color",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "img",
"type": null,
"docstring": null,
"docstring_tokens": []... |
8c796cad12abd29b9ca9a3a4a889749e7ba6f262 | MarkDekker/CarND-Vehicle-Detection | carclassifier.py | [
"MIT"
] | Python | train | null | def train(self, features_train, labels_train, features_test,
labels_test):
"""Trains the classifier with the supplied training data."""
features_train = self.normalise(features_train)
features_test = self.normalise(features_test)
self.clf.fit(features_train, labels_train)
... | Trains the classifier with the supplied training data. | Trains the classifier with the supplied training data. | [
"Trains",
"the",
"classifier",
"with",
"the",
"supplied",
"training",
"data",
"."
] | def train(self, features_train, labels_train, features_test,
labels_test):
features_train = self.normalise(features_train)
features_test = self.normalise(features_test)
self.clf.fit(features_train, labels_train)
start = time.time()
test_set_accuracy = self.clf.score... | [
"def",
"train",
"(",
"self",
",",
"features_train",
",",
"labels_train",
",",
"features_test",
",",
"labels_test",
")",
":",
"features_train",
"=",
"self",
".",
"normalise",
"(",
"features_train",
")",
"features_test",
"=",
"self",
".",
"normalise",
"(",
"feat... | Trains the classifier with the supplied training data. | [
"Trains",
"the",
"classifier",
"with",
"the",
"supplied",
"training",
"data",
"."
] | [
"\"\"\"Trains the classifier with the supplied training data.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "features_train",
"type": null
},
{
"param": "labels_train",
"type": null
},
{
"param": "features_test",
"type": null
},
{
"param": "labels_test",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "features_train",
"type": null,
"docstring": null,
"docstring_... |
8c796cad12abd29b9ca9a3a4a889749e7ba6f262 | MarkDekker/CarND-Vehicle-Detection | carclassifier.py | [
"MIT"
] | Python | normalise | <not_specific> | def normalise(self, features):
"""Normalises the input feature set. """
if self.feature_scaler is None:
raise ValueError('The feature scaler has not yet been fit!')
else:
return self.feature_scaler.transform(features) | Normalises the input feature set. | Normalises the input feature set. | [
"Normalises",
"the",
"input",
"feature",
"set",
"."
] | def normalise(self, features):
if self.feature_scaler is None:
raise ValueError('The feature scaler has not yet been fit!')
else:
return self.feature_scaler.transform(features) | [
"def",
"normalise",
"(",
"self",
",",
"features",
")",
":",
"if",
"self",
".",
"feature_scaler",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'The feature scaler has not yet been fit!'",
")",
"else",
":",
"return",
"self",
".",
"feature_scaler",
".",
"transfo... | Normalises the input feature set. | [
"Normalises",
"the",
"input",
"feature",
"set",
"."
] | [
"\"\"\"Normalises the input feature set. \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "features",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "features",
"type": null,
"docstring": null,
"docstring_tokens... |
8c796cad12abd29b9ca9a3a4a889749e7ba6f262 | MarkDekker/CarND-Vehicle-Detection | carclassifier.py | [
"MIT"
] | Python | fit_feature_scaler | null | def fit_feature_scaler(self, training_features):
"""Fit a feature scaler to the training data to easily normalise inputs
later.
"""
self.feature_scaler = StandardScaler().fit(training_features) | Fit a feature scaler to the training data to easily normalise inputs
later.
| Fit a feature scaler to the training data to easily normalise inputs
later. | [
"Fit",
"a",
"feature",
"scaler",
"to",
"the",
"training",
"data",
"to",
"easily",
"normalise",
"inputs",
"later",
"."
] | def fit_feature_scaler(self, training_features):
self.feature_scaler = StandardScaler().fit(training_features) | [
"def",
"fit_feature_scaler",
"(",
"self",
",",
"training_features",
")",
":",
"self",
".",
"feature_scaler",
"=",
"StandardScaler",
"(",
")",
".",
"fit",
"(",
"training_features",
")"
] | Fit a feature scaler to the training data to easily normalise inputs
later. | [
"Fit",
"a",
"feature",
"scaler",
"to",
"the",
"training",
"data",
"to",
"easily",
"normalise",
"inputs",
"later",
"."
] | [
"\"\"\"Fit a feature scaler to the training data to easily normalise inputs\n later.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "training_features",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "training_features",
"type": null,
"docstring": null,
"docstri... |
8c796cad12abd29b9ca9a3a4a889749e7ba6f262 | MarkDekker/CarND-Vehicle-Detection | carclassifier.py | [
"MIT"
] | Python | svm | <not_specific> | def svm(cls, params=None):
"""Set up a support vector machine classifier."""
if params is None:
params = {'C': 1.0,
'kernel': 'rbf',
'max_iter': -1}
return cls(SVC(**params)) | Set up a support vector machine classifier. | Set up a support vector machine classifier. | [
"Set",
"up",
"a",
"support",
"vector",
"machine",
"classifier",
"."
] | def svm(cls, params=None):
if params is None:
params = {'C': 1.0,
'kernel': 'rbf',
'max_iter': -1}
return cls(SVC(**params)) | [
"def",
"svm",
"(",
"cls",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"'C'",
":",
"1.0",
",",
"'kernel'",
":",
"'rbf'",
",",
"'max_iter'",
":",
"-",
"1",
"}",
"return",
"cls",
"(",
"SVC",
"(",
"*... | Set up a support vector machine classifier. | [
"Set",
"up",
"a",
"support",
"vector",
"machine",
"classifier",
"."
] | [
"\"\"\"Set up a support vector machine classifier.\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "params",
"type": null,
"docstring": null,
"docstring_tokens": ... |
8c796cad12abd29b9ca9a3a4a889749e7ba6f262 | MarkDekker/CarND-Vehicle-Detection | carclassifier.py | [
"MIT"
] | Python | svm_linear | <not_specific> | def svm_linear(cls, params=None):
"""Set up a linear support vector machine classifier."""
if params is None:
params = {'C': 1.0,
'dual': True}
return cls(LinearSVC(**params)) | Set up a linear support vector machine classifier. | Set up a linear support vector machine classifier. | [
"Set",
"up",
"a",
"linear",
"support",
"vector",
"machine",
"classifier",
"."
] | def svm_linear(cls, params=None):
if params is None:
params = {'C': 1.0,
'dual': True}
return cls(LinearSVC(**params)) | [
"def",
"svm_linear",
"(",
"cls",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
"is",
"None",
":",
"params",
"=",
"{",
"'C'",
":",
"1.0",
",",
"'dual'",
":",
"True",
"}",
"return",
"cls",
"(",
"LinearSVC",
"(",
"**",
"params",
")",
")"
] | Set up a linear support vector machine classifier. | [
"Set",
"up",
"a",
"linear",
"support",
"vector",
"machine",
"classifier",
"."
] | [
"\"\"\"Set up a linear support vector machine classifier.\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "params",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "params",
"type": null,
"docstring": null,
"docstring_tokens": ... |
4ad901a8298b809d5587744663b504bab793a514 | jireh-father/SipMask | SipMask-benchmark/fcos_core/modeling/rpn/sipmask/loss.py | [
"MIT"
] | Python | bbox_overlaps | <not_specific> | def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False):
"""Calculate overlap between two set of bboxes.
If ``is_aligned`` is ``False``, then calculate the ious between each bbox
of bboxes1 and bboxes2, otherwise the ious between each aligned pair of
bboxes1 and bboxes2.
Args:
bb... | Calculate overlap between two set of bboxes.
If ``is_aligned`` is ``False``, then calculate the ious between each bbox
of bboxes1 and bboxes2, otherwise the ious between each aligned pair of
bboxes1 and bboxes2.
Args:
bboxes1 (Tensor): shape (m, 4)
bboxes2 (Tensor): shape (n, 4), if is... | Calculate overlap between two set of bboxes. | [
"Calculate",
"overlap",
"between",
"two",
"set",
"of",
"bboxes",
"."
] | def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False):
assert mode in ['iou', 'iof']
rows = bboxes1.size(0)
cols = bboxes2.size(0)
if is_aligned:
assert rows == cols
if rows * cols == 0:
return bboxes1.new(rows, 1) if is_aligned else bboxes1.new(rows, cols)
if is_alig... | [
"def",
"bbox_overlaps",
"(",
"bboxes1",
",",
"bboxes2",
",",
"mode",
"=",
"'iou'",
",",
"is_aligned",
"=",
"False",
")",
":",
"assert",
"mode",
"in",
"[",
"'iou'",
",",
"'iof'",
"]",
"rows",
"=",
"bboxes1",
".",
"size",
"(",
"0",
")",
"cols",
"=",
... | Calculate overlap between two set of bboxes. | [
"Calculate",
"overlap",
"between",
"two",
"set",
"of",
"bboxes",
"."
] | [
"\"\"\"Calculate overlap between two set of bboxes.\n\n If ``is_aligned`` is ``False``, then calculate the ious between each bbox\n of bboxes1 and bboxes2, otherwise the ious between each aligned pair of\n bboxes1 and bboxes2.\n\n Args:\n bboxes1 (Tensor): shape (m, 4)\n bboxes2 (Tensor): ... | [
{
"param": "bboxes1",
"type": null
},
{
"param": "bboxes2",
"type": null
},
{
"param": "mode",
"type": null
},
{
"param": "is_aligned",
"type": null
}
] | {
"returns": [
{
"docstring": "shape (m, n) if is_aligned == False else shape (m, 1)",
"docstring_tokens": [
"shape",
"(",
"m",
"n",
")",
"if",
"is_aligned",
"==",
"False",
"else",
"shape",
"(",
"m"... |
4ad901a8298b809d5587744663b504bab793a514 | jireh-father/SipMask | SipMask-benchmark/fcos_core/modeling/rpn/sipmask/loss.py | [
"MIT"
] | Python | center_size | <not_specific> | def center_size(boxes):
""" Convert prior_boxes to (cx, cy, w, h)
representation for comparison to center-size form ground truth data.
Args:
boxes: (tensor) point_form boxes
Return:
boxes: (tensor) Converted xmin, ymin, xmax, ymax form of boxes.
"""
return torch.cat(( (boxes[:, 2... | Convert prior_boxes to (cx, cy, w, h)
representation for comparison to center-size form ground truth data.
Args:
boxes: (tensor) point_form boxes
Return:
boxes: (tensor) Converted xmin, ymin, xmax, ymax form of boxes.
| Convert prior_boxes to (cx, cy, w, h)
representation for comparison to center-size form ground truth data. | [
"Convert",
"prior_boxes",
"to",
"(",
"cx",
"cy",
"w",
"h",
")",
"representation",
"for",
"comparison",
"to",
"center",
"-",
"size",
"form",
"ground",
"truth",
"data",
"."
] | def center_size(boxes):
return torch.cat(( (boxes[:, 2:] + boxes[:, :2])/2,
boxes[:, 2:] - boxes[:, :2] ), 1) | [
"def",
"center_size",
"(",
"boxes",
")",
":",
"return",
"torch",
".",
"cat",
"(",
"(",
"(",
"boxes",
"[",
":",
",",
"2",
":",
"]",
"+",
"boxes",
"[",
":",
",",
":",
"2",
"]",
")",
"/",
"2",
",",
"boxes",
"[",
":",
",",
"2",
":",
"]",
"-",... | Convert prior_boxes to (cx, cy, w, h)
representation for comparison to center-size form ground truth data. | [
"Convert",
"prior_boxes",
"to",
"(",
"cx",
"cy",
"w",
"h",
")",
"representation",
"for",
"comparison",
"to",
"center",
"-",
"size",
"form",
"ground",
"truth",
"data",
"."
] | [
"\"\"\" Convert prior_boxes to (cx, cy, w, h)\n representation for comparison to center-size form ground truth data.\n Args:\n boxes: (tensor) point_form boxes\n Return:\n boxes: (tensor) Converted xmin, ymin, xmax, ymax form of boxes.\n \"\"\"",
"# cx, cy"
] | [
{
"param": "boxes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "boxes",
"type": null,
"docstring": "(tensor) point_form boxes",
"docstring_tokens": [
"(",
"tensor",
")",
"point_form",
"boxes"
],
"default": null,
"is_optional": null
... |
f5f1b4a581ce8833659317afb146bb0177e46908 | jireh-father/SipMask | SipMask-VIS/mmdet/models/anchor_heads/sipmask_head.py | [
"MIT"
] | Python | crop_split | <not_specific> | def crop_split(masks00, masks01, masks10, masks11, boxes, masksG=None):
"""
"Crop" predicted masks by zeroing out everything not in the predicted bbox.
Vectorized by Chong (thanks Chong).
Args:
- masks should be a size [h, w, n] tensor of masks
- boxes should be a size [n, 4] tensor of ... |
"Crop" predicted masks by zeroing out everything not in the predicted bbox.
Vectorized by Chong (thanks Chong).
Args:
- masks should be a size [h, w, n] tensor of masks
- boxes should be a size [n, 4] tensor of bbox coords in relative point form
| "Crop" predicted masks by zeroing out everything not in the predicted bbox.
Vectorized by Chong (thanks Chong).
masks should be a size [h, w, n] tensor of masks
boxes should be a size [n, 4] tensor of bbox coords in relative point form | [
"\"",
"Crop",
"\"",
"predicted",
"masks",
"by",
"zeroing",
"out",
"everything",
"not",
"in",
"the",
"predicted",
"bbox",
".",
"Vectorized",
"by",
"Chong",
"(",
"thanks",
"Chong",
")",
".",
"masks",
"should",
"be",
"a",
"size",
"[",
"h",
"w",
"n",
"]",
... | def crop_split(masks00, masks01, masks10, masks11, boxes, masksG=None):
h, w, n = masks00.size()
rows = torch.arange(w, device=masks00.device, dtype=boxes.dtype).view(1, -1, 1).expand(h, w, n)
cols = torch.arange(h, device=masks00.device, dtype=boxes.dtype).view(-1, 1, 1).expand(h, w, n)
x1, x2 = boxes[... | [
"def",
"crop_split",
"(",
"masks00",
",",
"masks01",
",",
"masks10",
",",
"masks11",
",",
"boxes",
",",
"masksG",
"=",
"None",
")",
":",
"h",
",",
"w",
",",
"n",
"=",
"masks00",
".",
"size",
"(",
")",
"rows",
"=",
"torch",
".",
"arange",
"(",
"w"... | "Crop" predicted masks by zeroing out everything not in the predicted bbox. | [
"\"",
"Crop",
"\"",
"predicted",
"masks",
"by",
"zeroing",
"out",
"everything",
"not",
"in",
"the",
"predicted",
"bbox",
"."
] | [
"\"\"\"\n \"Crop\" predicted masks by zeroing out everything not in the predicted bbox.\n Vectorized by Chong (thanks Chong).\n\n Args:\n - masks should be a size [h, w, n] tensor of masks\n - boxes should be a size [n, 4] tensor of bbox coords in relative point form\n \"\"\"",
"# saniti... | [
{
"param": "masks00",
"type": null
},
{
"param": "masks01",
"type": null
},
{
"param": "masks10",
"type": null
},
{
"param": "masks11",
"type": null
},
{
"param": "boxes",
"type": null
},
{
"param": "masksG",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "masks00",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "masks01",
"type": null,
"docstring": null,
"docstring_toke... |
a333395a92ecbb6d9b466c338d967ae3cefc4e40 | JN513/hub | tensorflow_hub/compressed_module_resolver.py | [
"Apache-2.0"
] | Python | _module_dir | <not_specific> | def _module_dir(handle):
"""Returns the directory where to cache the module."""
cache_dir = resolver.tfhub_cache_dir(use_temp=True)
return resolver.create_local_module_dir(
cache_dir,
hashlib.sha1(handle.encode("utf8")).hexdigest()) | Returns the directory where to cache the module. | Returns the directory where to cache the module. | [
"Returns",
"the",
"directory",
"where",
"to",
"cache",
"the",
"module",
"."
] | def _module_dir(handle):
cache_dir = resolver.tfhub_cache_dir(use_temp=True)
return resolver.create_local_module_dir(
cache_dir,
hashlib.sha1(handle.encode("utf8")).hexdigest()) | [
"def",
"_module_dir",
"(",
"handle",
")",
":",
"cache_dir",
"=",
"resolver",
".",
"tfhub_cache_dir",
"(",
"use_temp",
"=",
"True",
")",
"return",
"resolver",
".",
"create_local_module_dir",
"(",
"cache_dir",
",",
"hashlib",
".",
"sha1",
"(",
"handle",
".",
"... | Returns the directory where to cache the module. | [
"Returns",
"the",
"directory",
"where",
"to",
"cache",
"the",
"module",
"."
] | [
"\"\"\"Returns the directory where to cache the module.\"\"\""
] | [
{
"param": "handle",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a333395a92ecbb6d9b466c338d967ae3cefc4e40 | JN513/hub | tensorflow_hub/compressed_module_resolver.py | [
"Apache-2.0"
] | Python | download | <not_specific> | def download(handle, tmp_dir):
"""Fetch a module via HTTP(S), handling redirect and download headers."""
request = urllib.request.Request(_append_compressed_format_query(handle))
response = self._call_urlopen(request)
return resolver.DownloadManager(handle).download_and_uncompress(
res... | Fetch a module via HTTP(S), handling redirect and download headers. | Fetch a module via HTTP(S), handling redirect and download headers. | [
"Fetch",
"a",
"module",
"via",
"HTTP",
"(",
"S",
")",
"handling",
"redirect",
"and",
"download",
"headers",
"."
] | def download(handle, tmp_dir):
request = urllib.request.Request(_append_compressed_format_query(handle))
response = self._call_urlopen(request)
return resolver.DownloadManager(handle).download_and_uncompress(
response, tmp_dir) | [
"def",
"download",
"(",
"handle",
",",
"tmp_dir",
")",
":",
"request",
"=",
"urllib",
".",
"request",
".",
"Request",
"(",
"_append_compressed_format_query",
"(",
"handle",
")",
")",
"response",
"=",
"self",
".",
"_call_urlopen",
"(",
"request",
")",
"return... | Fetch a module via HTTP(S), handling redirect and download headers. | [
"Fetch",
"a",
"module",
"via",
"HTTP",
"(",
"S",
")",
"handling",
"redirect",
"and",
"download",
"headers",
"."
] | [
"\"\"\"Fetch a module via HTTP(S), handling redirect and download headers.\"\"\""
] | [
{
"param": "handle",
"type": null
},
{
"param": "tmp_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "handle",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tmp_dir",
"type": null,
"docstring": null,
"docstring_token... |
2d5113556bf0eaa41a48d167a8de70ed92a3c2af | eshanMewantha/natural-language-processing | text-clustering/text_clustering.py | [
"MIT"
] | Python | process_text | <not_specific> | def process_text(text, stem=True):
""" Tokenize text and stem words removing punctuation """
text = text.translate(string.punctuation)
tokens = word_tokenize(text)
if stem:
stemmer = PorterStemmer()
tokens = [stemmer.stem(t) for t in tokens]
return tokens | Tokenize text and stem words removing punctuation | Tokenize text and stem words removing punctuation | [
"Tokenize",
"text",
"and",
"stem",
"words",
"removing",
"punctuation"
] | def process_text(text, stem=True):
text = text.translate(string.punctuation)
tokens = word_tokenize(text)
if stem:
stemmer = PorterStemmer()
tokens = [stemmer.stem(t) for t in tokens]
return tokens | [
"def",
"process_text",
"(",
"text",
",",
"stem",
"=",
"True",
")",
":",
"text",
"=",
"text",
".",
"translate",
"(",
"string",
".",
"punctuation",
")",
"tokens",
"=",
"word_tokenize",
"(",
"text",
")",
"if",
"stem",
":",
"stemmer",
"=",
"PorterStemmer",
... | Tokenize text and stem words removing punctuation | [
"Tokenize",
"text",
"and",
"stem",
"words",
"removing",
"punctuation"
] | [
"\"\"\" Tokenize text and stem words removing punctuation \"\"\""
] | [
{
"param": "text",
"type": null
},
{
"param": "stem",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stem",
"type": null,
"docstring": null,
"docstring_tokens": [... |
2d5113556bf0eaa41a48d167a8de70ed92a3c2af | eshanMewantha/natural-language-processing | text-clustering/text_clustering.py | [
"MIT"
] | Python | cluster_texts | <not_specific> | def cluster_texts(texts, clusters=3):
""" Transform texts to Tf-Idf coordinates and cluster texts using K-Means """
vectorizer = TfidfVectorizer(tokenizer=process_text,
stop_words=stopwords.words('english'),
max_df=0.5,
... | Transform texts to Tf-Idf coordinates and cluster texts using K-Means | Transform texts to Tf-Idf coordinates and cluster texts using K-Means | [
"Transform",
"texts",
"to",
"Tf",
"-",
"Idf",
"coordinates",
"and",
"cluster",
"texts",
"using",
"K",
"-",
"Means"
] | def cluster_texts(texts, clusters=3):
vectorizer = TfidfVectorizer(tokenizer=process_text,
stop_words=stopwords.words('english'),
max_df=0.5,
min_df=0.1,
lowercase=True)
tfidf_mode... | [
"def",
"cluster_texts",
"(",
"texts",
",",
"clusters",
"=",
"3",
")",
":",
"vectorizer",
"=",
"TfidfVectorizer",
"(",
"tokenizer",
"=",
"process_text",
",",
"stop_words",
"=",
"stopwords",
".",
"words",
"(",
"'english'",
")",
",",
"max_df",
"=",
"0.5",
","... | Transform texts to Tf-Idf coordinates and cluster texts using K-Means | [
"Transform",
"texts",
"to",
"Tf",
"-",
"Idf",
"coordinates",
"and",
"cluster",
"texts",
"using",
"K",
"-",
"Means"
] | [
"\"\"\" Transform texts to Tf-Idf coordinates and cluster texts using K-Means \"\"\""
] | [
{
"param": "texts",
"type": null
},
{
"param": "clusters",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "texts",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "clusters",
"type": null,
"docstring": null,
"docstring_token... |
a05af8cf155c35c46fc91e51b96e1b5e710a397d | victorjambo/WeConnect | versions/v2/business.py | [
"MIT"
] | Python | precheck | <not_specific> | def precheck(f):
"""Checks if businessID is available
Check if business belongs to current user
"""
@wraps(f)
def wrap(*args, **kwargs):
business = get_in_module('business', kwargs['businessId'])
if not business:
return jsonify({'warning': 'Business Not Found'}), 404
... | Checks if businessID is available
Check if business belongs to current user
| Checks if businessID is available
Check if business belongs to current user | [
"Checks",
"if",
"businessID",
"is",
"available",
"Check",
"if",
"business",
"belongs",
"to",
"current",
"user"
] | def precheck(f):
@wraps(f)
def wrap(*args, **kwargs):
business = get_in_module('business', kwargs['businessId'])
if not business:
return jsonify({'warning': 'Business Not Found'}), 404
if args[0] != business.owner.id:
return jsonify({'warning': 'Not Allowed, you a... | [
"def",
"precheck",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrap",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"business",
"=",
"get_in_module",
"(",
"'business'",
",",
"kwargs",
"[",
"'businessId'",
"]",
")",
"if",
"not",
"bus... | Checks if businessID is available
Check if business belongs to current user | [
"Checks",
"if",
"businessID",
"is",
"available",
"Check",
"if",
"business",
"belongs",
"to",
"current",
"user"
] | [
"\"\"\"Checks if businessID is available\n Check if business belongs to current user\n \"\"\""
] | [
{
"param": "f",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "f",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a05af8cf155c35c46fc91e51b96e1b5e710a397d | victorjambo/WeConnect | versions/v2/business.py | [
"MIT"
] | Python | read_all_businesses | <not_specific> | def read_all_businesses():
"""Reads all Businesses
user can search for business via business name
response is paginated per limit
"""
params = {
'page': request.args.get('page', default=1, type=int),
'limit': request.args.get('limit', default=5, type=int),
'location': request... | Reads all Businesses
user can search for business via business name
response is paginated per limit
| Reads all Businesses
user can search for business via business name
response is paginated per limit | [
"Reads",
"all",
"Businesses",
"user",
"can",
"search",
"for",
"business",
"via",
"business",
"name",
"response",
"is",
"paginated",
"per",
"limit"
] | def read_all_businesses():
params = {
'page': request.args.get('page', default=1, type=int),
'limit': request.args.get('limit', default=5, type=int),
'location': request.args.get('location', default=None, type=str),
'category': request.args.get('category', default=None, type=str),
... | [
"def",
"read_all_businesses",
"(",
")",
":",
"params",
"=",
"{",
"'page'",
":",
"request",
".",
"args",
".",
"get",
"(",
"'page'",
",",
"default",
"=",
"1",
",",
"type",
"=",
"int",
")",
",",
"'limit'",
":",
"request",
".",
"args",
".",
"get",
"(",... | Reads all Businesses
user can search for business via business name
response is paginated per limit | [
"Reads",
"all",
"Businesses",
"user",
"can",
"search",
"for",
"business",
"via",
"business",
"name",
"response",
"is",
"paginated",
"per",
"limit"
] | [
"\"\"\"Reads all Businesses\n user can search for business via business name\n response is paginated per limit\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a05af8cf155c35c46fc91e51b96e1b5e710a397d | victorjambo/WeConnect | versions/v2/business.py | [
"MIT"
] | Python | create_business | <not_specific> | def create_business(current_user):
"""Creates a business
Takes current_user ID and update data
test if actually saved
"""
data = request.get_json()
# Check if there is an existing business with same name
if existing_module('business', data['name']):
return jsonify({
'war... | Creates a business
Takes current_user ID and update data
test if actually saved
| Creates a business
Takes current_user ID and update data
test if actually saved | [
"Creates",
"a",
"business",
"Takes",
"current_user",
"ID",
"and",
"update",
"data",
"test",
"if",
"actually",
"saved"
] | def create_business(current_user):
data = request.get_json()
if existing_module('business', data['name']):
return jsonify({
'warning': 'Business name {} already taken'.format(data['name'])
}), 409
business_owner = get_in_module('user', current_user)
new_business = Business(
... | [
"def",
"create_business",
"(",
"current_user",
")",
":",
"data",
"=",
"request",
".",
"get_json",
"(",
")",
"if",
"existing_module",
"(",
"'business'",
",",
"data",
"[",
"'name'",
"]",
")",
":",
"return",
"jsonify",
"(",
"{",
"'warning'",
":",
"'Business n... | Creates a business
Takes current_user ID and update data
test if actually saved | [
"Creates",
"a",
"business",
"Takes",
"current_user",
"ID",
"and",
"update",
"data",
"test",
"if",
"actually",
"saved"
] | [
"\"\"\"Creates a business\n Takes current_user ID and update data\n test if actually saved\n \"\"\"",
"# Check if there is an existing business with same name",
"# create new business instances",
"# Commit changes to db",
"# Send response if business was saved"
] | [
{
"param": "current_user",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "current_user",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a05af8cf155c35c46fc91e51b96e1b5e710a397d | victorjambo/WeConnect | versions/v2/business.py | [
"MIT"
] | Python | read_business | <not_specific> | def read_business(businessId):
"""Reads Business given a business id"""
business = get_in_module('business', businessId)
if business:
return jsonify({
'business': {
'id': business.id,
'name': business.name,
'logo': business.logo,
... | Reads Business given a business id | Reads Business given a business id | [
"Reads",
"Business",
"given",
"a",
"business",
"id"
] | def read_business(businessId):
business = get_in_module('business', businessId)
if business:
return jsonify({
'business': {
'id': business.id,
'name': business.name,
'logo': business.logo,
'location': business.location,
... | [
"def",
"read_business",
"(",
"businessId",
")",
":",
"business",
"=",
"get_in_module",
"(",
"'business'",
",",
"businessId",
")",
"if",
"business",
":",
"return",
"jsonify",
"(",
"{",
"'business'",
":",
"{",
"'id'",
":",
"business",
".",
"id",
",",
"'name'... | Reads Business given a business id | [
"Reads",
"Business",
"given",
"a",
"business",
"id"
] | [
"\"\"\"Reads Business given a business id\"\"\""
] | [
{
"param": "businessId",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "businessId",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a05af8cf155c35c46fc91e51b96e1b5e710a397d | victorjambo/WeConnect | versions/v2/business.py | [
"MIT"
] | Python | update_business | <not_specific> | def update_business(current_user, businessId):
"""Updates a business given a business ID
confirms if current user is owner of business
"""
data = request.get_json()
business = get_in_module('business', businessId)
business.name = data['name']
business.logo = data['logo']
business.locati... | Updates a business given a business ID
confirms if current user is owner of business
| Updates a business given a business ID
confirms if current user is owner of business | [
"Updates",
"a",
"business",
"given",
"a",
"business",
"ID",
"confirms",
"if",
"current",
"user",
"is",
"owner",
"of",
"business"
] | def update_business(current_user, businessId):
data = request.get_json()
business = get_in_module('business', businessId)
business.name = data['name']
business.logo = data['logo']
business.location = data['location']
business.category = data['category']
business.bio = data['bio']
busines... | [
"def",
"update_business",
"(",
"current_user",
",",
"businessId",
")",
":",
"data",
"=",
"request",
".",
"get_json",
"(",
")",
"business",
"=",
"get_in_module",
"(",
"'business'",
",",
"businessId",
")",
"business",
".",
"name",
"=",
"data",
"[",
"'name'",
... | Updates a business given a business ID
confirms if current user is owner of business | [
"Updates",
"a",
"business",
"given",
"a",
"business",
"ID",
"confirms",
"if",
"current",
"user",
"is",
"owner",
"of",
"business"
] | [
"\"\"\"Updates a business given a business ID\n confirms if current user is owner of business\n \"\"\""
] | [
{
"param": "current_user",
"type": null
},
{
"param": "businessId",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "current_user",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "businessId",
"type": null,
"docstring": null,
"docstr... |
a05af8cf155c35c46fc91e51b96e1b5e710a397d | victorjambo/WeConnect | versions/v2/business.py | [
"MIT"
] | Python | delete_business | <not_specific> | def delete_business(current_user, businessId):
"""Deletes a business
confirms if current user is owner of business
"""
business = get_in_module('business', businessId)
name = business.name
business.delete()
if not existing_module('business', name):
return jsonify({'success': 'Busine... | Deletes a business
confirms if current user is owner of business
| Deletes a business
confirms if current user is owner of business | [
"Deletes",
"a",
"business",
"confirms",
"if",
"current",
"user",
"is",
"owner",
"of",
"business"
] | def delete_business(current_user, businessId):
business = get_in_module('business', businessId)
name = business.name
business.delete()
if not existing_module('business', name):
return jsonify({'success': 'Business Deleted'}), 200
return jsonify({'warning': 'Business Not Deleted'}), 400 | [
"def",
"delete_business",
"(",
"current_user",
",",
"businessId",
")",
":",
"business",
"=",
"get_in_module",
"(",
"'business'",
",",
"businessId",
")",
"name",
"=",
"business",
".",
"name",
"business",
".",
"delete",
"(",
")",
"if",
"not",
"existing_module",
... | Deletes a business
confirms if current user is owner of business | [
"Deletes",
"a",
"business",
"confirms",
"if",
"current",
"user",
"is",
"owner",
"of",
"business"
] | [
"\"\"\"Deletes a business\n confirms if current user is owner of business\n \"\"\""
] | [
{
"param": "current_user",
"type": null
},
{
"param": "businessId",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "current_user",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "businessId",
"type": null,
"docstring": null,
"docstr... |
26b44fd5d30c50640fc3b846af6e10314e971d4b | victorjambo/WeConnect | versions/v2/review.py | [
"MIT"
] | Python | precheck | <not_specific> | def precheck(f):
"""Checks if businessID is available
Check if business belongs to current user
"""
@wraps(f)
def wrap(*args, **kwargs):
business = Business.query.get(kwargs['businessId'])
review = Review.query.get(kwargs['reviewId'])
if not business:
return json... | Checks if businessID is available
Check if business belongs to current user
| Checks if businessID is available
Check if business belongs to current user | [
"Checks",
"if",
"businessID",
"is",
"available",
"Check",
"if",
"business",
"belongs",
"to",
"current",
"user"
] | def precheck(f):
@wraps(f)
def wrap(*args, **kwargs):
business = Business.query.get(kwargs['businessId'])
review = Review.query.get(kwargs['reviewId'])
if not business:
return jsonify({'warning': 'Business Not Found'}), 404
if not review:
return jsonify({'... | [
"def",
"precheck",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrap",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"business",
"=",
"Business",
".",
"query",
".",
"get",
"(",
"kwargs",
"[",
"'businessId'",
"]",
")",
"review",
"="... | Checks if businessID is available
Check if business belongs to current user | [
"Checks",
"if",
"businessID",
"is",
"available",
"Check",
"if",
"business",
"belongs",
"to",
"current",
"user"
] | [
"\"\"\"Checks if businessID is available\n Check if business belongs to current user\n \"\"\""
] | [
{
"param": "f",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "f",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
26b44fd5d30c50640fc3b846af6e10314e971d4b | victorjambo/WeConnect | versions/v2/review.py | [
"MIT"
] | Python | create_review | <not_specific> | def create_review(current_user, businessId):
"""Create Review given a business ID
Takes current user ID and business ID then attachs it to response data
"""
data = request.get_json()
_reviewer = User.query.get(current_user)
_business = Business.query.get(businessId)
if not _business:
... | Create Review given a business ID
Takes current user ID and business ID then attachs it to response data
| Create Review given a business ID
Takes current user ID and business ID then attachs it to response data | [
"Create",
"Review",
"given",
"a",
"business",
"ID",
"Takes",
"current",
"user",
"ID",
"and",
"business",
"ID",
"then",
"attachs",
"it",
"to",
"response",
"data"
] | def create_review(current_user, businessId):
data = request.get_json()
_reviewer = User.query.get(current_user)
_business = Business.query.get(businessId)
if not _business:
return jsonify({'warning': 'Business Not Found'}), 404
new_review = Review(
title=data['title'],
desc=d... | [
"def",
"create_review",
"(",
"current_user",
",",
"businessId",
")",
":",
"data",
"=",
"request",
".",
"get_json",
"(",
")",
"_reviewer",
"=",
"User",
".",
"query",
".",
"get",
"(",
"current_user",
")",
"_business",
"=",
"Business",
".",
"query",
".",
"g... | Create Review given a business ID
Takes current user ID and business ID then attachs it to response data | [
"Create",
"Review",
"given",
"a",
"business",
"ID",
"Takes",
"current",
"user",
"ID",
"and",
"business",
"ID",
"then",
"attachs",
"it",
"to",
"response",
"data"
] | [
"\"\"\"Create Review given a business ID\n Takes current user ID and business ID then attachs it to response data\n \"\"\"",
"# create new review instances",
"# Commit changes to db",
"# Send response if business was saved",
"# create a notification if review is created"
] | [
{
"param": "current_user",
"type": null
},
{
"param": "businessId",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "current_user",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "businessId",
"type": null,
"docstring": null,
"docstr... |
26b44fd5d30c50640fc3b846af6e10314e971d4b | victorjambo/WeConnect | versions/v2/review.py | [
"MIT"
] | Python | read_review | <not_specific> | def read_review(businessId):
"""Reads all Review given a business ID"""
business = Business.query.get(businessId)
if not business:
return jsonify({'warning': 'Business Not Found'}), 404
if business.reviews:
return jsonify({'reviews': [
{
'id': review.id,
... | Reads all Review given a business ID | Reads all Review given a business ID | [
"Reads",
"all",
"Review",
"given",
"a",
"business",
"ID"
] | def read_review(businessId):
business = Business.query.get(businessId)
if not business:
return jsonify({'warning': 'Business Not Found'}), 404
if business.reviews:
return jsonify({'reviews': [
{
'id': review.id,
'title': review.title,
... | [
"def",
"read_review",
"(",
"businessId",
")",
":",
"business",
"=",
"Business",
".",
"query",
".",
"get",
"(",
"businessId",
")",
"if",
"not",
"business",
":",
"return",
"jsonify",
"(",
"{",
"'warning'",
":",
"'Business Not Found'",
"}",
")",
",",
"404",
... | Reads all Review given a business ID | [
"Reads",
"all",
"Review",
"given",
"a",
"business",
"ID"
] | [
"\"\"\"Reads all Review given a business ID\"\"\""
] | [
{
"param": "businessId",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "businessId",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
26b44fd5d30c50640fc3b846af6e10314e971d4b | victorjambo/WeConnect | versions/v2/review.py | [
"MIT"
] | Python | delete_review | <not_specific> | def delete_review(current_user, businessId, reviewId):
"""Delete a Review given a review ID and business ID
confirms if current_user is owner of review
"""
title = ''
review = Review.query.get(reviewId)
if review:
title = review.title
review.delete()
if not db.session.query(... | Delete a Review given a review ID and business ID
confirms if current_user is owner of review
| Delete a Review given a review ID and business ID
confirms if current_user is owner of review | [
"Delete",
"a",
"Review",
"given",
"a",
"review",
"ID",
"and",
"business",
"ID",
"confirms",
"if",
"current_user",
"is",
"owner",
"of",
"review"
] | def delete_review(current_user, businessId, reviewId):
title = ''
review = Review.query.get(reviewId)
if review:
title = review.title
review.delete()
if not db.session.query(
db.exists().where(Review.title == title)
).scalar():
return jsonify({'success': 'Review Delet... | [
"def",
"delete_review",
"(",
"current_user",
",",
"businessId",
",",
"reviewId",
")",
":",
"title",
"=",
"''",
"review",
"=",
"Review",
".",
"query",
".",
"get",
"(",
"reviewId",
")",
"if",
"review",
":",
"title",
"=",
"review",
".",
"title",
"review",
... | Delete a Review given a review ID and business ID
confirms if current_user is owner of review | [
"Delete",
"a",
"Review",
"given",
"a",
"review",
"ID",
"and",
"business",
"ID",
"confirms",
"if",
"current_user",
"is",
"owner",
"of",
"review"
] | [
"\"\"\"Delete a Review given a review ID and business ID\n confirms if current_user is owner of review\n \"\"\""
] | [
{
"param": "current_user",
"type": null
},
{
"param": "businessId",
"type": null
},
{
"param": "reviewId",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "current_user",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "businessId",
"type": null,
"docstring": null,
"docstr... |
26b44fd5d30c50640fc3b846af6e10314e971d4b | victorjambo/WeConnect | versions/v2/review.py | [
"MIT"
] | Python | update_business | <not_specific> | def update_business(current_user, businessId, reviewId):
"""Updates a review given a business ID
confirms if current user is owner of business
"""
data = request.get_json()
review = Review.query.get(reviewId)
review.title = data['title']
review.desc = data['desc']
review.save()
if... | Updates a review given a business ID
confirms if current user is owner of business
| Updates a review given a business ID
confirms if current user is owner of business | [
"Updates",
"a",
"review",
"given",
"a",
"business",
"ID",
"confirms",
"if",
"current",
"user",
"is",
"owner",
"of",
"business"
] | def update_business(current_user, businessId, reviewId):
data = request.get_json()
review = Review.query.get(reviewId)
review.title = data['title']
review.desc = data['desc']
review.save()
if review.title == data['title']:
return jsonify({
'success': 'successfully updated',
... | [
"def",
"update_business",
"(",
"current_user",
",",
"businessId",
",",
"reviewId",
")",
":",
"data",
"=",
"request",
".",
"get_json",
"(",
")",
"review",
"=",
"Review",
".",
"query",
".",
"get",
"(",
"reviewId",
")",
"review",
".",
"title",
"=",
"data",
... | Updates a review given a business ID
confirms if current user is owner of business | [
"Updates",
"a",
"review",
"given",
"a",
"business",
"ID",
"confirms",
"if",
"current",
"user",
"is",
"owner",
"of",
"business"
] | [
"\"\"\"Updates a review given a business ID\n confirms if current user is owner of business\n \"\"\""
] | [
{
"param": "current_user",
"type": null
},
{
"param": "businessId",
"type": null
},
{
"param": "reviewId",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "current_user",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "businessId",
"type": null,
"docstring": null,
"docstr... |
9d401c9a4edc266908c026b67199d61fc011a2fd | danielzhangau/bdd100k-models | sem_seg/vis.py | [
"Apache-2.0"
] | Python | vis_mask | None | def vis_mask(image_file: str, colormap_file: str, out_path: str) -> None:
"""Visualize bitmask for one image."""
img = np.array(Image.open(image_file))
bitmask = np.array(Image.open(colormap_file).convert("RGB"))
figsize = (int(1280 // 80), int(720 // 80))
fig = plt.figure(figsize=figsize, dpi=80)
... | Visualize bitmask for one image. | Visualize bitmask for one image. | [
"Visualize",
"bitmask",
"for",
"one",
"image",
"."
] | def vis_mask(image_file: str, colormap_file: str, out_path: str) -> None:
img = np.array(Image.open(image_file))
bitmask = np.array(Image.open(colormap_file).convert("RGB"))
figsize = (int(1280 // 80), int(720 // 80))
fig = plt.figure(figsize=figsize, dpi=80)
ax: Axes = fig.add_axes([0.0, 0.0, 1.0, ... | [
"def",
"vis_mask",
"(",
"image_file",
":",
"str",
",",
"colormap_file",
":",
"str",
",",
"out_path",
":",
"str",
")",
"->",
"None",
":",
"img",
"=",
"np",
".",
"array",
"(",
"Image",
".",
"open",
"(",
"image_file",
")",
")",
"bitmask",
"=",
"np",
"... | Visualize bitmask for one image. | [
"Visualize",
"bitmask",
"for",
"one",
"image",
"."
] | [
"\"\"\"Visualize bitmask for one image.\"\"\"",
"# masking out background pixels"
] | [
{
"param": "image_file",
"type": "str"
},
{
"param": "colormap_file",
"type": "str"
},
{
"param": "out_path",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "image_file",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "colormap_file",
"type": "str",
"docstring": null,
"doc... |
9d401c9a4edc266908c026b67199d61fc011a2fd | danielzhangau/bdd100k-models | sem_seg/vis.py | [
"Apache-2.0"
] | Python | vis_masks | None | def vis_masks(
image_files: List[str],
colormap_files: List[str],
out_paths: List[str],
nproc: int = NPROC,
) -> None:
"""Visualize bitmasks for a list of images."""
logger.info("Visualizing bitmasks...")
with Pool(nproc) as pool:
pool.starmap(
partial(vis_mask),
... | Visualize bitmasks for a list of images. | Visualize bitmasks for a list of images. | [
"Visualize",
"bitmasks",
"for",
"a",
"list",
"of",
"images",
"."
] | def vis_masks(
image_files: List[str],
colormap_files: List[str],
out_paths: List[str],
nproc: int = NPROC,
) -> None:
logger.info("Visualizing bitmasks...")
with Pool(nproc) as pool:
pool.starmap(
partial(vis_mask),
tqdm(
zip(image_files, colormap... | [
"def",
"vis_masks",
"(",
"image_files",
":",
"List",
"[",
"str",
"]",
",",
"colormap_files",
":",
"List",
"[",
"str",
"]",
",",
"out_paths",
":",
"List",
"[",
"str",
"]",
",",
"nproc",
":",
"int",
"=",
"NPROC",
",",
")",
"->",
"None",
":",
"logger"... | Visualize bitmasks for a list of images. | [
"Visualize",
"bitmasks",
"for",
"a",
"list",
"of",
"images",
"."
] | [
"\"\"\"Visualize bitmasks for a list of images.\"\"\""
] | [
{
"param": "image_files",
"type": "List[str]"
},
{
"param": "colormap_files",
"type": "List[str]"
},
{
"param": "out_paths",
"type": "List[str]"
},
{
"param": "nproc",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "image_files",
"type": "List[str]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "colormap_files",
"type": "List[str]",
"docstring": nu... |
e08ca0dbe57fb4167d9979b4d9cc7bd9b5237b1f | danielzhangau/bdd100k-models | det/test.py | [
"Apache-2.0"
] | Python | main | None | def main() -> None:
"""Main function for model inference."""
args = parse_args()
assert args.format_only or args.show or args.show_dir, (
"Please specify at least one operation (save/eval/format/show the "
"results / save the results) with the argument '--format-only', "
"'--show' o... | Main function for model inference. | Main function for model inference. | [
"Main",
"function",
"for",
"model",
"inference",
"."
] | def main() -> None:
args = parse_args()
assert args.format_only or args.show or args.show_dir, (
"Please specify at least one operation (save/eval/format/show the "
"results / save the results) with the argument '--format-only', "
"'--show' or '--show-dir'"
)
cfg = Config.fromfil... | [
"def",
"main",
"(",
")",
"->",
"None",
":",
"args",
"=",
"parse_args",
"(",
")",
"assert",
"args",
".",
"format_only",
"or",
"args",
".",
"show",
"or",
"args",
".",
"show_dir",
",",
"(",
"\"Please specify at least one operation (save/eval/format/show the \"",
"\... | Main function for model inference. | [
"Main",
"function",
"for",
"model",
"inference",
"."
] | [
"\"\"\"Main function for model inference.\"\"\"",
"# set cudnn_benchmark",
"# in case the test dataset is concatenated",
"# type: ignore",
"# Replace 'ImageToTensor' to 'DefaultFormatBundle'",
"# type: ignore",
"# type: ignore",
"# init distributed env first, since logger depends on the dist info.",
... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
1ab8bd33a22ba4edd9f7b7018375f1d16a66c97c | danielzhangau/bdd100k-models | ins_seg/datasets/bdd100k.py | [
"Apache-2.0"
] | Python | mask_merge | None | def mask_merge(
img_name: str,
scores: List[float],
segms: List[np.ndarray], # type: ignore
colors: List[List[int]],
bitmask_base: str,
) -> None:
"""Merge masks into a bitmask png file."""
bitmask = np.zeros((*SHAPE, 4), dtype=np.uint8)
sorted_idxs = np.argsort(scores)
for idx in s... | Merge masks into a bitmask png file. | Merge masks into a bitmask png file. | [
"Merge",
"masks",
"into",
"a",
"bitmask",
"png",
"file",
"."
] | def mask_merge(
img_name: str,
scores: List[float],
segms: List[np.ndarray],
colors: List[List[int]],
bitmask_base: str,
) -> None:
bitmask = np.zeros((*SHAPE, 4), dtype=np.uint8)
sorted_idxs = np.argsort(scores)
for idx in sorted_idxs:
mask = mask_utils.decode(segms[idx])
... | [
"def",
"mask_merge",
"(",
"img_name",
":",
"str",
",",
"scores",
":",
"List",
"[",
"float",
"]",
",",
"segms",
":",
"List",
"[",
"np",
".",
"ndarray",
"]",
",",
"colors",
":",
"List",
"[",
"List",
"[",
"int",
"]",
"]",
",",
"bitmask_base",
":",
"... | Merge masks into a bitmask png file. | [
"Merge",
"masks",
"into",
"a",
"bitmask",
"png",
"file",
"."
] | [
"# type: ignore",
"\"\"\"Merge masks into a bitmask png file.\"\"\""
] | [
{
"param": "img_name",
"type": "str"
},
{
"param": "scores",
"type": "List[float]"
},
{
"param": "segms",
"type": "List[np.ndarray]"
},
{
"param": "colors",
"type": "List[List[int]]"
},
{
"param": "bitmask_base",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "img_name",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "scores",
"type": "List[float]",
"docstring": null,
"docs... |
1ab8bd33a22ba4edd9f7b7018375f1d16a66c97c | danielzhangau/bdd100k-models | ins_seg/datasets/bdd100k.py | [
"Apache-2.0"
] | Python | mask_merge_parallel | None | def mask_merge_parallel(
bitmask_base: str,
img_names: List[str],
scores_list: List[List[float]],
segms_list: List[List[RLEType]],
colors_list: List[List[List[int]]],
nproc: int = 4,
) -> None:
"""Merge masks into a bitmask png file. Run parallely."""
with Pool(nproc) as pool:
pr... | Merge masks into a bitmask png file. Run parallely. | Merge masks into a bitmask png file. Run parallely. | [
"Merge",
"masks",
"into",
"a",
"bitmask",
"png",
"file",
".",
"Run",
"parallely",
"."
] | def mask_merge_parallel(
bitmask_base: str,
img_names: List[str],
scores_list: List[List[float]],
segms_list: List[List[RLEType]],
colors_list: List[List[List[int]]],
nproc: int = 4,
) -> None:
with Pool(nproc) as pool:
print("\nMerging overlapped masks.")
pool.starmap(
... | [
"def",
"mask_merge_parallel",
"(",
"bitmask_base",
":",
"str",
",",
"img_names",
":",
"List",
"[",
"str",
"]",
",",
"scores_list",
":",
"List",
"[",
"List",
"[",
"float",
"]",
"]",
",",
"segms_list",
":",
"List",
"[",
"List",
"[",
"RLEType",
"]",
"]",
... | Merge masks into a bitmask png file. | [
"Merge",
"masks",
"into",
"a",
"bitmask",
"png",
"file",
"."
] | [
"\"\"\"Merge masks into a bitmask png file. Run parallely.\"\"\""
] | [
{
"param": "bitmask_base",
"type": "str"
},
{
"param": "img_names",
"type": "List[str]"
},
{
"param": "scores_list",
"type": "List[List[float]]"
},
{
"param": "segms_list",
"type": "List[List[RLEType]]"
},
{
"param": "colors_list",
"type": "List[List[List[int]... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bitmask_base",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "img_names",
"type": "List[str]",
"docstring": null,
... |
1ab8bd33a22ba4edd9f7b7018375f1d16a66c97c | danielzhangau/bdd100k-models | ins_seg/datasets/bdd100k.py | [
"Apache-2.0"
] | Python | convert_format | None | def convert_format( # pylint: disable=arguments-differ
self, results: List[np.ndarray], out_dir: str # type: ignore
) -> None:
"""Format the results to the BDD100K prediction format."""
assert isinstance(results, list), "results must be a list"
assert len(results) == len(
... | Format the results to the BDD100K prediction format. | Format the results to the BDD100K prediction format. | [
"Format",
"the",
"results",
"to",
"the",
"BDD100K",
"prediction",
"format",
"."
] | def convert_format(
self, results: List[np.ndarray], out_dir: str
) -> None:
assert isinstance(results, list), "results must be a list"
assert len(results) == len(
self
), f"Length of res and dset not equal: {len(results)} != {len(self)}"
if not os.path.exists... | [
"def",
"convert_format",
"(",
"self",
",",
"results",
":",
"List",
"[",
"np",
".",
"ndarray",
"]",
",",
"out_dir",
":",
"str",
")",
"->",
"None",
":",
"assert",
"isinstance",
"(",
"results",
",",
"list",
")",
",",
"\"results must be a list\"",
"assert",
... | Format the results to the BDD100K prediction format. | [
"Format",
"the",
"results",
"to",
"the",
"BDD100K",
"prediction",
"format",
"."
] | [
"# pylint: disable=arguments-differ",
"# type: ignore",
"\"\"\"Format the results to the BDD100K prediction format.\"\"\"",
"# type: ignore",
"# type: ignore"
] | [
{
"param": "self",
"type": null
},
{
"param": "results",
"type": "List[np.ndarray]"
},
{
"param": "out_dir",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "results",
"type": "List[np.ndarray]",
"docstring": null,
"doc... |
e5f7017296d1e36be18708366d6edc0265c86af8 | danielzhangau/bdd100k-models | drivable/datasets/bdd100k.py | [
"Apache-2.0"
] | Python | results2img | List[str] | def results2img(
self, results: List[np.ndarray], imgfile_prefix: str # type: ignore
) -> List[str]:
"""Write the segmentation results to images."""
mmcv.mkdir_or_exist(imgfile_prefix)
result_files = []
prog_bar = mmcv.ProgressBar(len(self))
for idx in range(len(self... | Write the segmentation results to images. | Write the segmentation results to images. | [
"Write",
"the",
"segmentation",
"results",
"to",
"images",
"."
] | def results2img(
self, results: List[np.ndarray], imgfile_prefix: str
) -> List[str]:
mmcv.mkdir_or_exist(imgfile_prefix)
result_files = []
prog_bar = mmcv.ProgressBar(len(self))
for idx in range(len(self)):
result = results[idx]
filename = self.img_... | [
"def",
"results2img",
"(",
"self",
",",
"results",
":",
"List",
"[",
"np",
".",
"ndarray",
"]",
",",
"imgfile_prefix",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"mmcv",
".",
"mkdir_or_exist",
"(",
"imgfile_prefix",
")",
"result_files",
"=",
... | Write the segmentation results to images. | [
"Write",
"the",
"segmentation",
"results",
"to",
"images",
"."
] | [
"# type: ignore",
"\"\"\"Write the segmentation results to images.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "results",
"type": "List[np.ndarray]"
},
{
"param": "imgfile_prefix",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "results",
"type": "List[np.ndarray]",
"docstring": null,
"doc... |
e5f7017296d1e36be18708366d6edc0265c86af8 | danielzhangau/bdd100k-models | drivable/datasets/bdd100k.py | [
"Apache-2.0"
] | Python | format_results | List[str] | def format_results( # pylint: disable=arguments-differ
self, results: List[np.ndarray], imgfile_prefix: str # type: ignore
) -> List[str]:
"""Format the results into dir (standard format for BDD100K)."""
assert isinstance(results, list), "results must be a list"
assert len(results)... | Format the results into dir (standard format for BDD100K). | Format the results into dir (standard format for BDD100K). | [
"Format",
"the",
"results",
"into",
"dir",
"(",
"standard",
"format",
"for",
"BDD100K",
")",
"."
] | def format_results(
self, results: List[np.ndarray], imgfile_prefix: str
) -> List[str]:
assert isinstance(results, list), "results must be a list"
assert len(results) == len(self), (
"The length of results is not equal to the dataset len: "
f"{len(results)} != {l... | [
"def",
"format_results",
"(",
"self",
",",
"results",
":",
"List",
"[",
"np",
".",
"ndarray",
"]",
",",
"imgfile_prefix",
":",
"str",
")",
"->",
"List",
"[",
"str",
"]",
":",
"assert",
"isinstance",
"(",
"results",
",",
"list",
")",
",",
"\"results mus... | Format the results into dir (standard format for BDD100K). | [
"Format",
"the",
"results",
"into",
"dir",
"(",
"standard",
"format",
"for",
"BDD100K",
")",
"."
] | [
"# pylint: disable=arguments-differ",
"# type: ignore",
"\"\"\"Format the results into dir (standard format for BDD100K).\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "results",
"type": "List[np.ndarray]"
},
{
"param": "imgfile_prefix",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "results",
"type": "List[np.ndarray]",
"docstring": null,
"doc... |
ec6e8075299c4dd5f67ee5312395d2fad6855567 | danielzhangau/bdd100k-models | tagging/test.py | [
"Apache-2.0"
] | Python | main | None | def main() -> None:
"""Main function for model inference."""
args = parse_args()
cfg = mmcv.Config.fromfile(args.config)
if cfg.load_from is None:
cfg_split = args.config.split("/")
cfg_name = f"{cfg_split[-2]}/{cfg_split[-1].replace('.py', '.pth')}"
cfg.load_from = MODEL_SERVER... | Main function for model inference. | Main function for model inference. | [
"Main",
"function",
"for",
"model",
"inference",
"."
] | def main() -> None:
args = parse_args()
cfg = mmcv.Config.fromfile(args.config)
if cfg.load_from is None:
cfg_split = args.config.split("/")
cfg_name = f"{cfg_split[-2]}/{cfg_split[-1].replace('.py', '.pth')}"
cfg.load_from = MODEL_SERVER + cfg_name
if args.options is not None:
... | [
"def",
"main",
"(",
")",
"->",
"None",
":",
"args",
"=",
"parse_args",
"(",
")",
"cfg",
"=",
"mmcv",
".",
"Config",
".",
"fromfile",
"(",
"args",
".",
"config",
")",
"if",
"cfg",
".",
"load_from",
"is",
"None",
":",
"cfg_split",
"=",
"args",
".",
... | Main function for model inference. | [
"Main",
"function",
"for",
"model",
"inference",
"."
] | [
"\"\"\"Main function for model inference.\"\"\"",
"# set cudnn_benchmark",
"# init distributed env first, since logger depends on the dist info.",
"# build the dataloader",
"# the extra round_up data will be removed during gpu/cpu collect",
"# build the model and load checkpoint"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
b5b6566491c52adee814f8d2528f08fbbbe0fc46 | danielzhangau/bdd100k-models | sem_seg/test.py | [
"Apache-2.0"
] | Python | main | None | def main() -> None:
"""Main function for model inference."""
args = parse_args()
assert args.format_only or args.show or args.show_dir, (
"Please specify at least one operation (save/eval/format/show the "
"results / save the results) with the argument '--format-only', "
"'--show' o... | Main function for model inference. | Main function for model inference. | [
"Main",
"function",
"for",
"model",
"inference",
"."
] | def main() -> None:
args = parse_args()
assert args.format_only or args.show or args.show_dir, (
"Please specify at least one operation (save/eval/format/show the "
"results / save the results) with the argument '--format-only', "
"'--show' or '--show-dir'"
)
cfg = mmcv.Config.fr... | [
"def",
"main",
"(",
")",
"->",
"None",
":",
"args",
"=",
"parse_args",
"(",
")",
"assert",
"args",
".",
"format_only",
"or",
"args",
".",
"show",
"or",
"args",
".",
"show_dir",
",",
"(",
"\"Please specify at least one operation (save/eval/format/show the \"",
"\... | Main function for model inference. | [
"Main",
"function",
"for",
"model",
"inference",
"."
] | [
"\"\"\"Main function for model inference.\"\"\"",
"# set cudnn_benchmark",
"# hard code index",
"# init distributed env first, since logger depends on the dist info.",
"# build the dataloader",
"# build the model and load checkpoint"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e9e3d1ca482a634e23276261b6fda078be17b9a8 | OjureFred/watchlist | app/main/views.py | [
"MIT"
] | Python | index | <not_specific> | def index():
'''
View root page function that returns index page and it's data
'''
#Getting popular movies
popular_movies = get_movies('popular')
upcoming_movie = get_movies('upcoming')
now_showing_movie = get_movies('now_playing')
title = "Home - Welcome to the best Movie Review Websit... |
View root page function that returns index page and it's data
| View root page function that returns index page and it's data | [
"View",
"root",
"page",
"function",
"that",
"returns",
"index",
"page",
"and",
"it",
"'",
"s",
"data"
] | def index():
popular_movies = get_movies('popular')
upcoming_movie = get_movies('upcoming')
now_showing_movie = get_movies('now_playing')
title = "Home - Welcome to the best Movie Review Website Online"
search_movie = request.args.get('movie_query')
if search_movie:
return redirect(url_f... | [
"def",
"index",
"(",
")",
":",
"popular_movies",
"=",
"get_movies",
"(",
"'popular'",
")",
"upcoming_movie",
"=",
"get_movies",
"(",
"'upcoming'",
")",
"now_showing_movie",
"=",
"get_movies",
"(",
"'now_playing'",
")",
"title",
"=",
"\"Home - Welcome to the best Mov... | View root page function that returns index page and it's data | [
"View",
"root",
"page",
"function",
"that",
"returns",
"index",
"page",
"and",
"it",
"'",
"s",
"data"
] | [
"'''\n View root page function that returns index page and it's data\n '''",
"#Getting popular movies"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
e9e3d1ca482a634e23276261b6fda078be17b9a8 | OjureFred/watchlist | app/main/views.py | [
"MIT"
] | Python | movie | <not_specific> | def movie(id):
'''
View movie page function that returns movie details page and its data
'''
movie = get_movie(id)
title = f'{movie.title}'
reviews = Review.get_reviews(movie.id)
return render_template('movie.html', title=title, movie=movie, reviews = reviews) |
View movie page function that returns movie details page and its data
| View movie page function that returns movie details page and its data | [
"View",
"movie",
"page",
"function",
"that",
"returns",
"movie",
"details",
"page",
"and",
"its",
"data"
] | def movie(id):
movie = get_movie(id)
title = f'{movie.title}'
reviews = Review.get_reviews(movie.id)
return render_template('movie.html', title=title, movie=movie, reviews = reviews) | [
"def",
"movie",
"(",
"id",
")",
":",
"movie",
"=",
"get_movie",
"(",
"id",
")",
"title",
"=",
"f'{movie.title}'",
"reviews",
"=",
"Review",
".",
"get_reviews",
"(",
"movie",
".",
"id",
")",
"return",
"render_template",
"(",
"'movie.html'",
",",
"title",
... | View movie page function that returns movie details page and its data | [
"View",
"movie",
"page",
"function",
"that",
"returns",
"movie",
"details",
"page",
"and",
"its",
"data"
] | [
"'''\n View movie page function that returns movie details page and its data\n '''"
] | [
{
"param": "id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b0d03504bb6d7524fb7f1d12d620c0751b44c5b | kylegordon/mqtt-aprs | mqtt-aprs.py | [
"MIT"
] | Python | send_packet | null | def send_packet(packet):
"""
Create a socket, log on to the APRS server, and send the packet
"""
logging.debug(APRS_SERVER + ":" + str(APRS_PORT))
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect((APRS_SERVER, APRS_PORT))
# Log on to APRS server
connecti... |
Create a socket, log on to the APRS server, and send the packet
| Create a socket, log on to the APRS server, and send the packet | [
"Create",
"a",
"socket",
"log",
"on",
"to",
"the",
"APRS",
"server",
"and",
"send",
"the",
"packet"
] | def send_packet(packet):
logging.debug(APRS_SERVER + ":" + str(APRS_PORT))
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect((APRS_SERVER, APRS_PORT))
connection.send('user ' + APRS_CALLSIGN + ' pass ' + APRS_PASS + ' vers "mqtt-zabbix" \n')
logging.debug("Sending %s"... | [
"def",
"send_packet",
"(",
"packet",
")",
":",
"logging",
".",
"debug",
"(",
"APRS_SERVER",
"+",
"\":\"",
"+",
"str",
"(",
"APRS_PORT",
")",
")",
"connection",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM"... | Create a socket, log on to the APRS server, and send the packet | [
"Create",
"a",
"socket",
"log",
"on",
"to",
"the",
"APRS",
"server",
"and",
"send",
"the",
"packet"
] | [
"\"\"\"\n Create a socket, log on to the APRS server, and send the packet\n \"\"\"",
"# Log on to APRS server",
"# Send APRS packet",
"# Close socket -- must be closed to avoidbuffer overflow",
"# 15 sec. delay"
] | [
{
"param": "packet",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "packet",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6b0d03504bb6d7524fb7f1d12d620c0751b44c5b | kylegordon/mqtt-aprs | mqtt-aprs.py | [
"MIT"
] | Python | cleanup | null | def cleanup(signum, frame):
"""
Signal handler to ensure we disconnect cleanly
in the event of a SIGTERM or SIGINT.
"""
logging.info("Disconnecting from broker")
# Publish a retained message to state that this client is offline
mqttc.publish(PRESENCETOPIC, "0", retain=True)
mqttc.disconn... |
Signal handler to ensure we disconnect cleanly
in the event of a SIGTERM or SIGINT.
| Signal handler to ensure we disconnect cleanly
in the event of a SIGTERM or SIGINT. | [
"Signal",
"handler",
"to",
"ensure",
"we",
"disconnect",
"cleanly",
"in",
"the",
"event",
"of",
"a",
"SIGTERM",
"or",
"SIGINT",
"."
] | def cleanup(signum, frame):
logging.info("Disconnecting from broker")
mqttc.publish(PRESENCETOPIC, "0", retain=True)
mqttc.disconnect()
logging.info("Exiting on signal %d", signum)
sys.exit(signum) | [
"def",
"cleanup",
"(",
"signum",
",",
"frame",
")",
":",
"logging",
".",
"info",
"(",
"\"Disconnecting from broker\"",
")",
"mqttc",
".",
"publish",
"(",
"PRESENCETOPIC",
",",
"\"0\"",
",",
"retain",
"=",
"True",
")",
"mqttc",
".",
"disconnect",
"(",
")",
... | Signal handler to ensure we disconnect cleanly
in the event of a SIGTERM or SIGINT. | [
"Signal",
"handler",
"to",
"ensure",
"we",
"disconnect",
"cleanly",
"in",
"the",
"event",
"of",
"a",
"SIGTERM",
"or",
"SIGINT",
"."
] | [
"\"\"\"\n Signal handler to ensure we disconnect cleanly\n in the event of a SIGTERM or SIGINT.\n \"\"\"",
"# Publish a retained message to state that this client is offline"
] | [
{
"param": "signum",
"type": null
},
{
"param": "frame",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "signum",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "frame",
"type": null,
"docstring": null,
"docstring_tokens"... |
6b0d03504bb6d7524fb7f1d12d620c0751b44c5b | kylegordon/mqtt-aprs | mqtt-aprs.py | [
"MIT"
] | Python | connect | null | def connect():
"""
Connect to the broker, define the callbacks, and subscribe
This will also set the Last Will and Testament (LWT)
The LWT will be published in the event of an unclean or
unexpected disconnection.
"""
logging.debug("Connecting to %s:%s", MQTT_HOST, MQTT_PORT)
# Set the La... |
Connect to the broker, define the callbacks, and subscribe
This will also set the Last Will and Testament (LWT)
The LWT will be published in the event of an unclean or
unexpected disconnection.
| Connect to the broker, define the callbacks, and subscribe
This will also set the Last Will and Testament (LWT)
The LWT will be published in the event of an unclean or
unexpected disconnection. | [
"Connect",
"to",
"the",
"broker",
"define",
"the",
"callbacks",
"and",
"subscribe",
"This",
"will",
"also",
"set",
"the",
"Last",
"Will",
"and",
"Testament",
"(",
"LWT",
")",
"The",
"LWT",
"will",
"be",
"published",
"in",
"the",
"event",
"of",
"an",
"unc... | def connect():
logging.debug("Connecting to %s:%s", MQTT_HOST, MQTT_PORT)
mqttc.will_set(PRESENCETOPIC, "0", qos=0, retain=True)
mqttc.username_pw_set(MQTT_USER, MQTT_PASS)
result = mqttc.connect(MQTT_HOST, MQTT_PORT, 60, True)
if result != 0:
logging.info("Connection failed with error code ... | [
"def",
"connect",
"(",
")",
":",
"logging",
".",
"debug",
"(",
"\"Connecting to %s:%s\"",
",",
"MQTT_HOST",
",",
"MQTT_PORT",
")",
"mqttc",
".",
"will_set",
"(",
"PRESENCETOPIC",
",",
"\"0\"",
",",
"qos",
"=",
"0",
",",
"retain",
"=",
"True",
")",
"mqttc... | Connect to the broker, define the callbacks, and subscribe
This will also set the Last Will and Testament (LWT)
The LWT will be published in the event of an unclean or
unexpected disconnection. | [
"Connect",
"to",
"the",
"broker",
"define",
"the",
"callbacks",
"and",
"subscribe",
"This",
"will",
"also",
"set",
"the",
"Last",
"Will",
"and",
"Testament",
"(",
"LWT",
")",
"The",
"LWT",
"will",
"be",
"published",
"in",
"the",
"event",
"of",
"an",
"unc... | [
"\"\"\"\n Connect to the broker, define the callbacks, and subscribe\n This will also set the Last Will and Testament (LWT)\n The LWT will be published in the event of an unclean or\n unexpected disconnection.\n \"\"\"",
"# Set the Last Will and Testament (LWT) *before* connecting",
"# Define the... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f12d25f65960249aa08c995451c3ec1fd40be2b7 | spraakbanken/karp-mfl | mflbackend/tests/test_search3.py | [
"MIT"
] | Python | call | <not_specific> | def call(url, params={}, data=None, is_json=True):
""" Makes a GET call to the given host and path.
"""
try:
params = urllib.parse.urlencode(params)
if params:
url = '%s?%s' % (url, params)
q = "%s/%s" % (host, url)
user, pw = 'mfl', 'mfl'
userpw = '%s:%s'... | Makes a GET call to the given host and path.
| Makes a GET call to the given host and path. | [
"Makes",
"a",
"GET",
"call",
"to",
"the",
"given",
"host",
"and",
"path",
"."
] | def call(url, params={}, data=None, is_json=True):
try:
params = urllib.parse.urlencode(params)
if params:
url = '%s?%s' % (url, params)
q = "%s/%s" % (host, url)
user, pw = 'mfl', 'mfl'
userpw = '%s:%s' % (user, pw)
basic = base64.b64encode(userpw.encode(... | [
"def",
"call",
"(",
"url",
",",
"params",
"=",
"{",
"}",
",",
"data",
"=",
"None",
",",
"is_json",
"=",
"True",
")",
":",
"try",
":",
"params",
"=",
"urllib",
".",
"parse",
".",
"urlencode",
"(",
"params",
")",
"if",
"params",
":",
"url",
"=",
... | Makes a GET call to the given host and path. | [
"Makes",
"a",
"GET",
"call",
"to",
"the",
"given",
"host",
"and",
"path",
"."
] | [
"\"\"\" Makes a GET call to the given host and path.\n \"\"\"",
"# print('headers %s' % req.headers)",
"# print('reps', response)"
] | [
{
"param": "url",
"type": null
},
{
"param": "params",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "is_json",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "params",
"type": null,
"docstring": null,
"docstring_tokens": ... |
3ba31ccb97f3544647866734c96d07c43622465d | spraakbanken/karp-mfl | mflbackend/config/saldomp_convert.py | [
"MIT"
] | Python | karp_wftableize | <not_specific> | def karp_wftableize(paradigm, table, classes={}, baseform='', identifier='',
pos='', resource=''):
" Url table format -> LMF format"
table = table.split(',')
obj = {'lexiconName': resource}
wfs = []
for l in table:
if '|' in l:
form, tag = l.split('|')
... | Url table format -> LMF format | Url table format -> LMF format | [
"Url",
"table",
"format",
"-",
">",
"LMF",
"format"
] | def karp_wftableize(paradigm, table, classes={}, baseform='', identifier='',
pos='', resource=''):
table = table.split(',')
obj = {'lexiconName': resource}
wfs = []
for l in table:
if '|' in l:
form, tag = l.split('|')
else:
form = l
... | [
"def",
"karp_wftableize",
"(",
"paradigm",
",",
"table",
",",
"classes",
"=",
"{",
"}",
",",
"baseform",
"=",
"''",
",",
"identifier",
"=",
"''",
",",
"pos",
"=",
"''",
",",
"resource",
"=",
"''",
")",
":",
"table",
"=",
"table",
".",
"split",
"(",... | Url table format -> LMF format | [
"Url",
"table",
"format",
"-",
">",
"LMF",
"format"
] | [
"\" Url table format -> LMF format\""
] | [
{
"param": "paradigm",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "classes",
"type": null
},
{
"param": "baseform",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "r... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "paradigm",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_token... |
47f825d3ef850072bfaa77e3ff99acab3ee7d8d9 | spraakbanken/karp-mfl | mflbackend/src/handleparadigms.py | [
"MIT"
] | Python | add_paradigm | null | def add_paradigm(lexicon, pid, paradigm, paradigms, identifier, pos, classes):
"""
Add a new paradigm (update language model, save to karp).
Args:
lexicon (str): the lexicon name
pid (string): the paradigms name (human readable id)
paradigm (obj): the paradigm (Paradigm.py)
p... |
Add a new paradigm (update language model, save to karp).
Args:
lexicon (str): the lexicon name
pid (string): the paradigms name (human readable id)
paradigm (obj): the paradigm (Paradigm.py)
paradigms (list): a list of all internal paradigms
identifier (str): the tables... | Add a new paradigm (update language model, save to karp). | [
"Add",
"a",
"new",
"paradigm",
"(",
"update",
"language",
"model",
"save",
"to",
"karp",
")",
"."
] | def add_paradigm(lexicon, pid, paradigm, paradigms, identifier, pos, classes):
presource = lexconfig.get_paradigmlexicon(lexicon)
lresource = lexconfig.get_lexiconname(lexicon)
logging.debug('id %s, para %s.\n classes %s, identifier %s',
pid, paradigm, classes, identifier)
paradigm.set... | [
"def",
"add_paradigm",
"(",
"lexicon",
",",
"pid",
",",
"paradigm",
",",
"paradigms",
",",
"identifier",
",",
"pos",
",",
"classes",
")",
":",
"presource",
"=",
"lexconfig",
".",
"get_paradigmlexicon",
"(",
"lexicon",
")",
"lresource",
"=",
"lexconfig",
".",... | Add a new paradigm (update language model, save to karp). | [
"Add",
"a",
"new",
"paradigm",
"(",
"update",
"language",
"model",
"save",
"to",
"karp",
")",
"."
] | [
"\"\"\"\n Add a new paradigm (update language model, save to karp).\n Args:\n lexicon (str): the lexicon name\n pid (string): the paradigms name (human readable id)\n paradigm (obj): the paradigm (Paradigm.py)\n paradigms (list): a list of all internal paradigms\n identifier... | [
{
"param": "lexicon",
"type": null
},
{
"param": "pid",
"type": null
},
{
"param": "paradigm",
"type": null
},
{
"param": "paradigms",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "cl... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": "the lexicon name",
"docstring_tokens": [
"the",
"lexicon",
"name"
],
"default": null,
"is_optional": false
},
{
"identifier": "pid",... |
47f825d3ef850072bfaa77e3ff99acab3ee7d8d9 | spraakbanken/karp-mfl | mflbackend/src/handleparadigms.py | [
"MIT"
] | Python | add_word_to_paradigm | null | def add_word_to_paradigm(lexicon, paradigm, paradigms, identifier, pos,
classes, inst):
"""
Add a word to extisting paradigm (update language model, save to karp)
Args:
lexicon (str): the lexicon name
paradigm (obj): the paradigm (Paradigm.py)
paradigms (dict... |
Add a word to extisting paradigm (update language model, save to karp)
Args:
lexicon (str): the lexicon name
paradigm (obj): the paradigm (Paradigm.py)
paradigms (dict): a dictionary with all paradigms
'{"lexname": {"nn": [], "vb": []}'
identifier (str): the tables i... | Add a word to extisting paradigm (update language model, save to karp) | [
"Add",
"a",
"word",
"to",
"extisting",
"paradigm",
"(",
"update",
"language",
"model",
"save",
"to",
"karp",
")"
] | def add_word_to_paradigm(lexicon, paradigm, paradigms, identifier, pos,
classes, inst):
presource = lexconfig.get_paradigmlexicon(lexicon)
lresource = lexconfig.get_lexiconname(lexicon)
logging.debug('old count %s', paradigm.count)
var_inst = [('first-attest', identifier)]+list(... | [
"def",
"add_word_to_paradigm",
"(",
"lexicon",
",",
"paradigm",
",",
"paradigms",
",",
"identifier",
",",
"pos",
",",
"classes",
",",
"inst",
")",
":",
"presource",
"=",
"lexconfig",
".",
"get_paradigmlexicon",
"(",
"lexicon",
")",
"lresource",
"=",
"lexconfig... | Add a word to extisting paradigm (update language model, save to karp) | [
"Add",
"a",
"word",
"to",
"extisting",
"paradigm",
"(",
"update",
"language",
"model",
"save",
"to",
"karp",
")"
] | [
"\"\"\"\n Add a word to extisting paradigm (update language model, save to karp)\n Args:\n lexicon (str): the lexicon name\n paradigm (obj): the paradigm (Paradigm.py)\n paradigms (dict): a dictionary with all paradigms\n '{\"lexname\": {\"nn\": [], \"vb\": []}'\n identi... | [
{
"param": "lexicon",
"type": null
},
{
"param": "paradigm",
"type": null
},
{
"param": "paradigms",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "classes",
"type": null
},
{
"param":... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": "the lexicon name",
"docstring_tokens": [
"the",
"lexicon",
"name"
],
"default": null,
"is_optional": false
},
{
"identifier": "parad... |
47f825d3ef850072bfaa77e3ff99acab3ee7d8d9 | spraakbanken/karp-mfl | mflbackend/src/handleparadigms.py | [
"MIT"
] | Python | remove_word_from_paradigm | null | def remove_word_from_paradigm(lexicon, paradigm, paradigms, identifier, pos):
"""
Remove a word from a paradigm (update language model, save to karp)
Args:
lexicon (str): the lexicon name
paradigm (obj): the paradigm (Paradigm.py)
paradigms (dict): a dictionary with all paradigms
... |
Remove a word from a paradigm (update language model, save to karp)
Args:
lexicon (str): the lexicon name
paradigm (obj): the paradigm (Paradigm.py)
paradigms (dict): a dictionary with all paradigms
'{"lexname": {"nn": [], "vb": []}'
identifier (str): the tables ide... | Remove a word from a paradigm (update language model, save to karp) | [
"Remove",
"a",
"word",
"from",
"a",
"paradigm",
"(",
"update",
"language",
"model",
"save",
"to",
"karp",
")"
] | def remove_word_from_paradigm(lexicon, paradigm, paradigms, identifier, pos):
logging.debug('old count %s', paradigm.count)
for ix, var_inst in enumerate(paradigm.var_insts):
if dict(var_inst).get('first-attest', '') == identifier:
paradigm.var_insts.pop(ix)
break
try:
... | [
"def",
"remove_word_from_paradigm",
"(",
"lexicon",
",",
"paradigm",
",",
"paradigms",
",",
"identifier",
",",
"pos",
")",
":",
"logging",
".",
"debug",
"(",
"'old count %s'",
",",
"paradigm",
".",
"count",
")",
"for",
"ix",
",",
"var_inst",
"in",
"enumerate... | Remove a word from a paradigm (update language model, save to karp) | [
"Remove",
"a",
"word",
"from",
"a",
"paradigm",
"(",
"update",
"language",
"model",
"save",
"to",
"karp",
")"
] | [
"\"\"\"\n Remove a word from a paradigm (update language model, save to karp)\n Args:\n lexicon (str): the lexicon name\n paradigm (obj): the paradigm (Paradigm.py)\n paradigms (dict): a dictionary with all paradigms\n '{\"lexname\": {\"nn\": [], \"vb\": []}'\n identifi... | [
{
"param": "lexicon",
"type": null
},
{
"param": "paradigm",
"type": null
},
{
"param": "paradigms",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "pos",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": "the lexicon name",
"docstring_tokens": [
"the",
"lexicon",
"name"
],
"default": null,
"is_optional": false
},
{
"identifier": "parad... |
47f825d3ef850072bfaa77e3ff99acab3ee7d8d9 | spraakbanken/karp-mfl | mflbackend/src/handleparadigms.py | [
"MIT"
] | Python | remove_paradigm | null | def remove_paradigm(lexicon, paradigm, paradigms, pos):
"""
Remove a paradigm (update language model, delete from karp)
Args:
lexicon (str): the lexicon name
paradigm (obj): the paradigm (Paradigm.py)
paradigms (dict): a dictionary with all paradigms
'{"lexname": {"nn":... |
Remove a paradigm (update language model, delete from karp)
Args:
lexicon (str): the lexicon name
paradigm (obj): the paradigm (Paradigm.py)
paradigms (dict): a dictionary with all paradigms
'{"lexname": {"nn": [], "vb": []}'
pos (str): the tables word class
| Remove a paradigm (update language model, delete from karp) | [
"Remove",
"a",
"paradigm",
"(",
"update",
"language",
"model",
"delete",
"from",
"karp",
")"
] | def remove_paradigm(lexicon, paradigm, paradigms, pos):
helpers.karp_delete(paradigm.uuid, lexconfig.get_paradigmlexicon(lexicon))
lresource = lexconfig.get_lexiconname(lexicon)
all_paras, numex, lms, alpha = paradigms[lresource].get(pos, ({}, 0, None))
del all_paras[paradigm.uuid]
del lms[paradigm.... | [
"def",
"remove_paradigm",
"(",
"lexicon",
",",
"paradigm",
",",
"paradigms",
",",
"pos",
")",
":",
"helpers",
".",
"karp_delete",
"(",
"paradigm",
".",
"uuid",
",",
"lexconfig",
".",
"get_paradigmlexicon",
"(",
"lexicon",
")",
")",
"lresource",
"=",
"lexconf... | Remove a paradigm (update language model, delete from karp) | [
"Remove",
"a",
"paradigm",
"(",
"update",
"language",
"model",
"delete",
"from",
"karp",
")"
] | [
"\"\"\"\n Remove a paradigm (update language model, delete from karp)\n Args:\n lexicon (str): the lexicon name\n paradigm (obj): the paradigm (Paradigm.py)\n paradigms (dict): a dictionary with all paradigms\n '{\"lexname\": {\"nn\": [], \"vb\": []}'\n pos (str): the ... | [
{
"param": "lexicon",
"type": null
},
{
"param": "paradigm",
"type": null
},
{
"param": "paradigms",
"type": null
},
{
"param": "pos",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": "the lexicon name",
"docstring_tokens": [
"the",
"lexicon",
"name"
],
"default": null,
"is_optional": false
},
{
"identifier": "parad... |
47f825d3ef850072bfaa77e3ff99acab3ee7d8d9 | spraakbanken/karp-mfl | mflbackend/src/handleparadigms.py | [
"MIT"
] | Python | inflect_table | <not_specific> | def inflect_table(lexicon, table, paradigms, identifier, pos, ppriorv=None,
kbest=10, match_all=False):
"""
Find matching paradigms for an inflectiontable, possibly by adding
word forms to the original table.
Args:
lexicon (str): the lexicon name
table (list): the comma... |
Find matching paradigms for an inflectiontable, possibly by adding
word forms to the original table.
Args:
lexicon (str): the lexicon name
table (list): the comma separated word forms, possibly with msds.
"katt,katter|pl indef nom,katts"
paradigms (dict): a dic... | Find matching paradigms for an inflectiontable, possibly by adding
word forms to the original table. | [
"Find",
"matching",
"paradigms",
"for",
"an",
"inflectiontable",
"possibly",
"by",
"adding",
"word",
"forms",
"to",
"the",
"original",
"table",
"."
] | def inflect_table(lexicon, table, paradigms, identifier, pos, ppriorv=None,
kbest=10, match_all=False):
lexconf = lexconfig.get_lexiconconf(lexicon)
restrict_baseform = helpers.read_restriction(lexconf)
paras, numex, lms = helpers.relevant_paradigms(paradigms, lexicon, pos)
fill_tags =... | [
"def",
"inflect_table",
"(",
"lexicon",
",",
"table",
",",
"paradigms",
",",
"identifier",
",",
"pos",
",",
"ppriorv",
"=",
"None",
",",
"kbest",
"=",
"10",
",",
"match_all",
"=",
"False",
")",
":",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(... | Find matching paradigms for an inflectiontable, possibly by adding
word forms to the original table. | [
"Find",
"matching",
"paradigms",
"for",
"an",
"inflectiontable",
"possibly",
"by",
"adding",
"word",
"forms",
"to",
"the",
"original",
"table",
"."
] | [
"\"\"\"\n Find matching paradigms for an inflectiontable, possibly by adding\n word forms to the original table.\n Args:\n lexicon (str): the lexicon name\n table (list): the comma separated word forms, possibly with msds.\n \"katt,katter|pl indef nom,katts\"\n par... | [
{
"param": "lexicon",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "paradigms",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "ppriorv",
"type": null
},
{
"param": "k... | {
"returns": [
{
"docstring": "[results]}\nwhere a result consits of:\n{score: float, paradigm: str, new: bool,\nidentifier: str,\nbaseform: str,\nvariables: dict of variable instansiations,\nWordForms: [{writtenForm: str, msd: str}]\npartOfSpeech: str,\nparadigm_entries: int,\n}\nIf the paradigm is new, th... |
47f825d3ef850072bfaa77e3ff99acab3ee7d8d9 | spraakbanken/karp-mfl | mflbackend/src/handleparadigms.py | [
"MIT"
] | Python | make_new_table | <not_specific> | def make_new_table(lexicon, table, paradigm, paradigms, identifier, baseform,
pos, classes, ppriorv=None, newword=False, newpara=False):
"""
Check that the given table and identifiers are ok, that the table matches
given paradigm and then add the table to the paradigm,
in karp and int... |
Check that the given table and identifiers are ok, that the table matches
given paradigm and then add the table to the paradigm,
in karp and internally.
Args:
lexicon (str): the lexicon name
table (str): the comma separated word forms, possibly with msds.
"katt,katter|pl ind... | Check that the given table and identifiers are ok, that the table matches
given paradigm and then add the table to the paradigm,
in karp and internally. | [
"Check",
"that",
"the",
"given",
"table",
"and",
"identifiers",
"are",
"ok",
"that",
"the",
"table",
"matches",
"given",
"paradigm",
"and",
"then",
"add",
"the",
"table",
"to",
"the",
"paradigm",
"in",
"karp",
"and",
"internally",
"."
] | def make_new_table(lexicon, table, paradigm, paradigms, identifier, baseform,
pos, classes, ppriorv=None, newword=False, newpara=False):
lresource = lexconfig.get_lexiconname(lexicon)
ok = helpers.check_identifier(identifier,
lexconfig.get_identifierfield(lex... | [
"def",
"make_new_table",
"(",
"lexicon",
",",
"table",
",",
"paradigm",
",",
"paradigms",
",",
"identifier",
",",
"baseform",
",",
"pos",
",",
"classes",
",",
"ppriorv",
"=",
"None",
",",
"newword",
"=",
"False",
",",
"newpara",
"=",
"False",
")",
":",
... | Check that the given table and identifiers are ok, that the table matches
given paradigm and then add the table to the paradigm,
in karp and internally. | [
"Check",
"that",
"the",
"given",
"table",
"and",
"identifiers",
"are",
"ok",
"that",
"the",
"table",
"matches",
"given",
"paradigm",
"and",
"then",
"add",
"the",
"table",
"to",
"the",
"paradigm",
"in",
"karp",
"and",
"internally",
"."
] | [
"\"\"\"\n Check that the given table and identifiers are ok, that the table matches\n given paradigm and then add the table to the paradigm,\n in karp and internally.\n Args:\n lexicon (str): the lexicon name\n table (str): the comma separated word forms, possibly with msds.\n \... | [
{
"param": "lexicon",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "paradigm",
"type": null
},
{
"param": "paradigms",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "baseform",
"type": null
},
{
"para... | {
"returns": [
{
"docstring": "a tuple (identifier, wf_table, para, v, classes)\nwhere\nidentifier (str): identifier of the table\nwf_table (obj): the formatted inflection table\npara (obj): the paradigm object\nv (list): the variable instances\nclasses (dict): the formatted classes of the word",
"do... |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | lexiconinfo | <not_specific> | def lexiconinfo(lex=''):
" Give information about existing lexicons and their configs "
if lex:
lexconf = lexconfig.get_lexiconconf(lex)
return jsonify(lexconf)
else:
res = []
for lexdict in C.config['all_lexicons']:
lexconf = {'name': lexdict['name'], 'open': lex... | Give information about existing lexicons and their configs | Give information about existing lexicons and their configs | [
"Give",
"information",
"about",
"existing",
"lexicons",
"and",
"their",
"configs"
] | def lexiconinfo(lex=''):
if lex:
lexconf = lexconfig.get_lexiconconf(lex)
return jsonify(lexconf)
else:
res = []
for lexdict in C.config['all_lexicons']:
lexconf = {'name': lexdict['name'], 'open': lexdict.get('open', False)}
res.append(lexconf)
re... | [
"def",
"lexiconinfo",
"(",
"lex",
"=",
"''",
")",
":",
"if",
"lex",
":",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lex",
")",
"return",
"jsonify",
"(",
"lexconf",
")",
"else",
":",
"res",
"=",
"[",
"]",
"for",
"lexdict",
"in",
"C",
... | Give information about existing lexicons and their configs | [
"Give",
"information",
"about",
"existing",
"lexicons",
"and",
"their",
"configs"
] | [
"\" Give information about existing lexicons and their configs \""
] | [
{
"param": "lex",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lex",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | wordinfo | <not_specific> | def wordinfo(word=''):
" Show information for the word infobox "
lexicon = request.args.get('lexicon', C.config['default'])
identifier = word or request.args.get('identifier')
lexconf = lexconfig.get_lexiconconf(lexicon)
obj = helpers.give_info(identifier, lexconf['identifier'],
... | Show information for the word infobox | Show information for the word infobox | [
"Show",
"information",
"for",
"the",
"word",
"infobox"
] | def wordinfo(word=''):
lexicon = request.args.get('lexicon', C.config['default'])
identifier = word or request.args.get('identifier')
lexconf = lexconfig.get_lexiconconf(lexicon)
obj = helpers.give_info(identifier, lexconf['identifier'],
lexconf['lexiconMode'], lexconf["lexic... | [
"def",
"wordinfo",
"(",
"word",
"=",
"''",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"identifier",
"=",
"word",
"or",
"request",
".",
"args",
".",
"get",
"("... | Show information for the word infobox | [
"Show",
"information",
"for",
"the",
"word",
"infobox"
] | [
"\" Show information for the word infobox \"",
"# Get info about paradigm_entries and variable instances",
"# Merge the paradigmentry and the wordentry"
] | [
{
"param": "word",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "word",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | paradigminfo | <not_specific> | def paradigminfo(paradigm=''):
" Show information for the paradigm infobox "
lexicon = request.args.get('lexicon', C.config['default'])
paradigm = request.args.get('paradigm', paradigm)
lexconf = lexconfig.get_lexiconconf(lexicon)
# short: only show top 5 variable instances
short = request.args.... | Show information for the paradigm infobox | Show information for the paradigm infobox | [
"Show",
"information",
"for",
"the",
"paradigm",
"infobox"
] | def paradigminfo(paradigm=''):
lexicon = request.args.get('lexicon', C.config['default'])
paradigm = request.args.get('paradigm', paradigm)
lexconf = lexconfig.get_lexiconconf(lexicon)
short = request.args.get('short', '')
short = short in [True, 'true', 'True']
show = pp.show_short() if short e... | [
"def",
"paradigminfo",
"(",
"paradigm",
"=",
"''",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"paradigm",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'paradi... | Show information for the paradigm infobox | [
"Show",
"information",
"for",
"the",
"paradigm",
"infobox"
] | [
"\" Show information for the paradigm infobox \"",
"# short: only show top 5 variable instances"
] | [
{
"param": "paradigm",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "paradigm",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | all_pos | <not_specific> | def all_pos():
" Show all part of speech tags that the lexicon use "
lexicon = request.args.get('lexicon', C.config['default'])
# authentication is only needed when karp is not involved
helpers.authenticate(lexicon, 'read')
# TODO also give combined info about tags in (the karp) lexicon
# that a... | Show all part of speech tags that the lexicon use | Show all part of speech tags that the lexicon use | [
"Show",
"all",
"part",
"of",
"speech",
"tags",
"that",
"the",
"lexicon",
"use"
] | def all_pos():
lexicon = request.args.get('lexicon', C.config['default'])
helpers.authenticate(lexicon, 'read')
logging.debug('ok %s', list(paradigmdict[lexicon].keys()))
return jsonify({"partOfSpeech": list(paradigmdict[lexicon].keys())}) | [
"def",
"all_pos",
"(",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"helpers",
".",
"authenticate",
"(",
"lexicon",
",",
"'read'",
")",
"logging",
".",
"debug",
"... | Show all part of speech tags that the lexicon use | [
"Show",
"all",
"part",
"of",
"speech",
"tags",
"that",
"the",
"lexicon",
"use"
] | [
"\" Show all part of speech tags that the lexicon use \"",
"# authentication is only needed when karp is not involved",
"# TODO also give combined info about tags in (the karp) lexicon",
"# that are not shown in mfl?"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | inflectclass | <not_specific> | def inflectclass():
" Inflect a word according to a user defined category "
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
word = request.args.get('wordform', '')
# ppriorv: setting for pextract
ppriorv = float(request.args.get('pprior', l... | Inflect a word according to a user defined category | Inflect a word according to a user defined category | [
"Inflect",
"a",
"word",
"according",
"to",
"a",
"user",
"defined",
"category"
] | def inflectclass():
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
word = request.args.get('wordform', '')
ppriorv = float(request.args.get('pprior', lexconf["pprior"]))
classname = request.args.get('classname', '')
classval = request.args... | [
"def",
"inflectclass",
"(",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lexicon",
")",
"word",
"=",
"req... | Inflect a word according to a user defined category | [
"Inflect",
"a",
"word",
"according",
"to",
"a",
"user",
"defined",
"category"
] | [
"\" Inflect a word according to a user defined category \"",
"# ppriorv: setting for pextract",
"# ask karp to filter out matching paradigm's IDs",
"# get the internal objects for these paradigms",
"# get the provided variable instances, if any",
"# Special case: '?classname=paradigm&classval=p14_oxe..nn.... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | inflectlike | <not_specific> | def inflectlike():
" Inflect a word similarly to another word "
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
# the word to inflect
word = request.args.get('wordform', '')
pos = helpers.read_one_pos(lexconf)
# the word (or word form) ... | Inflect a word similarly to another word | Inflect a word similarly to another word | [
"Inflect",
"a",
"word",
"similarly",
"to",
"another",
"word"
] | def inflectlike():
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
word = request.args.get('wordform', '')
pos = helpers.read_one_pos(lexconf)
like = request.args.get('like')
logging.debug('like %s', like)
ppriorv = float(request.args.g... | [
"def",
"inflectlike",
"(",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lexicon",
")",
"word",
"=",
"requ... | Inflect a word similarly to another word | [
"Inflect",
"a",
"word",
"similarly",
"to",
"another",
"word"
] | [
"\" Inflect a word similarly to another word \"",
"# the word to inflect",
"# the word (or word form) with known inflection",
"# ppriorv: setting for pextract",
"# ask karp to filter out the paradigm's ID",
"# get the internal objects for these paradigms",
"# is the given form necessarily the baseform?"... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | inflectcandidate | <not_specific> | def inflectcandidate():
" Inflect a known candidate according to it's assigned paradigms "
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
identifier = request.args.get('identifier', '')
# ask karp for the saved candidates and its assigned para... | Inflect a known candidate according to it's assigned paradigms | Inflect a known candidate according to it's assigned paradigms | [
"Inflect",
"a",
"known",
"candidate",
"according",
"to",
"it",
"'",
"s",
"assigned",
"paradigms"
] | def inflectcandidate():
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
identifier = request.args.get('identifier', '')
q = 'extended||and|%s.search|equals|%s' % ('identifier', identifier)
res = helpers.karp_query('query', query={'q': q},
... | [
"def",
"inflectcandidate",
"(",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lexicon",
")",
"identifier",
"... | Inflect a known candidate according to it's assigned paradigms | [
"Inflect",
"a",
"known",
"candidate",
"according",
"to",
"it",
"'",
"s",
"assigned",
"paradigms"
] | [
"\" Inflect a known candidate according to it's assigned paradigms \"",
"# ask karp for the saved candidates and its assigned paradigms",
"# go through each possible paradigm",
"# get the variable instansiation",
"# get the paradigm with the given ID",
"# the paradigm might be removed, then skip it",
"#... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | listing | <not_specific> | def listing():
"""
Make a short listing of possible values. Used for population dropdowns
Possible values to list: class, wf/wordform, paradigm
"""
q = request.args.get('q', '') # querystring
s = request.args.get('c', '*') # compilation field
lexicon = request.args.get('lexicon', C.config[... |
Make a short listing of possible values. Used for population dropdowns
Possible values to list: class, wf/wordform, paradigm
| Make a short listing of possible values. Used for population dropdowns
Possible values to list: class, wf/wordform, paradigm | [
"Make",
"a",
"short",
"listing",
"of",
"possible",
"values",
".",
"Used",
"for",
"population",
"dropdowns",
"Possible",
"values",
"to",
"list",
":",
"class",
"wf",
"/",
"wordform",
"paradigm"
] | def listing():
q = request.args.get('q', '')
s = request.args.get('c', '*')
lexicon = request.args.get('lexicon', C.config['default'])
size = request.args.get('size', '100')
lexconf = lexconfig.get_lexiconconf(lexicon)
pos = helpers.read_pos(lexconf)
query = []
if pos:
quer... | [
"def",
"listing",
"(",
")",
":",
"q",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'q'",
",",
"''",
")",
"s",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'c'",
",",
"'*'",
")",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'l... | Make a short listing of possible values. | [
"Make",
"a",
"short",
"listing",
"of",
"possible",
"values",
"."
] | [
"\"\"\"\n Make a short listing of possible values. Used for population dropdowns\n Possible values to list: class, wf/wordform, paradigm\n \"\"\"",
"# querystring",
"# compilation field",
"# will contain all parts of the karp query",
"# if pos tag(s) is given, filter out this/these",
"# list all ... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | compile | <not_specific> | def compile():
"""
Make a compilation, possible filtered. Contains more information than /list
Possible values to compile: class, wf/wordform, paradigm
"""
querystr = request.args.get('q', '') # querystring
search_f = request.args.get('s', '') # search field
compile_f = request.args.get('c... |
Make a compilation, possible filtered. Contains more information than /list
Possible values to compile: class, wf/wordform, paradigm
| Make a compilation, possible filtered. Contains more information than /list
Possible values to compile: class, wf/wordform, paradigm | [
"Make",
"a",
"compilation",
"possible",
"filtered",
".",
"Contains",
"more",
"information",
"than",
"/",
"list",
"Possible",
"values",
"to",
"compile",
":",
"class",
"wf",
"/",
"wordform",
"paradigm"
] | def compile():
querystr = request.args.get('q', '')
search_f = request.args.get('s', '')
compile_f = request.args.get('c', '')
isfilter = request.args.get('filter', '')
isfilter = isfilter in ['true', 'True', True]
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = le... | [
"def",
"compile",
"(",
")",
":",
"querystr",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'q'",
",",
"''",
")",
"search_f",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'s'",
",",
"''",
")",
"compile_f",
"=",
"request",
".",
"args",
".",
"get... | Make a compilation, possible filtered. | [
"Make",
"a",
"compilation",
"possible",
"filtered",
"."
] | [
"\"\"\"\n Make a compilation, possible filtered. Contains more information than /list\n Possible values to compile: class, wf/wordform, paradigm\n \"\"\"",
"# querystring",
"# search field",
"# compilation field",
"# if isfilter is true, the given query string will searched for as a",
"# substrin... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | update_table | <not_specific> | def update_table():
"""
Update the inflection table of a word.
Also update/add the corresponding paradigm, and remove the word
from the old paradigm.
"""
identifier = request.args.get('identifier', '')
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_le... |
Update the inflection table of a word.
Also update/add the corresponding paradigm, and remove the word
from the old paradigm.
| Update the inflection table of a word.
Also update/add the corresponding paradigm, and remove the word
from the old paradigm. | [
"Update",
"the",
"inflection",
"table",
"of",
"a",
"word",
".",
"Also",
"update",
"/",
"add",
"the",
"corresponding",
"paradigm",
"and",
"remove",
"the",
"word",
"from",
"the",
"old",
"paradigm",
"."
] | def update_table():
identifier = request.args.get('identifier', '')
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
pos = helpers.read_one_pos(lexconf)
old_para = helpers.get_current_paradigm(identifier, pos, lexconf, paradigmdict)
table = ... | [
"def",
"update_table",
"(",
")",
":",
"identifier",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'identifier'",
",",
"''",
")",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")... | Update the inflection table of a word. | [
"Update",
"the",
"inflection",
"table",
"of",
"a",
"word",
"."
] | [
"\"\"\"\n Update the inflection table of a word.\n Also update/add the corresponding paradigm, and remove the word\n from the old paradigm.\n \"\"\"",
"# remove from the old paradigm",
"# make inflection, assign to the new paradigm",
"# ask karp for the word's ID",
"# save the inflection table ... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | remove_table | <not_specific> | def remove_table():
"""
Remove the inflection table of a word (ie the whole entry).
Also remove the word from its paradigm.
"""
identifier = request.args.get('identifier', '')
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
pos = h... |
Remove the inflection table of a word (ie the whole entry).
Also remove the word from its paradigm.
| Remove the inflection table of a word .
Also remove the word from its paradigm. | [
"Remove",
"the",
"inflection",
"table",
"of",
"a",
"word",
".",
"Also",
"remove",
"the",
"word",
"from",
"its",
"paradigm",
"."
] | def remove_table():
identifier = request.args.get('identifier', '')
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
pos = helpers.read_one_pos(lexconf)
para = helpers.get_current_paradigm(identifier, pos, lexconf, paradigmdict)
handle.remov... | [
"def",
"remove_table",
"(",
")",
":",
"identifier",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'identifier'",
",",
"''",
")",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")... | Remove the inflection table of a word (ie the whole entry). | [
"Remove",
"the",
"inflection",
"table",
"of",
"a",
"word",
"(",
"ie",
"the",
"whole",
"entry",
")",
"."
] | [
"\"\"\"\n Remove the inflection table of a word (ie the whole entry).\n Also remove the word from its paradigm.\n \"\"\"",
"# remove from the old paradigm",
"# ask karp for the word's ID",
"# save the inflection table in karp",
"# TODO"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | add_table | <not_specific> | def add_table():
"""
Add a word (an inflection table).
Also update/add the corresponding paradigm.
"""
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
pos = helpers.read_one_pos(lexconf)
table = request.args.get('table', '')
par... |
Add a word (an inflection table).
Also update/add the corresponding paradigm.
| Add a word (an inflection table).
Also update/add the corresponding paradigm. | [
"Add",
"a",
"word",
"(",
"an",
"inflection",
"table",
")",
".",
"Also",
"update",
"/",
"add",
"the",
"corresponding",
"paradigm",
"."
] | def add_table():
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
pos = helpers.read_one_pos(lexconf)
table = request.args.get('table', '')
paradigm = request.args.get('paradigm', '')
identifier = request.args.get('identifier', '')
basef... | [
"def",
"add_table",
"(",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lexicon",
")",
"pos",
"=",
"helpers... | Add a word (an inflection table). | [
"Add",
"a",
"word",
"(",
"an",
"inflection",
"table",
")",
"."
] | [
"\"\"\"\n Add a word (an inflection table).\n Also update/add the corresponding paradigm.\n \"\"\"",
"# make inflection, assign to the paradigm",
"# add the inflection to karp"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | removecandidate | <not_specific> | def removecandidate(_id=''):
"""
Remove a candidate from the candidate list
Use with the lexcion's identifiers
/removecandidate?identifier=katt..nn.1
"""
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
try:
identifier = ... |
Remove a candidate from the candidate list
Use with the lexcion's identifiers
/removecandidate?identifier=katt..nn.1
| Remove a candidate from the candidate list
Use with the lexcion's identifiers
removecandidate?identifier=katt..nn.1 | [
"Remove",
"a",
"candidate",
"from",
"the",
"candidate",
"list",
"Use",
"with",
"the",
"lexcion",
"'",
"s",
"identifiers",
"removecandidate?identifier",
"=",
"katt",
"..",
"nn",
".",
"1"
] | def removecandidate(_id=''):
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
try:
identifier = request.args.get('identifier', '')
q = 'extended||and|%s.search|equals|%s' % ('identifier', identifier)
res = helpers.karp_query('que... | [
"def",
"removecandidate",
"(",
"_id",
"=",
"''",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lexicon",
"... | Remove a candidate from the candidate list
Use with the lexcion's identifiers
removecandidate?identifier=katt..nn.1 | [
"Remove",
"a",
"candidate",
"from",
"the",
"candidate",
"list",
"Use",
"with",
"the",
"lexcion",
"'",
"s",
"identifiers",
"removecandidate?identifier",
"=",
"katt",
"..",
"nn",
".",
"1"
] | [
"\"\"\"\n Remove a candidate from the candidate list\n Use with the lexcion's identifiers\n /removecandidate?identifier=katt..nn.1\n \"\"\"",
"# ask karp for the identifier",
"# delete it"
] | [
{
"param": "_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7a59ff8072a73caaadb160e240b6bc2b6c018cb4 | spraakbanken/karp-mfl | mflbackend/src/backend.py | [
"MIT"
] | Python | recomputecandiadtes | <not_specific> | def recomputecandiadtes():
"""
Recompute the candidates' paradigm assignments
Returns the number of candidates that have been updated
"""
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
postags = helpers.read_pos(lexconf)
# pprior... |
Recompute the candidates' paradigm assignments
Returns the number of candidates that have been updated
| Recompute the candidates' paradigm assignments
Returns the number of candidates that have been updated | [
"Recompute",
"the",
"candidates",
"'",
"paradigm",
"assignments",
"Returns",
"the",
"number",
"of",
"candidates",
"that",
"have",
"been",
"updated"
] | def recomputecandiadtes():
lexicon = request.args.get('lexicon', C.config['default'])
lexconf = lexconfig.get_lexiconconf(lexicon)
postags = helpers.read_pos(lexconf)
ppriorv = float(request.args.get('pprior', lexconf["pprior"]))
counter = 0
for pos in postags:
q = 'extended||and|%s.sear... | [
"def",
"recomputecandiadtes",
"(",
")",
":",
"lexicon",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'lexicon'",
",",
"C",
".",
"config",
"[",
"'default'",
"]",
")",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lexicon",
")",
"postags",
"... | Recompute the candidates' paradigm assignments
Returns the number of candidates that have been updated | [
"Recompute",
"the",
"candidates",
"'",
"paradigm",
"assignments",
"Returns",
"the",
"number",
"of",
"candidates",
"that",
"have",
"been",
"updated"
] | [
"\"\"\"\n Recompute the candidates' paradigm assignments\n Returns the number of candidates that have been updated\n \"\"\"",
"# ppriorv: setting for pextract",
"# ask karp for all relevant candidates",
"# get all relevant paradigms",
"# go through the candidates",
"# construct a pextract table... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
ef27d96147fd1cd5adcb0f8bd135f3efc3885969 | spraakbanken/karp-mfl | mflbackend/config/votiska_convert.py | [
"MIT"
] | Python | karp_wftableize | <not_specific> | def karp_wftableize(paradigm, table, classes={}, baseform='', identifier='',
pos='', resource=''):
" Url table format -> LMF format"
table = table.split(',')
obj = {'lexiconName': resource}
wfs = []
for l in table:
if '|' in l:
form, tag = l.split('|')
... | Url table format -> LMF format | Url table format -> LMF format | [
"Url",
"table",
"format",
"-",
">",
"LMF",
"format"
] | def karp_wftableize(paradigm, table, classes={}, baseform='', identifier='',
pos='', resource=''):
table = table.split(',')
obj = {'lexiconName': resource}
wfs = []
for l in table:
if '|' in l:
form, tag = l.split('|')
else:
form = l
... | [
"def",
"karp_wftableize",
"(",
"paradigm",
",",
"table",
",",
"classes",
"=",
"{",
"}",
",",
"baseform",
"=",
"''",
",",
"identifier",
"=",
"''",
",",
"pos",
"=",
"''",
",",
"resource",
"=",
"''",
")",
":",
"table",
"=",
"table",
".",
"split",
"(",... | Url table format -> LMF format | [
"Url",
"table",
"format",
"-",
">",
"LMF",
"format"
] | [
"\" Url table format -> LMF format\""
] | [
{
"param": "paradigm",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "classes",
"type": null
},
{
"param": "baseform",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "r... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "paradigm",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_token... |
4b2f16f45f5bb3d435a557397faad08da0ce3bd9 | spraakbanken/karp-mfl | mflbackend/config/saolp_convert.py | [
"MIT"
] | Python | karp_wftableize | <not_specific> | def karp_wftableize(paradigm, table, classes={}, baseform='', identifier='',
pos='', resource=''):
" Url table format -> LMF format"
table = table.split(',')
obj = {'lexiconName': resource}
wfs = []
for l in table:
if '|' in l:
form, tag = l.split('|')
... | Url table format -> LMF format | Url table format -> LMF format | [
"Url",
"table",
"format",
"-",
">",
"LMF",
"format"
] | def karp_wftableize(paradigm, table, classes={}, baseform='', identifier='',
pos='', resource=''):
table = table.split(',')
obj = {'lexiconName': resource}
wfs = []
for l in table:
if '|' in l:
form, tag = l.split('|')
else:
form = l
... | [
"def",
"karp_wftableize",
"(",
"paradigm",
",",
"table",
",",
"classes",
"=",
"{",
"}",
",",
"baseform",
"=",
"''",
",",
"identifier",
"=",
"''",
",",
"pos",
"=",
"''",
",",
"resource",
"=",
"''",
")",
":",
"table",
"=",
"table",
".",
"split",
"(",... | Url table format -> LMF format | [
"Url",
"table",
"format",
"-",
">",
"LMF",
"format"
] | [
"\" Url table format -> LMF format\"",
"# TODO will change in the future, make better structure for msd",
"# tag = tag[1:] if tag.startswith('*') else tag"
] | [
{
"param": "paradigm",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "classes",
"type": null
},
{
"param": "baseform",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "r... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "paradigm",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_token... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | search_q | <not_specific> | def search_q(fullquery, searchfield, q, lexicon, isfilter=False):
"""
Construct a Karp query string.
Args:
fullquery (list): previously composed queries
searchfield (str): a karp search field
q (str): a term to search for
lexicon (str): the lexicon to search
isfilter ... |
Construct a Karp query string.
Args:
fullquery (list): previously composed queries
searchfield (str): a karp search field
q (str): a term to search for
lexicon (str): the lexicon to search
isfilter (bool, optional): search for q as a substring if true.
Defaul... | Construct a Karp query string. | [
"Construct",
"a",
"Karp",
"query",
"string",
"."
] | def search_q(fullquery, searchfield, q, lexicon, isfilter=False):
if q:
operator = 'equals' if not isfilter else 'regexp'
if isfilter:
q = '.*'+q+'.*'
logging.debug('q is %s', q)
fullquery.append('and|%s.search|%s|%s' % (searchfield, operator, q))
if fullquery:
... | [
"def",
"search_q",
"(",
"fullquery",
",",
"searchfield",
",",
"q",
",",
"lexicon",
",",
"isfilter",
"=",
"False",
")",
":",
"if",
"q",
":",
"operator",
"=",
"'equals'",
"if",
"not",
"isfilter",
"else",
"'regexp'",
"if",
"isfilter",
":",
"q",
"=",
"'.*'... | Construct a Karp query string. | [
"Construct",
"a",
"Karp",
"query",
"string",
"."
] | [
"\"\"\"\n Construct a Karp query string.\n Args:\n fullquery (list): previously composed queries\n searchfield (str): a karp search field\n q (str): a term to search for\n lexicon (str): the lexicon to search\n isfilter (bool, optional): search for q as a substring if true.\... | [
{
"param": "fullquery",
"type": null
},
{
"param": "searchfield",
"type": null
},
{
"param": "q",
"type": null
},
{
"param": "lexicon",
"type": null
},
{
"param": "isfilter",
"type": null
}
] | {
"returns": [
{
"docstring": "fullquery (list): the input fullquery list, with the new query appended.",
"docstring_tokens": [
"fullquery",
"(",
"list",
")",
":",
"the",
"input",
"fullquery",
"list",
"with",
"the"... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | multi_query | <not_specific> | def multi_query(lexicon, fullquery, fields, query, isfilter):
"""
Construct a Karp query string, searching for different terms in different
fields.
Args:
lexicon (str): the lexicon name
fullquery (list): previously composed queries
fields (list): a list of fields to search
... |
Construct a Karp query string, searching for different terms in different
fields.
Args:
lexicon (str): the lexicon name
fullquery (list): previously composed queries
fields (list): a list of fields to search
query (list): a list of terms to search for
isfilter (bool,... | Construct a Karp query string, searching for different terms in different
fields. | [
"Construct",
"a",
"Karp",
"query",
"string",
"searching",
"for",
"different",
"terms",
"in",
"different",
"fields",
"."
] | def multi_query(lexicon, fullquery, fields, query, isfilter):
operator = 'equals' if not isfilter else 'regexp'
for ix, field in enumerate(fields):
q = query[ix]
if isfilter:
q = '.*'+q+'.*'
fullquery.append('and|%s.search|%s|%s' %
(lexconfig.get_fiel... | [
"def",
"multi_query",
"(",
"lexicon",
",",
"fullquery",
",",
"fields",
",",
"query",
",",
"isfilter",
")",
":",
"operator",
"=",
"'equals'",
"if",
"not",
"isfilter",
"else",
"'regexp'",
"for",
"ix",
",",
"field",
"in",
"enumerate",
"(",
"fields",
")",
":... | Construct a Karp query string, searching for different terms in different
fields. | [
"Construct",
"a",
"Karp",
"query",
"string",
"searching",
"for",
"different",
"terms",
"in",
"different",
"fields",
"."
] | [
"\"\"\"\n Construct a Karp query string, searching for different terms in different\n fields.\n Args:\n lexicon (str): the lexicon name\n fullquery (list): previously composed queries\n fields (list): a list of fields to search\n query (list): a list of terms to search for\n ... | [
{
"param": "lexicon",
"type": null
},
{
"param": "fullquery",
"type": null
},
{
"param": "fields",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "isfilter",
"type": null
}
] | {
"returns": [
{
"docstring": "fullquery (list): the input fullquery list, with the new query appended.",
"docstring_tokens": [
"fullquery",
"(",
"list",
")",
":",
"the",
"input",
"fullquery",
"list",
"with",
"the"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.