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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d67dc0d83b5247f7d3c050aeb5c25a8cbd1e1095 | PradeepThapa/FewShotDetection | lib/datasets/metadata_coco.py | [
"MIT"
] | Python | image_path_from_index | <not_specific> | def image_path_from_index(self, index):
"""
Construct an image path from the image's "index" identifier.
"""
# Example image path for index=119993:
# images/train2014/COCO_train2014_000000119993.jpg
if self._year == '2017':
file_name = str(index).zfill(12) ... |
Construct an image path from the image's "index" identifier.
| Construct an image path from the image's "index" identifier. | [
"Construct",
"an",
"image",
"path",
"from",
"the",
"image",
"'",
"s",
"\"",
"index",
"\"",
"identifier",
"."
] | def image_path_from_index(self, index):
if self._year == '2017':
file_name = str(index).zfill(12) + '.jpg'
elif self._year == '2014':
file_name = ('COCO_' + self._data_name + '_' + str(index).zfill(12) + '.jpg')
image_path = osp.join(self._data_path, 'images', self._data_... | [
"def",
"image_path_from_index",
"(",
"self",
",",
"index",
")",
":",
"if",
"self",
".",
"_year",
"==",
"'2017'",
":",
"file_name",
"=",
"str",
"(",
"index",
")",
".",
"zfill",
"(",
"12",
")",
"+",
"'.jpg'",
"elif",
"self",
".",
"_year",
"==",
"'2014'... | Construct an image path from the image's "index" identifier. | [
"Construct",
"an",
"image",
"path",
"from",
"the",
"image",
"'",
"s",
"\"",
"index",
"\"",
"identifier",
"."
] | [
"\"\"\"\n Construct an image path from the image's \"index\" identifier.\n \"\"\"",
"# Example image path for index=119993:",
"# images/train2014/COCO_train2014_000000119993.jpg"
] | [
{
"param": "self",
"type": null
},
{
"param": "index",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "index",
"type": null,
"docstring": null,
"docstring_tokens": ... |
a0dc6ca1dd5e9090ba694a26d440fcf677983ba6 | hakrosabir/cnn-dog-breed-classifier | misc.py | [
"MIT"
] | Python | train | null | def train(n_epochs, loaders, model, optimizer, criterion, device, path_model, fivecrop = None, lr_scheduler = None):
"""Trains, validates, and saves the model and other data in a file"""
# initialize tracker for minimum validation loss
valid_loss_min = np.Inf
train_loss = []
valid_loss = []
pat... | Trains, validates, and saves the model and other data in a file | Trains, validates, and saves the model and other data in a file | [
"Trains",
"validates",
"and",
"saves",
"the",
"model",
"and",
"other",
"data",
"in",
"a",
"file"
] | def train(n_epochs, loaders, model, optimizer, criterion, device, path_model, fivecrop = None, lr_scheduler = None):
valid_loss_min = np.Inf
train_loss = []
valid_loss = []
path_state_dict = f"./temp/temp_state_dict_{str(int(np.abs(np.random.randn()) * 1e12))}.pt"
time_start = time.time()
for e... | [
"def",
"train",
"(",
"n_epochs",
",",
"loaders",
",",
"model",
",",
"optimizer",
",",
"criterion",
",",
"device",
",",
"path_model",
",",
"fivecrop",
"=",
"None",
",",
"lr_scheduler",
"=",
"None",
")",
":",
"valid_loss_min",
"=",
"np",
".",
"Inf",
"train... | Trains, validates, and saves the model and other data in a file | [
"Trains",
"validates",
"and",
"saves",
"the",
"model",
"and",
"other",
"data",
"in",
"a",
"file"
] | [
"\"\"\"Trains, validates, and saves the model and other data in a file\"\"\"",
"# initialize tracker for minimum validation loss",
"# Time everything",
"# Train this epoch",
"# Validate this epoch",
"# Call the learning rate scheduler if we have one",
"# Save if validation loss is the lowest so far",
... | [
{
"param": "n_epochs",
"type": null
},
{
"param": "loaders",
"type": null
},
{
"param": "model",
"type": null
},
{
"param": "optimizer",
"type": null
},
{
"param": "criterion",
"type": null
},
{
"param": "device",
"type": null
},
{
"param":... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "n_epochs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "loaders",
"type": null,
"docstring": null,
"docstring_tok... |
fe3282cf1640417288a3600bf016cd72d2c70eaa | EniMiniGames/MC-Server-VPS-Scripts | sftp_utils.py | [
"MIT"
] | Python | put_dir_approved_list | null | def put_dir_approved_list(self, source, target, approved):
"""
Uploads the contents of the list to the target path. The
target directory needs to exists. All subdirectories in source are
created under target.
"""
# Replace forward slash in case of Windows
... |
Uploads the contents of the list to the target path. The
target directory needs to exists. All subdirectories in source are
created under target.
| Uploads the contents of the list to the target path. The
target directory needs to exists. All subdirectories in source are
created under target. | [
"Uploads",
"the",
"contents",
"of",
"the",
"list",
"to",
"the",
"target",
"path",
".",
"The",
"target",
"directory",
"needs",
"to",
"exists",
".",
"All",
"subdirectories",
"in",
"source",
"are",
"created",
"under",
"target",
"."
] | def put_dir_approved_list(self, source, target, approved):
approved = [i.replace("\\", "/") for i in approved]
for item in os.listdir(source):
full_path = os.path.join(source, item)
full_path = full_path.replace("\\", "/")
full_path = full_path[2:] if full_path.starts... | [
"def",
"put_dir_approved_list",
"(",
"self",
",",
"source",
",",
"target",
",",
"approved",
")",
":",
"approved",
"=",
"[",
"i",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
")",
"for",
"i",
"in",
"approved",
"]",
"for",
"item",
"in",
"os",
".",
"l... | Uploads the contents of the list to the target path. | [
"Uploads",
"the",
"contents",
"of",
"the",
"list",
"to",
"the",
"target",
"path",
"."
] | [
"\"\"\"\n Uploads the contents of the list to the target path. The\n target directory needs to exists. All subdirectories in source are\n created under target.\n \"\"\"",
"# Replace forward slash in case of Windows",
"# aa/bb/cc.dd",
"# print(\"This means file isn't approve... | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "approved",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens":... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | read_csv_with_pandas | <not_specific> | def read_csv_with_pandas(filename):
"""
Function written by Joe Muller, Digital Publishing Coordinator,
during troubleshooting with Scott St. Louis. November 13, 2020.
Opens the CSV file into a DataFrame object,
drops all columns except the ones specified in output_headers,
and convert... |
Function written by Joe Muller, Digital Publishing Coordinator,
during troubleshooting with Scott St. Louis. November 13, 2020.
Opens the CSV file into a DataFrame object,
drops all columns except the ones specified in output_headers,
and converts the DataFrame to a list of row lists.
... | Function written by Joe Muller, Digital Publishing Coordinator,
during troubleshooting with Scott St. Louis.
Opens the CSV file into a DataFrame object,
drops all columns except the ones specified in output_headers,
and converts the DataFrame to a list of row lists. | [
"Function",
"written",
"by",
"Joe",
"Muller",
"Digital",
"Publishing",
"Coordinator",
"during",
"troubleshooting",
"with",
"Scott",
"St",
".",
"Louis",
".",
"Opens",
"the",
"CSV",
"file",
"into",
"a",
"DataFrame",
"object",
"drops",
"all",
"columns",
"except",
... | def read_csv_with_pandas(filename):
df = pd.read_csv(filename,dtype=str)
list_of_row_lists = []
output_headers = [
"uri",
"fm:title",
"marc:245A",
"marc:245B",
"marc:250A",
"ocr:copyrightPage"
]
df = df.reindex(columns = output_headers)
for i in df... | [
"def",
"read_csv_with_pandas",
"(",
"filename",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"filename",
",",
"dtype",
"=",
"str",
")",
"list_of_row_lists",
"=",
"[",
"]",
"output_headers",
"=",
"[",
"\"uri\"",
",",
"\"fm:title\"",
",",
"\"marc:245A\"",
... | Function written by Joe Muller, Digital Publishing Coordinator,
during troubleshooting with Scott St. Louis. | [
"Function",
"written",
"by",
"Joe",
"Muller",
"Digital",
"Publishing",
"Coordinator",
"during",
"troubleshooting",
"with",
"Scott",
"St",
".",
"Louis",
"."
] | [
"\"\"\"\r\n Function written by Joe Muller, Digital Publishing Coordinator,\r\n during troubleshooting with Scott St. Louis. November 13, 2020.\r\n\r\n Opens the CSV file into a DataFrame object,\r\n drops all columns except the ones specified in output_headers,\r\n and converts the DataFrame to a li... | [
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": null,
"docstring": "The name of the CSV file.",
"docstring_tokens": [
"The",
"name",
"of",
"the",
"CSV",
"file",
"."
],
"default": null,
... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | generate_uri_list | <not_specific> | def generate_uri_list(list_of_row_lists):
"""
Generates a list of URIs from the metadata records.
Parameters
----------
filename: str
The name of the CSV file.
Returns
----------
uri_list: list
A list of URIs for each title.
"""
uri_list = []
... |
Generates a list of URIs from the metadata records.
Parameters
----------
filename: str
The name of the CSV file.
Returns
----------
uri_list: list
A list of URIs for each title.
| Generates a list of URIs from the metadata records. | [
"Generates",
"a",
"list",
"of",
"URIs",
"from",
"the",
"metadata",
"records",
"."
] | def generate_uri_list(list_of_row_lists):
uri_list = []
for row in list_of_row_lists:
uri = row[0]
uri_list.append(uri)
return uri_list | [
"def",
"generate_uri_list",
"(",
"list_of_row_lists",
")",
":",
"uri_list",
"=",
"[",
"]",
"for",
"row",
"in",
"list_of_row_lists",
":",
"uri",
"=",
"row",
"[",
"0",
"]",
"uri_list",
".",
"append",
"(",
"uri",
")",
"return",
"uri_list"
] | Generates a list of URIs from the metadata records. | [
"Generates",
"a",
"list",
"of",
"URIs",
"from",
"the",
"metadata",
"records",
"."
] | [
"\"\"\"\r\n Generates a list of URIs from the metadata records.\r\n\r\n Parameters\r\n ----------\r\n filename: str\r\n The name of the CSV file.\r\n\r\n Returns\r\n ----------\r\n uri_list: list\r\n A list of URIs for each title.\r\n \"\"\""
] | [
{
"param": "list_of_row_lists",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_of_row_lists",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [
{
"identifier": "filename",
"type": null,
"do... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | curating_metadata | <not_specific> | def curating_metadata(list_of_row_lists):
"""
Cleans metadata records read into the program
from input CSV.
Parameters
----------
list_of_row_lists: list
A list of the metadata records returned
from the original CSV.
Returns
----------
curated_metadat... |
Cleans metadata records read into the program
from input CSV.
Parameters
----------
list_of_row_lists: list
A list of the metadata records returned
from the original CSV.
Returns
----------
curated_metadata_records: list of lists
A list of curate... | Cleans metadata records read into the program
from input CSV. | [
"Cleans",
"metadata",
"records",
"read",
"into",
"the",
"program",
"from",
"input",
"CSV",
"."
] | def curating_metadata(list_of_row_lists):
curated_metadata_records = []
for row in list_of_row_lists:
full_title = row[1]
full_title = full_title.strip()
if full_title.startswith("A ") == True:
title_prefix = "A"
elif full_title.startswith("An ") == True:
... | [
"def",
"curating_metadata",
"(",
"list_of_row_lists",
")",
":",
"curated_metadata_records",
"=",
"[",
"]",
"for",
"row",
"in",
"list_of_row_lists",
":",
"full_title",
"=",
"row",
"[",
"1",
"]",
"full_title",
"=",
"full_title",
".",
"strip",
"(",
")",
"if",
"... | Cleans metadata records read into the program
from input CSV. | [
"Cleans",
"metadata",
"records",
"read",
"into",
"the",
"program",
"from",
"input",
"CSV",
"."
] | [
"\"\"\"\r\n Cleans metadata records read into the program\r\n from input CSV.\r\n\r\n Parameters\r\n ----------\r\n list_of_row_lists: list\r\n A list of the metadata records returned\r\n from the original CSV.\r\n\r\n\r\n Returns\r\n ----------\r\n curated_metadata_records: li... | [
{
"param": "list_of_row_lists",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_of_row_lists",
"type": null,
"docstring": "A list of the metadata records returned\nfrom the original CSV.",
"docstring_tokens": [
"A",
"list",
"of",
"the",
"metadata",
"rec... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | sifting_metadata_for_volume_info | <not_specific> | def sifting_metadata_for_volume_info(list_of_row_lists):
"""
Sifts full title values in metadata records for which
to look for keywords relevant to potential volume information.
Parameters
----------
list_of_row_lists: list
A list of the metadata records returned
from t... |
Sifts full title values in metadata records for which
to look for keywords relevant to potential volume information.
Parameters
----------
list_of_row_lists: list
A list of the metadata records returned
from the original CSV.
Returns
----------
check_full_t... | Sifts full title values in metadata records for which
to look for keywords relevant to potential volume information. | [
"Sifts",
"full",
"title",
"values",
"in",
"metadata",
"records",
"for",
"which",
"to",
"look",
"for",
"keywords",
"relevant",
"to",
"potential",
"volume",
"information",
"."
] | def sifting_metadata_for_volume_info(list_of_row_lists):
full_title_list = []
check_full_titles_for_volume_info = []
for row in list_of_row_lists:
full_title = row[1]
clean_full_title = str(full_title).lower()
cleaner_full_title = clean_full_title.replace("\n", "")
cleanest_f... | [
"def",
"sifting_metadata_for_volume_info",
"(",
"list_of_row_lists",
")",
":",
"full_title_list",
"=",
"[",
"]",
"check_full_titles_for_volume_info",
"=",
"[",
"]",
"for",
"row",
"in",
"list_of_row_lists",
":",
"full_title",
"=",
"row",
"[",
"1",
"]",
"clean_full_ti... | Sifts full title values in metadata records for which
to look for keywords relevant to potential volume information. | [
"Sifts",
"full",
"title",
"values",
"in",
"metadata",
"records",
"for",
"which",
"to",
"look",
"for",
"keywords",
"relevant",
"to",
"potential",
"volume",
"information",
"."
] | [
"\"\"\"\r\n Sifts full title values in metadata records for which\r\n to look for keywords relevant to potential volume information.\r\n\r\n Parameters\r\n ----------\r\n list_of_row_lists: list\r\n A list of the metadata records returned\r\n from the original CSV.\r\n\r\n Returns\r\... | [
{
"param": "list_of_row_lists",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_of_row_lists",
"type": null,
"docstring": "A list of the metadata records returned\nfrom the original CSV.",
"docstring_tokens": [
"A",
"list",
"of",
"the",
"metadata",
"rec... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | sifting_metadata_for_edition_info | <not_specific> | def sifting_metadata_for_edition_info(list_of_row_lists):
"""
Sifts copyright OCR text in metadata records to look for keywords
relevant to potential edition information.
Parameters
----------
list_of_row_lists: list
A list of the metadata records returned
from the orig... |
Sifts copyright OCR text in metadata records to look for keywords
relevant to potential edition information.
Parameters
----------
list_of_row_lists: list
A list of the metadata records returned
from the original CSV.
Returns
----------
check_copyright_ocr_... | Sifts copyright OCR text in metadata records to look for keywords
relevant to potential edition information. | [
"Sifts",
"copyright",
"OCR",
"text",
"in",
"metadata",
"records",
"to",
"look",
"for",
"keywords",
"relevant",
"to",
"potential",
"edition",
"information",
"."
] | def sifting_metadata_for_edition_info(list_of_row_lists):
copyright_ocr_list = []
check_copyright_ocr_for_edition_info = []
for row in list_of_row_lists:
copyright_ocr = row[5]
clean_copyright_ocr = str(copyright_ocr).lower()
cleaner_copyright_ocr = clean_copyright_ocr.replace("\n", ... | [
"def",
"sifting_metadata_for_edition_info",
"(",
"list_of_row_lists",
")",
":",
"copyright_ocr_list",
"=",
"[",
"]",
"check_copyright_ocr_for_edition_info",
"=",
"[",
"]",
"for",
"row",
"in",
"list_of_row_lists",
":",
"copyright_ocr",
"=",
"row",
"[",
"5",
"]",
"cle... | Sifts copyright OCR text in metadata records to look for keywords
relevant to potential edition information. | [
"Sifts",
"copyright",
"OCR",
"text",
"in",
"metadata",
"records",
"to",
"look",
"for",
"keywords",
"relevant",
"to",
"potential",
"edition",
"information",
"."
] | [
"\"\"\"\r\n Sifts copyright OCR text in metadata records to look for keywords\r\n relevant to potential edition information.\r\n\r\n Parameters\r\n ----------\r\n list_of_row_lists: list\r\n A list of the metadata records returned\r\n from the original CSV.\r\n\r\n Returns\r\n ---... | [
{
"param": "list_of_row_lists",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_of_row_lists",
"type": null,
"docstring": "A list of the metadata records returned\nfrom the original CSV.",
"docstring_tokens": [
"A",
"list",
"of",
"the",
"metadata",
"rec... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | sifting_metadata_for_title_differences | <not_specific> | def sifting_metadata_for_title_differences(list_of_row_lists):
"""
Sifts fm and marc title values in metadata records to
look for potential indicators of discrepancies.
The following Stack Overflow page was helpful in producing this function:
"Merge Two Lists to Make List of Lists,"
htt... |
Sifts fm and marc title values in metadata records to
look for potential indicators of discrepancies.
The following Stack Overflow page was helpful in producing this function:
"Merge Two Lists to Make List of Lists,"
https://stackoverflow.com/questions/23327242/merge-two-lists-to-make-list-... | Sifts fm and marc title values in metadata records to
look for potential indicators of discrepancies.
| [
"Sifts",
"fm",
"and",
"marc",
"title",
"values",
"in",
"metadata",
"records",
"to",
"look",
"for",
"potential",
"indicators",
"of",
"discrepancies",
"."
] | def sifting_metadata_for_title_differences(list_of_row_lists):
fm_full_title_list = []
marc_full_title_list = []
check_fm_and_marc_titles_for_differences = []
for row in list_of_row_lists:
fm_full_title = str(row[1]).lower()
clean_fm_full_title = fm_full_title.replace("/n", "")
c... | [
"def",
"sifting_metadata_for_title_differences",
"(",
"list_of_row_lists",
")",
":",
"fm_full_title_list",
"=",
"[",
"]",
"marc_full_title_list",
"=",
"[",
"]",
"check_fm_and_marc_titles_for_differences",
"=",
"[",
"]",
"for",
"row",
"in",
"list_of_row_lists",
":",
"fm_... | Sifts fm and marc title values in metadata records to
look for potential indicators of discrepancies. | [
"Sifts",
"fm",
"and",
"marc",
"title",
"values",
"in",
"metadata",
"records",
"to",
"look",
"for",
"potential",
"indicators",
"of",
"discrepancies",
"."
] | [
"\"\"\"\r\n Sifts fm and marc title values in metadata records to \r\n look for potential indicators of discrepancies.\r\n\r\n The following Stack Overflow page was helpful in producing this function:\r\n \"Merge Two Lists to Make List of Lists,\"\r\n https://stackoverflow.com/questions/23327242/merg... | [
{
"param": "list_of_row_lists",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_of_row_lists",
"type": null,
"docstring": "A list of the metadata records returned\nfrom the original CSV.",
"docstring_tokens": [
"A",
"list",
"of",
"the",
"metadata",
"rec... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | combine_values | <not_specific> | def combine_values(uri_list, check_full_titles_for_volume_info, check_copyright_ocr_for_edition_info, check_fm_and_marc_titles_for_differences):
"""
Creates list of check values corresponding to title URIs.
The following Stack Overflow page was helpful in producing this function:
"Merge Two Lists ... |
Creates list of check values corresponding to title URIs.
The following Stack Overflow page was helpful in producing this function:
"Merge Two Lists to Make List of Lists,"
https://stackoverflow.com/questions/23327242/merge-two-lists-to-make-list-of-lists (accessed October 28, 2020)
Parame... | Creates list of check values corresponding to title URIs. | [
"Creates",
"list",
"of",
"check",
"values",
"corresponding",
"to",
"title",
"URIs",
"."
] | def combine_values(uri_list, check_full_titles_for_volume_info, check_copyright_ocr_for_edition_info, check_fm_and_marc_titles_for_differences):
a = uri_list
b = check_full_titles_for_volume_info
c = check_copyright_ocr_for_edition_info
d = check_fm_and_marc_titles_for_differences
combined_values = ... | [
"def",
"combine_values",
"(",
"uri_list",
",",
"check_full_titles_for_volume_info",
",",
"check_copyright_ocr_for_edition_info",
",",
"check_fm_and_marc_titles_for_differences",
")",
":",
"a",
"=",
"uri_list",
"b",
"=",
"check_full_titles_for_volume_info",
"c",
"=",
"check_co... | Creates list of check values corresponding to title URIs. | [
"Creates",
"list",
"of",
"check",
"values",
"corresponding",
"to",
"title",
"URIs",
"."
] | [
"\"\"\"\r\n Creates list of check values corresponding to title URIs.\r\n\r\n The following Stack Overflow page was helpful in producing this function:\r\n \"Merge Two Lists to Make List of Lists,\"\r\n https://stackoverflow.com/questions/23327242/merge-two-lists-to-make-list-of-lists (accessed October ... | [
{
"param": "uri_list",
"type": null
},
{
"param": "check_full_titles_for_volume_info",
"type": null
},
{
"param": "check_copyright_ocr_for_edition_info",
"type": null
},
{
"param": "check_fm_and_marc_titles_for_differences",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "uri_list",
"type": null,
"docstring": "A list of URIs for each title",
"docstring_tokens": [
"A",
"list",
"of",
"URIs",
"for",
"each",
"title"
],
"default": n... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | write_curated_metadata | <not_specific> | def write_curated_metadata(curated_metadata_records, filename_1):
"""
Cleans metadata records read into the program from input CSV.
Source for help constructing this function:
Jon Fincher, "Reading and Writing CSV Files in Python,"
Real Python, accessed October 13, 2020,
https://realpyth... |
Cleans metadata records read into the program from input CSV.
Source for help constructing this function:
Jon Fincher, "Reading and Writing CSV Files in Python,"
Real Python, accessed October 13, 2020,
https://realpython.com/python-csv/
Parameters
----------
curated_metadata... | Cleans metadata records read into the program from input CSV. | [
"Cleans",
"metadata",
"records",
"read",
"into",
"the",
"program",
"from",
"input",
"CSV",
"."
] | def write_curated_metadata(curated_metadata_records, filename_1):
with open(filename_1, 'w', encoding = 'utf-8') as csv_file:
fieldnames = ["uri", "full_title", "main_title", "subtitle",
"marc_main_title", "marc_subtitle", "title_prefix", "edition", "copyright_ocr",]
writer = csv.DictWriter(... | [
"def",
"write_curated_metadata",
"(",
"curated_metadata_records",
",",
"filename_1",
")",
":",
"with",
"open",
"(",
"filename_1",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"csv_file",
":",
"fieldnames",
"=",
"[",
"\"uri\"",
",",
"\"full_title\"",
... | Cleans metadata records read into the program from input CSV. | [
"Cleans",
"metadata",
"records",
"read",
"into",
"the",
"program",
"from",
"input",
"CSV",
"."
] | [
"\"\"\"\r\n Cleans metadata records read into the program from input CSV.\r\n\r\n Source for help constructing this function:\r\n Jon Fincher, \"Reading and Writing CSV Files in Python,\"\r\n Real Python, accessed October 13, 2020,\r\n https://realpython.com/python-csv/\r\n\r\n Parameters\r\n -... | [
{
"param": "curated_metadata_records",
"type": null
},
{
"param": "filename_1",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "curated_metadata_records",
"type": null,
"docstring": "The list of curated metadata records to be written\nto the desired CSV file.",
"docstring_tokens": [
"The",
"list",
"of",
"curated",
... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | write_sifting_responses | <not_specific> | def write_sifting_responses(combined_values, filename_2):
"""
Writes the check values corresponding to URI onto a spreadsheet.
Source for help constructing this function:
Jon Fincher, "Reading and Writing CSV Files in Python,"
Real Python, accessed October 13, 2020,
https://realpython.co... |
Writes the check values corresponding to URI onto a spreadsheet.
Source for help constructing this function:
Jon Fincher, "Reading and Writing CSV Files in Python,"
Real Python, accessed October 13, 2020,
https://realpython.com/python-csv/
Parameters
----------
combined_valu... | Writes the check values corresponding to URI onto a spreadsheet. | [
"Writes",
"the",
"check",
"values",
"corresponding",
"to",
"URI",
"onto",
"a",
"spreadsheet",
"."
] | def write_sifting_responses(combined_values, filename_2):
with open(filename_2, 'w', encoding = 'utf-8') as csv_file:
fieldnames = ["uri", "check_full_titles_for_volume_info?", "check_copyright_ocr_for_edition_info?", "check_fm_and_marc_titles_for_differences?"]
writer = csv.DictWriter(csv_file, fie... | [
"def",
"write_sifting_responses",
"(",
"combined_values",
",",
"filename_2",
")",
":",
"with",
"open",
"(",
"filename_2",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"csv_file",
":",
"fieldnames",
"=",
"[",
"\"uri\"",
",",
"\"check_full_titles_for_vo... | Writes the check values corresponding to URI onto a spreadsheet. | [
"Writes",
"the",
"check",
"values",
"corresponding",
"to",
"URI",
"onto",
"a",
"spreadsheet",
"."
] | [
"\"\"\"\r\n Writes the check values corresponding to URI onto a spreadsheet.\r\n\r\n Source for help constructing this function:\r\n Jon Fincher, \"Reading and Writing CSV Files in Python,\"\r\n Real Python, accessed October 13, 2020,\r\n https://realpython.com/python-csv/\r\n\r\n Parameters\r\n ... | [
{
"param": "combined_values",
"type": null
},
{
"param": "filename_2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "combined_values",
"type": null,
"docstring": "A list of URIs and volume/edition check values corresponding to each title.",
"docstring_tokens": [
"A",
"list",
"of",
"URIs",
"and",
... |
c86ae901a48ced6131d37cdf1c203f1bd792909f | stlouiss/ACLS_Humanities_eBook_Collection_Metadata_Curation | srs_metadata_cleaning.py | [
"CNRI-Python",
"Info-ZIP"
] | Python | merge_csv_files | <not_specific> | def merge_csv_files(filename_1, filename_2):
"""
The following Stack Overflow page was helpful in writing this function:
"Merging two CSV files using Python,"
https://stackoverflow.com/questions/16265831/merging-two-csv-files-using-python
(accessed October 28, 2020)
Merges CSV files of c... |
The following Stack Overflow page was helpful in writing this function:
"Merging two CSV files using Python,"
https://stackoverflow.com/questions/16265831/merging-two-csv-files-using-python
(accessed October 28, 2020)
Merges CSV files of curated metadata records and
volume/edition check... |
Merges CSV files of curated metadata records and
volume/edition check values on shared URI strings. | [
"Merges",
"CSV",
"files",
"of",
"curated",
"metadata",
"records",
"and",
"volume",
"/",
"edition",
"check",
"values",
"on",
"shared",
"URI",
"strings",
"."
] | def merge_csv_files(filename_1, filename_2):
curated_metadata_records = pd.read_csv(filename_1)
sifting_responses = pd.read_csv(filename_2)
merged = curated_metadata_records.merge(sifting_responses, on="uri")
final_output_metadata = merged.to_csv("python_FINAL_output_metadata.csv", index=False)
retu... | [
"def",
"merge_csv_files",
"(",
"filename_1",
",",
"filename_2",
")",
":",
"curated_metadata_records",
"=",
"pd",
".",
"read_csv",
"(",
"filename_1",
")",
"sifting_responses",
"=",
"pd",
".",
"read_csv",
"(",
"filename_2",
")",
"merged",
"=",
"curated_metadata_reco... | The following Stack Overflow page was helpful in writing this function:
"Merging two CSV files using Python,"
https://stackoverflow.com/questions/16265831/merging-two-csv-files-using-python
(accessed October 28, 2020) | [
"The",
"following",
"Stack",
"Overflow",
"page",
"was",
"helpful",
"in",
"writing",
"this",
"function",
":",
"\"",
"Merging",
"two",
"CSV",
"files",
"using",
"Python",
"\"",
"https",
":",
"//",
"stackoverflow",
".",
"com",
"/",
"questions",
"/",
"16265831",
... | [
"\"\"\"\r\n The following Stack Overflow page was helpful in writing this function:\r\n \"Merging two CSV files using Python,\"\r\n https://stackoverflow.com/questions/16265831/merging-two-csv-files-using-python\r\n (accessed October 28, 2020)\r\n\r\n Merges CSV files of curated metadata records and\... | [
{
"param": "filename_1",
"type": null
},
{
"param": "filename_2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename_1",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": false
},
{
"identifier": "filename_2",
"type": null,
"docstring"... |
ea896da647ec879c98b92f48285f44f6e14896db | Capstrat/django-hilbert | hilbert/decorators.py | [
"BSD-2-Clause"
] | Python | ajax_login_required | <not_specific> | def ajax_login_required(view_func):
"""Handle non-authenticated users differently if it is an AJAX request."""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if request.is_ajax():
if request.user.is_authenticated():
re... | Handle non-authenticated users differently if it is an AJAX request. | Handle non-authenticated users differently if it is an AJAX request. | [
"Handle",
"non",
"-",
"authenticated",
"users",
"differently",
"if",
"it",
"is",
"an",
"AJAX",
"request",
"."
] | def ajax_login_required(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if request.is_ajax():
if request.user.is_authenticated():
return view_func(request, *args, **kwargs)
else:
respo... | [
"def",
"ajax_login_required",
"(",
"view_func",
")",
":",
"@",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",
"(",
"view_func",
")",
")",
"def",
"_wrapped_view",
"(",
"request",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
... | Handle non-authenticated users differently if it is an AJAX request. | [
"Handle",
"non",
"-",
"authenticated",
"users",
"differently",
"if",
"it",
"is",
"an",
"AJAX",
"request",
"."
] | [
"\"\"\"Handle non-authenticated users differently if it is an AJAX request.\"\"\""
] | [
{
"param": "view_func",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "view_func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ea896da647ec879c98b92f48285f44f6e14896db | Capstrat/django-hilbert | hilbert/decorators.py | [
"BSD-2-Clause"
] | Python | ajax_only | <not_specific> | def ajax_only(view_func):
"""Required the view is only accessed via AJAX."""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if request.is_ajax():
return view_func(request, *args, **kwargs)
else:
return http.HttpRes... | Required the view is only accessed via AJAX. | Required the view is only accessed via AJAX. | [
"Required",
"the",
"view",
"is",
"only",
"accessed",
"via",
"AJAX",
"."
] | def ajax_only(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if request.is_ajax():
return view_func(request, *args, **kwargs)
else:
return http.HttpResponseBadRequest()
return _wrapped_view | [
"def",
"ajax_only",
"(",
"view_func",
")",
":",
"@",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",
"(",
"view_func",
")",
")",
"def",
"_wrapped_view",
"(",
"request",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"request",... | Required the view is only accessed via AJAX. | [
"Required",
"the",
"view",
"is",
"only",
"accessed",
"via",
"AJAX",
"."
] | [
"\"\"\"Required the view is only accessed via AJAX.\"\"\""
] | [
{
"param": "view_func",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "view_func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ea896da647ec879c98b92f48285f44f6e14896db | Capstrat/django-hilbert | hilbert/decorators.py | [
"BSD-2-Clause"
] | Python | anonymous_required | <not_specific> | def anonymous_required(func=None, url=None):
"""Required that the user is not logged in."""
url = url or "/"
def _dec(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if request.user.is_authenticated():
... | Required that the user is not logged in. | Required that the user is not logged in. | [
"Required",
"that",
"the",
"user",
"is",
"not",
"logged",
"in",
"."
] | def anonymous_required(func=None, url=None):
url = url or "/"
def _dec(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if request.user.is_authenticated():
return redirect(url)
else:
... | [
"def",
"anonymous_required",
"(",
"func",
"=",
"None",
",",
"url",
"=",
"None",
")",
":",
"url",
"=",
"url",
"or",
"\"/\"",
"def",
"_dec",
"(",
"view_func",
")",
":",
"@",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",
"(",
"view_f... | Required that the user is not logged in. | [
"Required",
"that",
"the",
"user",
"is",
"not",
"logged",
"in",
"."
] | [
"\"\"\"Required that the user is not logged in.\"\"\""
] | [
{
"param": "func",
"type": null
},
{
"param": "url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": []... |
ea896da647ec879c98b92f48285f44f6e14896db | Capstrat/django-hilbert | hilbert/decorators.py | [
"BSD-2-Clause"
] | Python | secure | <not_specific> | def secure(view_func):
"""Handles SSL redirect on the view level."""
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if not request.is_secure():
redirect = _redirect(request, True)
if redirect:
# Redirect mi... | Handles SSL redirect on the view level. | Handles SSL redirect on the view level. | [
"Handles",
"SSL",
"redirect",
"on",
"the",
"view",
"level",
"."
] | def secure(view_func):
@wraps(view_func, assigned=available_attrs(view_func))
def _wrapped_view(request, *args, **kwargs):
if not request.is_secure():
redirect = _redirect(request, True)
if redirect:
return redirect
return view_func(request, *args, **kwarg... | [
"def",
"secure",
"(",
"view_func",
")",
":",
"@",
"wraps",
"(",
"view_func",
",",
"assigned",
"=",
"available_attrs",
"(",
"view_func",
")",
")",
"def",
"_wrapped_view",
"(",
"request",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"not",
"req... | Handles SSL redirect on the view level. | [
"Handles",
"SSL",
"redirect",
"on",
"the",
"view",
"level",
"."
] | [
"\"\"\"Handles SSL redirect on the view level.\"\"\"",
"# Redirect might be None if SSL is not enabled"
] | [
{
"param": "view_func",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "view_func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b114f20e3b7577a8df89c34d7cea2c8d9a78b5ba | kinow/bactopia | bin/bactopia/bactopia-datasets.py | [
"MIT"
] | Python | validate_species | <not_specific> | def validate_species(species):
"""Query input species against ENA to determine if it exists."""
import requests
ENDPOINT = 'https://www.ebi.ac.uk/ena/data/taxonomy/v1/taxon/any-name'
checks = []
if os.path.exists(species):
with open(species, 'r') as handle:
for line in handle:
... | Query input species against ENA to determine if it exists. | Query input species against ENA to determine if it exists. | [
"Query",
"input",
"species",
"against",
"ENA",
"to",
"determine",
"if",
"it",
"exists",
"."
] | def validate_species(species):
import requests
ENDPOINT = 'https://www.ebi.ac.uk/ena/data/taxonomy/v1/taxon/any-name'
checks = []
if os.path.exists(species):
with open(species, 'r') as handle:
for line in handle:
line = line.rstrip()
if line:
... | [
"def",
"validate_species",
"(",
"species",
")",
":",
"import",
"requests",
"ENDPOINT",
"=",
"'https://www.ebi.ac.uk/ena/data/taxonomy/v1/taxon/any-name'",
"checks",
"=",
"[",
"]",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"species",
")",
":",
"with",
"open",
... | Query input species against ENA to determine if it exists. | [
"Query",
"input",
"species",
"against",
"ENA",
"to",
"determine",
"if",
"it",
"exists",
"."
] | [
"\"\"\"Query input species against ENA to determine if it exists.\"\"\"",
"# Error! Species/Organism found, but doesn't match input. This shouldn't",
"# (query is case-insensitive exact match) happen, but my grandma could \"",
"# probably trigger it, so here it is!",
"# Error! Species/Organism not found. Ch... | [
{
"param": "species",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "species",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b114f20e3b7577a8df89c34d7cea2c8d9a78b5ba | kinow/bactopia | bin/bactopia/bactopia-datasets.py | [
"MIT"
] | Python | pubmlst_schemas | <not_specific> | def pubmlst_schemas(pubmlst_file):
"""Read the PubMLST mappings and return a dict."""
pubmlst = {}
with open(pubmlst_file, 'rt') as pubmlst_fh:
for line in pubmlst_fh:
line = line.rstrip()
if line and not line.startswith('ariba'):
ariba, species, schema = line... | Read the PubMLST mappings and return a dict. | Read the PubMLST mappings and return a dict. | [
"Read",
"the",
"PubMLST",
"mappings",
"and",
"return",
"a",
"dict",
"."
] | def pubmlst_schemas(pubmlst_file):
pubmlst = {}
with open(pubmlst_file, 'rt') as pubmlst_fh:
for line in pubmlst_fh:
line = line.rstrip()
if line and not line.startswith('ariba'):
ariba, species, schema = line.split('\t')
if species not in pubmlst:... | [
"def",
"pubmlst_schemas",
"(",
"pubmlst_file",
")",
":",
"pubmlst",
"=",
"{",
"}",
"with",
"open",
"(",
"pubmlst_file",
",",
"'rt'",
")",
"as",
"pubmlst_fh",
":",
"for",
"line",
"in",
"pubmlst_fh",
":",
"line",
"=",
"line",
".",
"rstrip",
"(",
")",
"if... | Read the PubMLST mappings and return a dict. | [
"Read",
"the",
"PubMLST",
"mappings",
"and",
"return",
"a",
"dict",
"."
] | [
"\"\"\"Read the PubMLST mappings and return a dict.\"\"\""
] | [
{
"param": "pubmlst_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pubmlst_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b114f20e3b7577a8df89c34d7cea2c8d9a78b5ba | kinow/bactopia | bin/bactopia/bactopia-datasets.py | [
"MIT"
] | Python | available_datasets | null | def available_datasets(ariba, pubmlst, missing=False):
"""Print available Ariba references, MLST schemas, and exit."""
print_to = sys.stderr if missing else sys.stdout
print("Ariba reference datasets available:", file=print_to)
print("\n".join(sorted(ariba)), file=print_to)
print("\nMLST schemas av... | Print available Ariba references, MLST schemas, and exit. | Print available Ariba references, MLST schemas, and exit. | [
"Print",
"available",
"Ariba",
"references",
"MLST",
"schemas",
"and",
"exit",
"."
] | def available_datasets(ariba, pubmlst, missing=False):
print_to = sys.stderr if missing else sys.stdout
print("Ariba reference datasets available:", file=print_to)
print("\n".join(sorted(ariba)), file=print_to)
print("\nMLST schemas available from pubMLST.org:", file=print_to)
for k,v in sorted(pubm... | [
"def",
"available_datasets",
"(",
"ariba",
",",
"pubmlst",
",",
"missing",
"=",
"False",
")",
":",
"print_to",
"=",
"sys",
".",
"stderr",
"if",
"missing",
"else",
"sys",
".",
"stdout",
"print",
"(",
"\"Ariba reference datasets available:\"",
",",
"file",
"=",
... | Print available Ariba references, MLST schemas, and exit. | [
"Print",
"available",
"Ariba",
"references",
"MLST",
"schemas",
"and",
"exit",
"."
] | [
"\"\"\"Print available Ariba references, MLST schemas, and exit.\"\"\""
] | [
{
"param": "ariba",
"type": null
},
{
"param": "pubmlst",
"type": null
},
{
"param": "missing",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ariba",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pubmlst",
"type": null,
"docstring": null,
"docstring_tokens... |
b114f20e3b7577a8df89c34d7cea2c8d9a78b5ba | kinow/bactopia | bin/bactopia/bactopia-datasets.py | [
"MIT"
] | Python | available_species | null | def available_species(dataset_dir):
"""Print species already in the dataset, and exit."""
summary_json = f'{dataset_dir}/summary.json'
if os.path.exists(summary_json):
species_list = []
with open(summary_json, 'rt') as summary_fh:
summary_data = json.load(summary_fh)
... | Print species already in the dataset, and exit. | Print species already in the dataset, and exit. | [
"Print",
"species",
"already",
"in",
"the",
"dataset",
"and",
"exit",
"."
] | def available_species(dataset_dir):
summary_json = f'{dataset_dir}/summary.json'
if os.path.exists(summary_json):
species_list = []
with open(summary_json, 'rt') as summary_fh:
summary_data = json.load(summary_fh)
for species in summary_data['species-specific'].keys():
... | [
"def",
"available_species",
"(",
"dataset_dir",
")",
":",
"summary_json",
"=",
"f'{dataset_dir}/summary.json'",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"summary_json",
")",
":",
"species_list",
"=",
"[",
"]",
"with",
"open",
"(",
"summary_json",
",",
"'rt... | Print species already in the dataset, and exit. | [
"Print",
"species",
"already",
"in",
"the",
"dataset",
"and",
"exit",
"."
] | [
"\"\"\"Print species already in the dataset, and exit.\"\"\""
] | [
{
"param": "dataset_dir",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dataset_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b114f20e3b7577a8df89c34d7cea2c8d9a78b5ba | kinow/bactopia | bin/bactopia/bactopia-datasets.py | [
"MIT"
] | Python | create_summary | null | def create_summary(outdir, training_set=False):
"""Create a summary of available datasets in JSON format."""
from collections import OrderedDict
available_datasets = OrderedDict()
available_datasets['antimicrobial-resistance'] = []
available_datasets['ariba'] = []
available_datasets['minmer'] =... | Create a summary of available datasets in JSON format. | Create a summary of available datasets in JSON format. | [
"Create",
"a",
"summary",
"of",
"available",
"datasets",
"in",
"JSON",
"format",
"."
] | def create_summary(outdir, training_set=False):
from collections import OrderedDict
available_datasets = OrderedDict()
available_datasets['antimicrobial-resistance'] = []
available_datasets['ariba'] = []
available_datasets['minmer'] = {'sketches': [], 'last_update': None}
available_datasets['pla... | [
"def",
"create_summary",
"(",
"outdir",
",",
"training_set",
"=",
"False",
")",
":",
"from",
"collections",
"import",
"OrderedDict",
"available_datasets",
"=",
"OrderedDict",
"(",
")",
"available_datasets",
"[",
"'antimicrobial-resistance'",
"]",
"=",
"[",
"]",
"a... | Create a summary of available datasets in JSON format. | [
"Create",
"a",
"summary",
"of",
"available",
"datasets",
"in",
"JSON",
"format",
"."
] | [
"\"\"\"Create a summary of available datasets in JSON format.\"\"\"",
"# Antimicrobial Resistance",
"# Ariba",
"# Minmers",
"# Organism Specific",
"# Skip hidden files like .DS_Store",
"# These are optional directories users can add data to"
] | [
{
"param": "outdir",
"type": null
},
{
"param": "training_set",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "outdir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "training_set",
"type": null,
"docstring": null,
"docstring_... |
8c83eb0e640a31a9c971eb58429844f764b2bafd | kinow/bactopia | tests/test_versions_yml.py | [
"MIT"
] | Python | _get_workflow_names | null | def _get_workflow_names():
"""Get all names of all workflows which have a test.yml in the tests directory.
To do so, recursively finds all test.yml files and parses their content.
"""
here = Path(__file__).parent.parent.resolve()
pytest_workflow_files = here.glob("**/test.yml")
for f in pytest_w... | Get all names of all workflows which have a test.yml in the tests directory.
To do so, recursively finds all test.yml files and parses their content.
| Get all names of all workflows which have a test.yml in the tests directory.
To do so, recursively finds all test.yml files and parses their content. | [
"Get",
"all",
"names",
"of",
"all",
"workflows",
"which",
"have",
"a",
"test",
".",
"yml",
"in",
"the",
"tests",
"directory",
".",
"To",
"do",
"so",
"recursively",
"finds",
"all",
"test",
".",
"yml",
"files",
"and",
"parses",
"their",
"content",
"."
] | def _get_workflow_names():
here = Path(__file__).parent.parent.resolve()
pytest_workflow_files = here.glob("**/test.yml")
for f in pytest_workflow_files:
test_config = yaml.load(f.read_text(), Loader=yaml.BaseLoader)
if test_config:
for workflow in test_config:
yi... | [
"def",
"_get_workflow_names",
"(",
")",
":",
"here",
"=",
"Path",
"(",
"__file__",
")",
".",
"parent",
".",
"parent",
".",
"resolve",
"(",
")",
"pytest_workflow_files",
"=",
"here",
".",
"glob",
"(",
"\"**/test.yml\"",
")",
"for",
"f",
"in",
"pytest_workfl... | Get all names of all workflows which have a test.yml in the tests directory. | [
"Get",
"all",
"names",
"of",
"all",
"workflows",
"which",
"have",
"a",
"test",
".",
"yml",
"in",
"the",
"tests",
"directory",
"."
] | [
"\"\"\"Get all names of all workflows which have a test.yml in the tests directory.\n To do so, recursively finds all test.yml files and parses their content.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
028cb4e10b1f52f5adbad84bfdd15dc1d7d821eb | zcbrand/sdev300flaskapp | auth/login.py | [
"MIT"
] | Python | user_exists | <not_specific> | def user_exists(uname):
"""Checks if user exists in the passfile"""
with open('passfile.txt', 'r') as f:
for line in f:
user = json.loads(line)
if user['username'] == uname:
return True
return False | Checks if user exists in the passfile | Checks if user exists in the passfile | [
"Checks",
"if",
"user",
"exists",
"in",
"the",
"passfile"
] | def user_exists(uname):
with open('passfile.txt', 'r') as f:
for line in f:
user = json.loads(line)
if user['username'] == uname:
return True
return False | [
"def",
"user_exists",
"(",
"uname",
")",
":",
"with",
"open",
"(",
"'passfile.txt'",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"user",
"=",
"json",
".",
"loads",
"(",
"line",
")",
"if",
"user",
"[",
"'username'",
"]",
"==",
... | Checks if user exists in the passfile | [
"Checks",
"if",
"user",
"exists",
"in",
"the",
"passfile"
] | [
"\"\"\"Checks if user exists in the passfile\"\"\""
] | [
{
"param": "uname",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "uname",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
028cb4e10b1f52f5adbad84bfdd15dc1d7d821eb | zcbrand/sdev300flaskapp | auth/login.py | [
"MIT"
] | Python | complexity | <not_specific> | def complexity(password):
"""Confirms and entered password meets the needed complexity"""
if (len(password) >= 12
and any(c.islower() for c in password)
and any(c.isupper() for c in password)
and any(c.isdigit() for c in password)
and any(c in string.punctuation f... | Confirms and entered password meets the needed complexity | Confirms and entered password meets the needed complexity | [
"Confirms",
"and",
"entered",
"password",
"meets",
"the",
"needed",
"complexity"
] | def complexity(password):
if (len(password) >= 12
and any(c.islower() for c in password)
and any(c.isupper() for c in password)
and any(c.isdigit() for c in password)
and any(c in string.punctuation for c in password)
and password_is_not_common(password)):... | [
"def",
"complexity",
"(",
"password",
")",
":",
"if",
"(",
"len",
"(",
"password",
")",
">=",
"12",
"and",
"any",
"(",
"c",
".",
"islower",
"(",
")",
"for",
"c",
"in",
"password",
")",
"and",
"any",
"(",
"c",
".",
"isupper",
"(",
")",
"for",
"c... | Confirms and entered password meets the needed complexity | [
"Confirms",
"and",
"entered",
"password",
"meets",
"the",
"needed",
"complexity"
] | [
"\"\"\"Confirms and entered password meets the needed complexity\"\"\""
] | [
{
"param": "password",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "password",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
028cb4e10b1f52f5adbad84bfdd15dc1d7d821eb | zcbrand/sdev300flaskapp | auth/login.py | [
"MIT"
] | Python | password_is_not_common | <not_specific> | def password_is_not_common(password):
"""Check password against a list of common passwords"""
with open('commonPasswords.txt', 'r') as f:
for line in f:
if line == password:
return False
return True | Check password against a list of common passwords | Check password against a list of common passwords | [
"Check",
"password",
"against",
"a",
"list",
"of",
"common",
"passwords"
] | def password_is_not_common(password):
with open('commonPasswords.txt', 'r') as f:
for line in f:
if line == password:
return False
return True | [
"def",
"password_is_not_common",
"(",
"password",
")",
":",
"with",
"open",
"(",
"'commonPasswords.txt'",
",",
"'r'",
")",
"as",
"f",
":",
"for",
"line",
"in",
"f",
":",
"if",
"line",
"==",
"password",
":",
"return",
"False",
"return",
"True"
] | Check password against a list of common passwords | [
"Check",
"password",
"against",
"a",
"list",
"of",
"common",
"passwords"
] | [
"\"\"\"Check password against a list of common passwords\"\"\""
] | [
{
"param": "password",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "password",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
929cf9f5ed8e5ef40a2fee9df8c97301c2041153 | Phazz/spacemacs | layers/+tools/ycmd/global_conf.py | [
"Vim"
] | Python | FlagsForFile | <not_specific> | def FlagsForFile( filename, **kwargs ):
""" given the source filename, return the compiler flags """
opt_basename = '.clang_complete'
curr_dir = os.path.dirname(filename)
opt_fname = os.path.join(curr_dir, opt_basename)
# keep traversing up the tree until we find the file, or hit the root
while ... | given the source filename, return the compiler flags | given the source filename, return the compiler flags | [
"given",
"the",
"source",
"filename",
"return",
"the",
"compiler",
"flags"
] | def FlagsForFile( filename, **kwargs ):
opt_basename = '.clang_complete'
curr_dir = os.path.dirname(filename)
opt_fname = os.path.join(curr_dir, opt_basename)
while not os.path.exists(opt_fname):
new_dir = os.path.dirname(curr_dir)
if new_dir == curr_dir:
break
curr_dir... | [
"def",
"FlagsForFile",
"(",
"filename",
",",
"**",
"kwargs",
")",
":",
"opt_basename",
"=",
"'.clang_complete'",
"curr_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"filename",
")",
"opt_fname",
"=",
"os",
".",
"path",
".",
"join",
"(",
"curr_dir",
... | given the source filename, return the compiler flags | [
"given",
"the",
"source",
"filename",
"return",
"the",
"compiler",
"flags"
] | [
"\"\"\" given the source filename, return the compiler flags \"\"\"",
"# keep traversing up the tree until we find the file, or hit the root",
"# we've reached the root of the tree"
] | [
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cc8503cb690f47b179e678c0d0b9a4b1f212cbb4 | prewettg/Open3D | examples/Python/Advanced/mesh_voxelization.py | [
"MIT"
] | Python | preprocess | <not_specific> | def preprocess(model):
"""Normalize model to fit in unit sphere (sphere with unit radius).
Calculate center & scale of vertices, and transform vertices to have 0 mean and unit variance.
Returns:
open3d.geometry.TriangleMesh: normalized mesh
"""
min_bound = model.get_min_bound()
ma... | Normalize model to fit in unit sphere (sphere with unit radius).
Calculate center & scale of vertices, and transform vertices to have 0 mean and unit variance.
Returns:
open3d.geometry.TriangleMesh: normalized mesh
| Normalize model to fit in unit sphere (sphere with unit radius).
Calculate center & scale of vertices, and transform vertices to have 0 mean and unit variance. | [
"Normalize",
"model",
"to",
"fit",
"in",
"unit",
"sphere",
"(",
"sphere",
"with",
"unit",
"radius",
")",
".",
"Calculate",
"center",
"&",
"scale",
"of",
"vertices",
"and",
"transform",
"vertices",
"to",
"have",
"0",
"mean",
"and",
"unit",
"variance",
"."
] | def preprocess(model):
min_bound = model.get_min_bound()
max_bound = model.get_max_bound()
center = min_bound + (max_bound - min_bound) / 2.0
scale = np.linalg.norm(max_bound - min_bound) / 2.0
vertices = np.asarray(model.vertices)
vertices -= np.matlib.repmat(center, len(model.vertices), 1)
... | [
"def",
"preprocess",
"(",
"model",
")",
":",
"min_bound",
"=",
"model",
".",
"get_min_bound",
"(",
")",
"max_bound",
"=",
"model",
".",
"get_max_bound",
"(",
")",
"center",
"=",
"min_bound",
"+",
"(",
"max_bound",
"-",
"min_bound",
")",
"/",
"2.0",
"scal... | Normalize model to fit in unit sphere (sphere with unit radius). | [
"Normalize",
"model",
"to",
"fit",
"in",
"unit",
"sphere",
"(",
"sphere",
"with",
"unit",
"radius",
")",
"."
] | [
"\"\"\"Normalize model to fit in unit sphere (sphere with unit radius).\n \n Calculate center & scale of vertices, and transform vertices to have 0 mean and unit variance. \n\n Returns:\n open3d.geometry.TriangleMesh: normalized mesh\n \"\"\"",
"## Paint uniform color for pleasing visualization... | [
{
"param": "model",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "open3d.geometry.TriangleMesh"
}
],
"raises": [],
"params": [
{
"identifier": "model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
... |
f333fe22e7ad0329c85ea7432c6da77e9bc89dc6 | ScrapCodes/kserve | python/kserve/test/test_v1beta1_predictors_config.py | [
"Apache-2.0"
] | Python | make_instance | <not_specific> | def make_instance(self, include_optional):
"""Test V1beta1PredictorsConfig
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kserve.models.v1beta1_predictors_config.V1beta1... | Test V1beta1PredictorsConfig
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | Test V1beta1PredictorsConfig
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | [
"Test",
"V1beta1PredictorsConfig",
"include_option",
"is",
"a",
"boolean",
"when",
"False",
"only",
"required",
"params",
"are",
"included",
"when",
"True",
"both",
"required",
"and",
"optional",
"params",
"are",
"included"
] | def make_instance(self, include_optional):
if include_optional :
return V1beta1PredictorsConfig(
onnx = kserve.models.v1beta1_predictor_config.V1beta1PredictorConfig(
default_gpu_image_version = '0',
default_image_version = '0',
... | [
"def",
"make_instance",
"(",
"self",
",",
"include_optional",
")",
":",
"if",
"include_optional",
":",
"return",
"V1beta1PredictorsConfig",
"(",
"onnx",
"=",
"kserve",
".",
"models",
".",
"v1beta1_predictor_config",
".",
"V1beta1PredictorConfig",
"(",
"default_gpu_ima... | Test V1beta1PredictorsConfig
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | [
"Test",
"V1beta1PredictorsConfig",
"include_option",
"is",
"a",
"boolean",
"when",
"False",
"only",
"required",
"params",
"are",
"included",
"when",
"True",
"both",
"required",
"and",
"optional",
"params",
"are",
"included"
] | [
"\"\"\"Test V1beta1PredictorsConfig\n include_option is a boolean, when False only required\n params are included, when True both required and\n optional params are included \"\"\"",
"# model = kserve.models.v1beta1_predictors_config.V1beta1PredictorsConfig() # noqa: E501"
] | [
{
"param": "self",
"type": null
},
{
"param": "include_optional",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "include_optional",
"type": null,
"docstring": null,
"docstrin... |
b2380d9638db20ee6d6e25747fa80e36ee3e5918 | ScrapCodes/kserve | test/e2e/credentials/test_set_creds.py | [
"Apache-2.0"
] | Python | check_sa_exists | <not_specific> | def check_sa_exists(service_account):
'''Check if the specified service account existing.'''
sa_list = client.CoreV1Api().list_namespaced_service_account(namespace=KSERVE_TEST_NAMESPACE)
sa_name_list = []
for item in range(0, len(sa_list.items) - 1):
sa_name_list.append(sa_list.items[item].metad... | Check if the specified service account existing. | Check if the specified service account existing. | [
"Check",
"if",
"the",
"specified",
"service",
"account",
"existing",
"."
] | def check_sa_exists(service_account):
sa_list = client.CoreV1Api().list_namespaced_service_account(namespace=KSERVE_TEST_NAMESPACE)
sa_name_list = []
for item in range(0, len(sa_list.items) - 1):
sa_name_list.append(sa_list.items[item].metadata.name)
if service_account in sa_name_list:
r... | [
"def",
"check_sa_exists",
"(",
"service_account",
")",
":",
"sa_list",
"=",
"client",
".",
"CoreV1Api",
"(",
")",
".",
"list_namespaced_service_account",
"(",
"namespace",
"=",
"KSERVE_TEST_NAMESPACE",
")",
"sa_name_list",
"=",
"[",
"]",
"for",
"item",
"in",
"ra... | Check if the specified service account existing. | [
"Check",
"if",
"the",
"specified",
"service",
"account",
"existing",
"."
] | [
"'''Check if the specified service account existing.'''"
] | [
{
"param": "service_account",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "service_account",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
38a323477cdba3cd4e4bc0ebbe465af6d1261034 | ScrapCodes/kserve | python/kserve/test/test_v1beta1_model_spec.py | [
"Apache-2.0"
] | Python | make_instance | <not_specific> | def make_instance(self, include_optional):
"""Test V1beta1ModelSpec
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# model = kserve.models.v1beta1_model_spec.V1beta1ModelSpec() #... | Test V1beta1ModelSpec
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | Test V1beta1ModelSpec
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | [
"Test",
"V1beta1ModelSpec",
"include_option",
"is",
"a",
"boolean",
"when",
"False",
"only",
"required",
"params",
"are",
"included",
"when",
"True",
"both",
"required",
"and",
"optional",
"params",
"are",
"included"
] | def make_instance(self, include_optional):
if include_optional :
return V1beta1ModelSpec(
framework = '0',
memory = None,
storage_uri = '0'
)
else :
return V1beta1ModelSpec(
framework = '0',
... | [
"def",
"make_instance",
"(",
"self",
",",
"include_optional",
")",
":",
"if",
"include_optional",
":",
"return",
"V1beta1ModelSpec",
"(",
"framework",
"=",
"'0'",
",",
"memory",
"=",
"None",
",",
"storage_uri",
"=",
"'0'",
")",
"else",
":",
"return",
"V1beta... | Test V1beta1ModelSpec
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | [
"Test",
"V1beta1ModelSpec",
"include_option",
"is",
"a",
"boolean",
"when",
"False",
"only",
"required",
"params",
"are",
"included",
"when",
"True",
"both",
"required",
"and",
"optional",
"params",
"are",
"included"
] | [
"\"\"\"Test V1beta1ModelSpec\n include_option is a boolean, when False only required\n params are included, when True both required and\n optional params are included \"\"\"",
"# model = kserve.models.v1beta1_model_spec.V1beta1ModelSpec() # noqa: E501"
] | [
{
"param": "self",
"type": null
},
{
"param": "include_optional",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "include_optional",
"type": null,
"docstring": null,
"docstrin... |
4769252a9db17e6239dbdb50d0155cad135680a1 | ScrapCodes/kserve | python/kserve/test/test_v1beta1_predictor_protocols.py | [
"Apache-2.0"
] | Python | make_instance | <not_specific> | def make_instance(self, include_optional):
"""Test V1beta1PredictorProtocols
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included"""
# model = kserve.models.v1beta1_predictor_protocols.V1beta1Predictor... | Test V1beta1PredictorProtocols
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | Test V1beta1PredictorProtocols
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | [
"Test",
"V1beta1PredictorProtocols",
"include_option",
"is",
"a",
"boolean",
"when",
"False",
"only",
"required",
"params",
"are",
"included",
"when",
"True",
"both",
"required",
"and",
"optional",
"params",
"are",
"included"
] | def make_instance(self, include_optional):
if include_optional:
return V1beta1PredictorProtocols(
v1=kserve.models.v1beta1_predictor_config.V1beta1PredictorConfig(
default_gpu_image_version="0",
default_image_version="0",
im... | [
"def",
"make_instance",
"(",
"self",
",",
"include_optional",
")",
":",
"if",
"include_optional",
":",
"return",
"V1beta1PredictorProtocols",
"(",
"v1",
"=",
"kserve",
".",
"models",
".",
"v1beta1_predictor_config",
".",
"V1beta1PredictorConfig",
"(",
"default_gpu_ima... | Test V1beta1PredictorProtocols
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included | [
"Test",
"V1beta1PredictorProtocols",
"include_option",
"is",
"a",
"boolean",
"when",
"False",
"only",
"required",
"params",
"are",
"included",
"when",
"True",
"both",
"required",
"and",
"optional",
"params",
"are",
"included"
] | [
"\"\"\"Test V1beta1PredictorProtocols\n include_option is a boolean, when False only required\n params are included, when True both required and\n optional params are included\"\"\"",
"# model = kserve.models.v1beta1_predictor_protocols.V1beta1PredictorProtocols() # noqa: E501"
] | [
{
"param": "self",
"type": null
},
{
"param": "include_optional",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "include_optional",
"type": null,
"docstring": null,
"docstrin... |
70bec57042f6210da549195df3633a2e02bc3053 | GuyKeogh/wiki_factcheck | app.py | [
"BSD-2-Clause"
] | Python | correct | <not_specific> | def correct():
"""When downloading citations failed, this allows the user to copy-and-paste them and continue"""
input_text = request.form["correction_text"]
filtered_name = session['filtered_name']
data = session['data']
settings = session['settings']
language = settings['language']
i... | When downloading citations failed, this allows the user to copy-and-paste them and continue | When downloading citations failed, this allows the user to copy-and-paste them and continue | [
"When",
"downloading",
"citations",
"failed",
"this",
"allows",
"the",
"user",
"to",
"copy",
"-",
"and",
"-",
"paste",
"them",
"and",
"continue"
] | def correct():
input_text = request.form["correction_text"]
filtered_name = session['filtered_name']
data = session['data']
settings = session['settings']
language = settings['language']
if len(input_text) > 10:
data['reprocess?'] = True
data = correction.add_input(input_text, d... | [
"def",
"correct",
"(",
")",
":",
"input_text",
"=",
"request",
".",
"form",
"[",
"\"correction_text\"",
"]",
"filtered_name",
"=",
"session",
"[",
"'filtered_name'",
"]",
"data",
"=",
"session",
"[",
"'data'",
"]",
"settings",
"=",
"session",
"[",
"'settings... | When downloading citations failed, this allows the user to copy-and-paste them and continue | [
"When",
"downloading",
"citations",
"failed",
"this",
"allows",
"the",
"user",
"to",
"copy",
"-",
"and",
"-",
"paste",
"them",
"and",
"continue"
] | [
"\"\"\"When downloading citations failed, this allows the user to copy-and-paste them and continue\"\"\"",
"#Reprocess all data"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
70bec57042f6210da549195df3633a2e02bc3053 | GuyKeogh/wiki_factcheck | app.py | [
"BSD-2-Clause"
] | Python | article_start | <not_specific> | def article_start():
"""Display the article, including calling the processing of it"""
#Getting from article:
POST_name = request.form["page"] #Article name input by user
language = request.form["lang"] #Wikipedia language input by user
(filtered_name,if_error,error) = filter_title.handle_input_titl... | Display the article, including calling the processing of it | Display the article, including calling the processing of it | [
"Display",
"the",
"article",
"including",
"calling",
"the",
"processing",
"of",
"it"
] | def article_start():
POST_name = request.form["page"]
language = request.form["lang"]
(filtered_name,if_error,error) = filter_title.handle_input_title_language(POST_name,language)
if if_error:
return render_template("index.html",error_message = error)
if_quote = if_cardinal_number = if_sin... | [
"def",
"article_start",
"(",
")",
":",
"POST_name",
"=",
"request",
".",
"form",
"[",
"\"page\"",
"]",
"language",
"=",
"request",
".",
"form",
"[",
"\"lang\"",
"]",
"(",
"filtered_name",
",",
"if_error",
",",
"error",
")",
"=",
"filter_title",
".",
"han... | Display the article, including calling the processing of it | [
"Display",
"the",
"article",
"including",
"calling",
"the",
"processing",
"of",
"it"
] | [
"\"\"\"Display the article, including calling the processing of it\"\"\"",
"#Getting from article:",
"#Article name input by user",
"#Wikipedia language input by user",
"#Settings checkboxes. These are only delivered by POST if they are checked, so assume they are False unless delivered:",
"#Finished chec... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
70bec57042f6210da549195df3633a2e02bc3053 | GuyKeogh/wiki_factcheck | app.py | [
"BSD-2-Clause"
] | Python | article_named | <not_specific> | def article_named(POST_name):
"""Alternate method of inputting title, allowing /article/<article name> and /article/<Wikipedia page URL>"""
#Defaults:
language = "en"
if_noun = if_adjective = False
if_quote = if_cardinal_number = if_singular_proper_noun = True
#/article/<Wikipedia page URL>... | Alternate method of inputting title, allowing /article/<article name> and /article/<Wikipedia page URL> | Alternate method of inputting title, allowing /article/ and /article/ | [
"Alternate",
"method",
"of",
"inputting",
"title",
"allowing",
"/",
"article",
"/",
"and",
"/",
"article",
"/"
] | def article_named(POST_name):
language = "en"
if_noun = if_adjective = False
if_quote = if_cardinal_number = if_singular_proper_noun = True
if ".wikipedia.org/wiki/" in POST_name:
(language, POST_name) = filter_title.from_url(POST_name)
(filtered_name,if_error,error) = filter_title.handle_in... | [
"def",
"article_named",
"(",
"POST_name",
")",
":",
"language",
"=",
"\"en\"",
"if_noun",
"=",
"if_adjective",
"=",
"False",
"if_quote",
"=",
"if_cardinal_number",
"=",
"if_singular_proper_noun",
"=",
"True",
"if",
"\".wikipedia.org/wiki/\"",
"in",
"POST_name",
":",... | Alternate method of inputting title, allowing /article/<article name> and /article/<Wikipedia page URL> | [
"Alternate",
"method",
"of",
"inputting",
"title",
"allowing",
"/",
"article",
"/",
"<article",
"name",
">",
"and",
"/",
"article",
"/",
"<Wikipedia",
"page",
"URL",
">"
] | [
"\"\"\"Alternate method of inputting title, allowing /article/<article name> and /article/<Wikipedia page URL>\"\"\"",
"#Defaults:",
"#/article/<Wikipedia page URL> :",
"#Finished checks",
"#Submit to backend:",
"#No data yet",
"# Position of each citation in the original wikitext",
"# Text and tagged... | [
{
"param": "POST_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "POST_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
baba766bbbbdbf7ef65ded653ebb09022b30dbbd | GuyKeogh/wiki_factcheck | source/dataparsing/text_tagging.py | [
"BSD-2-Clause"
] | Python | tag_text_of_type | <not_specific> | def tag_text_of_type(tag_type, data):
"""Only output already tokenised words of specific type that was requested"""
text_of_tag = []
index = 0
for word in data:
if tag_type in word[1]:
text_of_tag.append(tuple((word[0], index)))
index+=1
return text_of_tag | Only output already tokenised words of specific type that was requested | Only output already tokenised words of specific type that was requested | [
"Only",
"output",
"already",
"tokenised",
"words",
"of",
"specific",
"type",
"that",
"was",
"requested"
] | def tag_text_of_type(tag_type, data):
text_of_tag = []
index = 0
for word in data:
if tag_type in word[1]:
text_of_tag.append(tuple((word[0], index)))
index+=1
return text_of_tag | [
"def",
"tag_text_of_type",
"(",
"tag_type",
",",
"data",
")",
":",
"text_of_tag",
"=",
"[",
"]",
"index",
"=",
"0",
"for",
"word",
"in",
"data",
":",
"if",
"tag_type",
"in",
"word",
"[",
"1",
"]",
":",
"text_of_tag",
".",
"append",
"(",
"tuple",
"(",... | Only output already tokenised words of specific type that was requested | [
"Only",
"output",
"already",
"tokenised",
"words",
"of",
"specific",
"type",
"that",
"was",
"requested"
] | [
"\"\"\"Only output already tokenised words of specific type that was requested\"\"\""
] | [
{
"param": "tag_type",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tag_type",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens... |
baba766bbbbdbf7ef65ded653ebb09022b30dbbd | GuyKeogh/wiki_factcheck | source/dataparsing/text_tagging.py | [
"BSD-2-Clause"
] | Python | eval_citation_for_type | <not_specific> | def eval_citation_for_type(citation_text, key):
"""Only output words of specific type stated in key"""
unique_terms_cite = []
for word in citation_text:
if key in word[1]:
unique_terms_cite.append(word[0])
return unique_terms_cite | Only output words of specific type stated in key | Only output words of specific type stated in key | [
"Only",
"output",
"words",
"of",
"specific",
"type",
"stated",
"in",
"key"
] | def eval_citation_for_type(citation_text, key):
unique_terms_cite = []
for word in citation_text:
if key in word[1]:
unique_terms_cite.append(word[0])
return unique_terms_cite | [
"def",
"eval_citation_for_type",
"(",
"citation_text",
",",
"key",
")",
":",
"unique_terms_cite",
"=",
"[",
"]",
"for",
"word",
"in",
"citation_text",
":",
"if",
"key",
"in",
"word",
"[",
"1",
"]",
":",
"unique_terms_cite",
".",
"append",
"(",
"word",
"[",... | Only output words of specific type stated in key | [
"Only",
"output",
"words",
"of",
"specific",
"type",
"stated",
"in",
"key"
] | [
"\"\"\"Only output words of specific type stated in key\"\"\""
] | [
{
"param": "citation_text",
"type": null
},
{
"param": "key",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "citation_text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": null,
"docstring": null,
"docstring_to... |
baba766bbbbdbf7ef65ded653ebb09022b30dbbd | GuyKeogh/wiki_factcheck | source/dataparsing/text_tagging.py | [
"BSD-2-Clause"
] | Python | compare_citation_and_text_terms | <not_specific> | def compare_citation_and_text_terms(tags,
unique_terms_citations_CD,
unique_terms_citations_JJ,
unique_terms_citations_NN,
unique_terms_citations_NNP,
... | Compare unique citation terms of specific type and article text of the same type | Compare unique citation terms of specific type and article text of the same type | [
"Compare",
"unique",
"citation",
"terms",
"of",
"specific",
"type",
"and",
"article",
"text",
"of",
"the",
"same",
"type"
] | def compare_citation_and_text_terms(tags,
unique_terms_citations_CD,
unique_terms_citations_JJ,
unique_terms_citations_NN,
unique_terms_citations_NNP,
... | [
"def",
"compare_citation_and_text_terms",
"(",
"tags",
",",
"unique_terms_citations_CD",
",",
"unique_terms_citations_JJ",
",",
"unique_terms_citations_NN",
",",
"unique_terms_citations_NNP",
",",
"if_detect_NNP",
"=",
"False",
",",
"if_detect_JJ",
"=",
"False",
",",
"if_de... | Compare unique citation terms of specific type and article text of the same type | [
"Compare",
"unique",
"citation",
"terms",
"of",
"specific",
"type",
"and",
"article",
"text",
"of",
"the",
"same",
"type"
] | [
"\"\"\"Compare unique citation terms of specific type and article text of the same type\"\"\""
] | [
{
"param": "tags",
"type": null
},
{
"param": "unique_terms_citations_CD",
"type": null
},
{
"param": "unique_terms_citations_JJ",
"type": null
},
{
"param": "unique_terms_citations_NN",
"type": null
},
{
"param": "unique_terms_citations_NNP",
"type": null
}... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tags",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "unique_terms_citations_CD",
"type": null,
"docstring": null,
... |
baba766bbbbdbf7ef65ded653ebb09022b30dbbd | GuyKeogh/wiki_factcheck | source/dataparsing/text_tagging.py | [
"BSD-2-Clause"
] | Python | mark_present_quotes | <not_specific> | def mark_present_quotes(data, quote, if_quote_in_citation):
"""With a citation and a text, marks if it's in that text"""
quote_in_data_startword = 0
index = 0
if_in_quote = False
quote_list = word_tokenize(quote) #List of each word in quote
#Find quote in data
for word in data: #find() won't... | With a citation and a text, marks if it's in that text | With a citation and a text, marks if it's in that text | [
"With",
"a",
"citation",
"and",
"a",
"text",
"marks",
"if",
"it",
"'",
"s",
"in",
"that",
"text"
] | def mark_present_quotes(data, quote, if_quote_in_citation):
quote_in_data_startword = 0
index = 0
if_in_quote = False
quote_list = word_tokenize(quote)
for word in data:
if not if_in_quote:
if word[0]==quote_list[0]:
if_in_quote = True
quote_in_d... | [
"def",
"mark_present_quotes",
"(",
"data",
",",
"quote",
",",
"if_quote_in_citation",
")",
":",
"quote_in_data_startword",
"=",
"0",
"index",
"=",
"0",
"if_in_quote",
"=",
"False",
"quote_list",
"=",
"word_tokenize",
"(",
"quote",
")",
"for",
"word",
"in",
"da... | With a citation and a text, marks if it's in that text | [
"With",
"a",
"citation",
"and",
"a",
"text",
"marks",
"if",
"it",
"'",
"s",
"in",
"that",
"text"
] | [
"\"\"\"With a citation and a text, marks if it's in that text\"\"\"",
"#List of each word in quote",
"#Find quote in data",
"#find() won't work, as data is in a different format",
"#If we seem to be in a quote, check it's still true",
"#Fully detected the quote"
] | [
{
"param": "data",
"type": null
},
{
"param": "quote",
"type": null
},
{
"param": "if_quote_in_citation",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "quote",
"type": null,
"docstring": null,
"docstring_tokens": ... |
baba766bbbbdbf7ef65ded653ebb09022b30dbbd | GuyKeogh/wiki_factcheck | source/dataparsing/text_tagging.py | [
"BSD-2-Clause"
] | Python | detect_quotes_in_string | <not_specific> | def detect_quotes_in_string(data, input_text, text_quotes):
"""With every quote and the sole text (used in correction), mark citations present"""
for quote in text_quotes:
if_quote_in_citation = check_quote_in_text(quote, input_text)
data = mark_present_quotes(data, quote, if_quote_in_citation)
... | With every quote and the sole text (used in correction), mark citations present | With every quote and the sole text (used in correction), mark citations present | [
"With",
"every",
"quote",
"and",
"the",
"sole",
"text",
"(",
"used",
"in",
"correction",
")",
"mark",
"citations",
"present"
] | def detect_quotes_in_string(data, input_text, text_quotes):
for quote in text_quotes:
if_quote_in_citation = check_quote_in_text(quote, input_text)
data = mark_present_quotes(data, quote, if_quote_in_citation)
return data | [
"def",
"detect_quotes_in_string",
"(",
"data",
",",
"input_text",
",",
"text_quotes",
")",
":",
"for",
"quote",
"in",
"text_quotes",
":",
"if_quote_in_citation",
"=",
"check_quote_in_text",
"(",
"quote",
",",
"input_text",
")",
"data",
"=",
"mark_present_quotes",
... | With every quote and the sole text (used in correction), mark citations present | [
"With",
"every",
"quote",
"and",
"the",
"sole",
"text",
"(",
"used",
"in",
"correction",
")",
"mark",
"citations",
"present"
] | [
"\"\"\"With every quote and the sole text (used in correction), mark citations present\"\"\""
] | [
{
"param": "data",
"type": null
},
{
"param": "input_text",
"type": null
},
{
"param": "text_quotes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input_text",
"type": null,
"docstring": null,
"docstring_toke... |
baba766bbbbdbf7ef65ded653ebb09022b30dbbd | GuyKeogh/wiki_factcheck | source/dataparsing/text_tagging.py | [
"BSD-2-Clause"
] | Python | detect_quotes_in_multiple_texts | <not_specific> | def detect_quotes_in_multiple_texts(data, citation_text, text_quotes):
"""With every quote and all texts, mark all citations that are present"""
for quote in text_quotes:
if_quote_in_citation = False
for citation in citation_text:
if not if_quote_in_citation: #Just needs to be in one... | With every quote and all texts, mark all citations that are present | With every quote and all texts, mark all citations that are present | [
"With",
"every",
"quote",
"and",
"all",
"texts",
"mark",
"all",
"citations",
"that",
"are",
"present"
] | def detect_quotes_in_multiple_texts(data, citation_text, text_quotes):
for quote in text_quotes:
if_quote_in_citation = False
for citation in citation_text:
if not if_quote_in_citation:
if_quote_in_citation = check_quote_in_text(quote, citation)
data = mark_prese... | [
"def",
"detect_quotes_in_multiple_texts",
"(",
"data",
",",
"citation_text",
",",
"text_quotes",
")",
":",
"for",
"quote",
"in",
"text_quotes",
":",
"if_quote_in_citation",
"=",
"False",
"for",
"citation",
"in",
"citation_text",
":",
"if",
"not",
"if_quote_in_citati... | With every quote and all texts, mark all citations that are present | [
"With",
"every",
"quote",
"and",
"all",
"texts",
"mark",
"all",
"citations",
"that",
"are",
"present"
] | [
"\"\"\"With every quote and all texts, mark all citations that are present\"\"\"",
"#Just needs to be in one citation"
] | [
{
"param": "data",
"type": null
},
{
"param": "citation_text",
"type": null
},
{
"param": "text_quotes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "citation_text",
"type": null,
"docstring": null,
"docstring_t... |
91e9d4b62241de31b45872f53b60970f8edf5dc7 | GuyKeogh/wiki_factcheck | source/io/output.py | [
"BSD-2-Clause"
] | Python | parse_HTML | <not_specific> | def parse_HTML(data):
"""Create the final HTML that's output to the user"""
if_header2_open = if_header3_open = if_bold_open = if_italic_open = if_paragraph_open = False
combined = ""
for word in data:
article_word = encode_text(word[0])
if(word[1]!="," and word[1]!= "'" and word[1]!... | Create the final HTML that's output to the user | Create the final HTML that's output to the user | [
"Create",
"the",
"final",
"HTML",
"that",
"'",
"s",
"output",
"to",
"the",
"user"
] | def parse_HTML(data):
if_header2_open = if_header3_open = if_bold_open = if_italic_open = if_paragraph_open = False
combined = ""
for word in data:
article_word = encode_text(word[0])
if(word[1]!="," and word[1]!= "'" and word[1]!= "." and word[0]!= "'s"
and word[1]!="``" and w... | [
"def",
"parse_HTML",
"(",
"data",
")",
":",
"if_header2_open",
"=",
"if_header3_open",
"=",
"if_bold_open",
"=",
"if_italic_open",
"=",
"if_paragraph_open",
"=",
"False",
"combined",
"=",
"\"\"",
"for",
"word",
"in",
"data",
":",
"article_word",
"=",
"encode_tex... | Create the final HTML that's output to the user | [
"Create",
"the",
"final",
"HTML",
"that",
"'",
"s",
"output",
"to",
"the",
"user"
] | [
"\"\"\"Create the final HTML that's output to the user\"\"\"",
"#Punctuation that doesn't need space before it",
"#Quotation marks",
"#<h2> is too big, so consistently bring it down a number",
"#Punctuation, so no space needed."
] | [
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
91e9d4b62241de31b45872f53b60970f8edf5dc7 | GuyKeogh/wiki_factcheck | source/io/output.py | [
"BSD-2-Clause"
] | Python | record_error | null | def record_error(article_title, error):
"""If an error occurred, write the details of it to a file with the current timestamp"""
try:
file = open("errors.log", 'a')
error_msg = error + " on article '" + article_title + "'"
file.write(error_msg)
file.close()
except:
..... | If an error occurred, write the details of it to a file with the current timestamp | If an error occurred, write the details of it to a file with the current timestamp | [
"If",
"an",
"error",
"occurred",
"write",
"the",
"details",
"of",
"it",
"to",
"a",
"file",
"with",
"the",
"current",
"timestamp"
] | def record_error(article_title, error):
try:
file = open("errors.log", 'a')
error_msg = error + " on article '" + article_title + "'"
file.write(error_msg)
file.close()
except:
... | [
"def",
"record_error",
"(",
"article_title",
",",
"error",
")",
":",
"try",
":",
"file",
"=",
"open",
"(",
"\"errors.log\"",
",",
"'a'",
")",
"error_msg",
"=",
"error",
"+",
"\" on article '\"",
"+",
"article_title",
"+",
"\"'\"",
"file",
".",
"write",
"("... | If an error occurred, write the details of it to a file with the current timestamp | [
"If",
"an",
"error",
"occurred",
"write",
"the",
"details",
"of",
"it",
"to",
"a",
"file",
"with",
"the",
"current",
"timestamp"
] | [
"\"\"\"If an error occurred, write the details of it to a file with the current timestamp\"\"\""
] | [
{
"param": "article_title",
"type": null
},
{
"param": "error",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "article_title",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "error",
"type": null,
"docstring": null,
"docstring_... |
91e9d4b62241de31b45872f53b60970f8edf5dc7 | GuyKeogh/wiki_factcheck | source/io/output.py | [
"BSD-2-Clause"
] | Python | encode_text | <not_specific> | def encode_text(text):
"""Encode data to help prevent XSS attacks from text in article"""
#Most efficient way is to chain these together ( https://stackoverflow.com/questions/3411771/best-way-to-replace-multiple-characters-in-a-string )
text = text.replace('&','&').replace('<','<').replace('>','>').r... | Encode data to help prevent XSS attacks from text in article | Encode data to help prevent XSS attacks from text in article | [
"Encode",
"data",
"to",
"help",
"prevent",
"XSS",
"attacks",
"from",
"text",
"in",
"article"
] | def encode_text(text):
text = text.replace('&','&').replace('<','<').replace('>','>').replace('"','"').replace("'",''')
return text | [
"def",
"encode_text",
"(",
"text",
")",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"'&'",
",",
"'&'",
")",
".",
"replace",
"(",
"'<'",
",",
"'<'",
")",
".",
"replace",
"(",
"'>'",
",",
"'>'",
")",
".",
"replace",
"(",
"'\"'",
",",
"'&q... | Encode data to help prevent XSS attacks from text in article | [
"Encode",
"data",
"to",
"help",
"prevent",
"XSS",
"attacks",
"from",
"text",
"in",
"article"
] | [
"\"\"\"Encode data to help prevent XSS attacks from text in article\"\"\"",
"#Most efficient way is to chain these together ( https://stackoverflow.com/questions/3411771/best-way-to-replace-multiple-characters-in-a-string )"
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8893a135fd1f07f41ecff187a951a67e864aa229 | GuyKeogh/wiki_factcheck | source/io/filter_title.py | [
"BSD-2-Clause"
] | Python | if_title_invalid_symbol_use | <not_specific> | def if_title_invalid_symbol_use(title):
"""If the title has an invalid name besides spaces, return True"""
title_length = len(title)
if title_length==0: #To prevent out of bounds
return True
#Symbols not allowed at all:
char_blacklist = [ #Characters not possible in a title
'[',
... | If the title has an invalid name besides spaces, return True | If the title has an invalid name besides spaces, return True | [
"If",
"the",
"title",
"has",
"an",
"invalid",
"name",
"besides",
"spaces",
"return",
"True"
] | def if_title_invalid_symbol_use(title):
title_length = len(title)
if title_length==0:
return True
char_blacklist = [
'[',
']',
'<',
'>',
'{',
'}',
'#',
]
for elem in title:
if elem in char_blacklist:
return True
... | [
"def",
"if_title_invalid_symbol_use",
"(",
"title",
")",
":",
"title_length",
"=",
"len",
"(",
"title",
")",
"if",
"title_length",
"==",
"0",
":",
"return",
"True",
"char_blacklist",
"=",
"[",
"'['",
",",
"']'",
",",
"'<'",
",",
"'>'",
",",
"'{'",
",",
... | If the title has an invalid name besides spaces, return True | [
"If",
"the",
"title",
"has",
"an",
"invalid",
"name",
"besides",
"spaces",
"return",
"True"
] | [
"\"\"\"If the title has an invalid name besides spaces, return True\"\"\"",
"#To prevent out of bounds",
"#Symbols not allowed at all:",
"#Characters not possible in a title",
"#Could possibly just ignore text after this",
"#If any symbol is bad it's all invalid.",
"#Symbols not allowed as first charact... | [
{
"param": "title",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "title",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8492b7f3141e466a124d97420afc9f216afef486 | GuyKeogh/wiki_factcheck | source/io/web_scraper.py | [
"BSD-2-Clause"
] | Python | generate_api_header | <not_specific> | def generate_api_header():
"""Creates the HTTP header which is sent when making Wikipedia API calls"""
if_from_web_text = "from web"
if not __metadata__.__IF_WEB__:
if_from_web_text = "from desktop" #If it's locally launched, mention that
header = {
'User-Agent': 'wiki_verify/'+__me... | Creates the HTTP header which is sent when making Wikipedia API calls | Creates the HTTP header which is sent when making Wikipedia API calls | [
"Creates",
"the",
"HTTP",
"header",
"which",
"is",
"sent",
"when",
"making",
"Wikipedia",
"API",
"calls"
] | def generate_api_header():
if_from_web_text = "from web"
if not __metadata__.__IF_WEB__:
if_from_web_text = "from desktop"
header = {
'User-Agent': 'wiki_verify/'+__metadata__.__VERSION__+"(https://verify.toolforge.org/) "+if_from_web_text,
'UPGRADE-INSECURE-REQUESTS': "1",
... | [
"def",
"generate_api_header",
"(",
")",
":",
"if_from_web_text",
"=",
"\"from web\"",
"if",
"not",
"__metadata__",
".",
"__IF_WEB__",
":",
"if_from_web_text",
"=",
"\"from desktop\"",
"header",
"=",
"{",
"'User-Agent'",
":",
"'wiki_verify/'",
"+",
"__metadata__",
".... | Creates the HTTP header which is sent when making Wikipedia API calls | [
"Creates",
"the",
"HTTP",
"header",
"which",
"is",
"sent",
"when",
"making",
"Wikipedia",
"API",
"calls"
] | [
"\"\"\"Creates the HTTP header which is sent when making Wikipedia API calls\"\"\"",
"#If it's locally launched, mention that",
"#gzip preferred by API"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8492b7f3141e466a124d97420afc9f216afef486 | GuyKeogh/wiki_factcheck | source/io/web_scraper.py | [
"BSD-2-Clause"
] | Python | generate_header | <not_specific> | def generate_header(language=""):
"""Creates the HTTP header which is sent when requesting citations"""
if_from_web_text = "from web"
if not __metadata__.__IF_WEB__:
if_from_web_text = "from desktop" #If it's locally launched, mention that
header = {
'User-Agent': 'wiki_verify/'+__m... | Creates the HTTP header which is sent when requesting citations | Creates the HTTP header which is sent when requesting citations | [
"Creates",
"the",
"HTTP",
"header",
"which",
"is",
"sent",
"when",
"requesting",
"citations"
] | def generate_header(language=""):
if_from_web_text = "from web"
if not __metadata__.__IF_WEB__:
if_from_web_text = "from desktop"
header = {
'User-Agent': 'wiki_verify/'+__metadata__.__VERSION__+"(https://verify.toolforge.org/) "+if_from_web_text,
'Accept-Language': "en-US,en;q=0.5"... | [
"def",
"generate_header",
"(",
"language",
"=",
"\"\"",
")",
":",
"if_from_web_text",
"=",
"\"from web\"",
"if",
"not",
"__metadata__",
".",
"__IF_WEB__",
":",
"if_from_web_text",
"=",
"\"from desktop\"",
"header",
"=",
"{",
"'User-Agent'",
":",
"'wiki_verify/'",
... | Creates the HTTP header which is sent when requesting citations | [
"Creates",
"the",
"HTTP",
"header",
"which",
"is",
"sent",
"when",
"requesting",
"citations"
] | [
"\"\"\"Creates the HTTP header which is sent when requesting citations\"\"\"",
"#If it's locally launched, mention that",
"#Automatically decompressed by requests"
] | [
{
"param": "language",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "language",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8492b7f3141e466a124d97420afc9f216afef486 | GuyKeogh/wiki_factcheck | source/io/web_scraper.py | [
"BSD-2-Clause"
] | Python | download_article | <not_specific> | def download_article(article_title, language):
"""Download the Wikipedia article text and mark safe HTML elements with codes so they remain the same"""
response = requests.get(
'https://'+language+'.wikipedia.org/w/api.php',
params={
'action': 'query',
'titles': article_title,
'format': 'jso... | Download the Wikipedia article text and mark safe HTML elements with codes so they remain the same | Download the Wikipedia article text and mark safe HTML elements with codes so they remain the same | [
"Download",
"the",
"Wikipedia",
"article",
"text",
"and",
"mark",
"safe",
"HTML",
"elements",
"with",
"codes",
"so",
"they",
"remain",
"the",
"same"
] | def download_article(article_title, language):
response = requests.get(
'https://'+language+'.wikipedia.org/w/api.php',
params={
'action': 'query',
'titles': article_title,
'format': 'json',
'prop': 'extracts',
'exsectionformat': 'plain',
},
headers = generate_api_header()
)... | [
"def",
"download_article",
"(",
"article_title",
",",
"language",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"'https://'",
"+",
"language",
"+",
"'.wikipedia.org/w/api.php'",
",",
"params",
"=",
"{",
"'action'",
":",
"'query'",
",",
"'titles'",
":... | Download the Wikipedia article text and mark safe HTML elements with codes so they remain the same | [
"Download",
"the",
"Wikipedia",
"article",
"text",
"and",
"mark",
"safe",
"HTML",
"elements",
"with",
"codes",
"so",
"they",
"remain",
"the",
"same"
] | [
"\"\"\"Download the Wikipedia article text and mark safe HTML elements with codes so they remain the same\"\"\"",
"#https://www.mediawiki.org/w/api.php?action=help&modules=query%2Bextracts"
] | [
{
"param": "article_title",
"type": null
},
{
"param": "language",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "article_title",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "language",
"type": null,
"docstring": null,
"docstri... |
8492b7f3141e466a124d97420afc9f216afef486 | GuyKeogh/wiki_factcheck | source/io/web_scraper.py | [
"BSD-2-Clause"
] | Python | download_external_URLs | <not_specific> | def download_external_URLs(article_title, language):
"""Get list of every unique URL in the Wikipedia article"""
external_link_limit = 500
if __metadata__.__IF_WEB__:
external_link_limit = __metadata__.__WEB_EXTERNAL_URL_LIMIT__+1 #+1 so error can be reported if too many
external_URLs =... | Get list of every unique URL in the Wikipedia article | Get list of every unique URL in the Wikipedia article | [
"Get",
"list",
"of",
"every",
"unique",
"URL",
"in",
"the",
"Wikipedia",
"article"
] | def download_external_URLs(article_title, language):
external_link_limit = 500
if __metadata__.__IF_WEB__:
external_link_limit = __metadata__.__WEB_EXTERNAL_URL_LIMIT__+1
external_URLs = []
try:
response = requests.get(
'https://'+language+'.wikipedia.org/w/api.php',
par... | [
"def",
"download_external_URLs",
"(",
"article_title",
",",
"language",
")",
":",
"external_link_limit",
"=",
"500",
"if",
"__metadata__",
".",
"__IF_WEB__",
":",
"external_link_limit",
"=",
"__metadata__",
".",
"__WEB_EXTERNAL_URL_LIMIT__",
"+",
"1",
"external_URLs",
... | Get list of every unique URL in the Wikipedia article | [
"Get",
"list",
"of",
"every",
"unique",
"URL",
"in",
"the",
"Wikipedia",
"article"
] | [
"\"\"\"Get list of every unique URL in the Wikipedia article\"\"\"",
"#+1 so error can be reported if too many",
"#https://www.mediawiki.org/w/api.php?action=help&modules=query%2Bextlinks",
"#Access the created dictionary of URLs and output a single list",
"#Make sure all URLs unique, e.g. an external URL m... | [
{
"param": "article_title",
"type": null
},
{
"param": "language",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "article_title",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "language",
"type": null,
"docstring": null,
"docstri... |
8492b7f3141e466a124d97420afc9f216afef486 | GuyKeogh/wiki_factcheck | source/io/web_scraper.py | [
"BSD-2-Clause"
] | Python | remove_junk | <not_specific> | def remove_junk(text):
"""Get rid of HTML and script tags in the citation text"""
output = ''
#Rm tags and scripts
word_blacklist = [
'[document]',
'noscript',
'header',
'html',
'meta',
'head',
'input',
'script',
'footer',
'... | Get rid of HTML and script tags in the citation text | Get rid of HTML and script tags in the citation text | [
"Get",
"rid",
"of",
"HTML",
"and",
"script",
"tags",
"in",
"the",
"citation",
"text"
] | def remove_junk(text):
output = ''
word_blacklist = [
'[document]',
'noscript',
'header',
'html',
'meta',
'head',
'input',
'script',
'footer',
'style',
]
for word in text:
if word.parent.name not in word_blacklist:
... | [
"def",
"remove_junk",
"(",
"text",
")",
":",
"output",
"=",
"''",
"word_blacklist",
"=",
"[",
"'[document]'",
",",
"'noscript'",
",",
"'header'",
",",
"'html'",
",",
"'meta'",
",",
"'head'",
",",
"'input'",
",",
"'script'",
",",
"'footer'",
",",
"'style'",... | Get rid of HTML and script tags in the citation text | [
"Get",
"rid",
"of",
"HTML",
"and",
"script",
"tags",
"in",
"the",
"citation",
"text"
] | [
"\"\"\"Get rid of HTML and script tags in the citation text\"\"\"",
"#Rm tags and scripts",
"#Strip tabs, newlines, etc"
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9165a4f79131d85e1118bf1bc2cc7f92950a85a2 | rixx/django-hierarkey | hierarkey/proxy.py | [
"Apache-2.0"
] | Python | _objects | <not_specific> | def _objects(self):
"""
Returns a model manager (or related object manager) giving access to the raw objects backing this
storage level.
"""
return getattr(self._obj, '_%s_objects' % self._h.attribute_name) |
Returns a model manager (or related object manager) giving access to the raw objects backing this
storage level.
| Returns a model manager (or related object manager) giving access to the raw objects backing this
storage level. | [
"Returns",
"a",
"model",
"manager",
"(",
"or",
"related",
"object",
"manager",
")",
"giving",
"access",
"to",
"the",
"raw",
"objects",
"backing",
"this",
"storage",
"level",
"."
] | def _objects(self):
return getattr(self._obj, '_%s_objects' % self._h.attribute_name) | [
"def",
"_objects",
"(",
"self",
")",
":",
"return",
"getattr",
"(",
"self",
".",
"_obj",
",",
"'_%s_objects'",
"%",
"self",
".",
"_h",
".",
"attribute_name",
")"
] | Returns a model manager (or related object manager) giving access to the raw objects backing this
storage level. | [
"Returns",
"a",
"model",
"manager",
"(",
"or",
"related",
"object",
"manager",
")",
"giving",
"access",
"to",
"the",
"raw",
"objects",
"backing",
"this",
"storage",
"level",
"."
] | [
"\"\"\"\n Returns a model manager (or related object manager) giving access to the raw objects backing this\n storage level.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9165a4f79131d85e1118bf1bc2cc7f92950a85a2 | rixx/django-hierarkey | hierarkey/proxy.py | [
"Apache-2.0"
] | Python | flush | None | def flush(self) -> None:
"""
Discards both the state within this object as well as the cache in Django's cache backend.
"""
self._cached_obj = None
self._write_cached_obj = None
self._flush_external_cache() |
Discards both the state within this object as well as the cache in Django's cache backend.
| Discards both the state within this object as well as the cache in Django's cache backend. | [
"Discards",
"both",
"the",
"state",
"within",
"this",
"object",
"as",
"well",
"as",
"the",
"cache",
"in",
"Django",
"'",
"s",
"cache",
"backend",
"."
] | def flush(self) -> None:
self._cached_obj = None
self._write_cached_obj = None
self._flush_external_cache() | [
"def",
"flush",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_cached_obj",
"=",
"None",
"self",
".",
"_write_cached_obj",
"=",
"None",
"self",
".",
"_flush_external_cache",
"(",
")"
] | Discards both the state within this object as well as the cache in Django's cache backend. | [
"Discards",
"both",
"the",
"state",
"within",
"this",
"object",
"as",
"well",
"as",
"the",
"cache",
"in",
"Django",
"'",
"s",
"cache",
"backend",
"."
] | [
"\"\"\"\n Discards both the state within this object as well as the cache in Django's cache backend.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9165a4f79131d85e1118bf1bc2cc7f92950a85a2 | rixx/django-hierarkey | hierarkey/proxy.py | [
"Apache-2.0"
] | Python | freeze | dict | def freeze(self) -> dict:
"""
Returns a dictionary of all settings set for this object, including
any values of its parents or hardcoded defaults.
"""
settings = {}
for key, v in self._h.defaults.items():
settings[key] = self._unserialize(v.value, v.type)
... |
Returns a dictionary of all settings set for this object, including
any values of its parents or hardcoded defaults.
| Returns a dictionary of all settings set for this object, including
any values of its parents or hardcoded defaults. | [
"Returns",
"a",
"dictionary",
"of",
"all",
"settings",
"set",
"for",
"this",
"object",
"including",
"any",
"values",
"of",
"its",
"parents",
"or",
"hardcoded",
"defaults",
"."
] | def freeze(self) -> dict:
settings = {}
for key, v in self._h.defaults.items():
settings[key] = self._unserialize(v.value, v.type)
if self._parent:
settings.update(getattr(self._parent, self._h.attribute_name).freeze())
for key in self._cache():
settin... | [
"def",
"freeze",
"(",
"self",
")",
"->",
"dict",
":",
"settings",
"=",
"{",
"}",
"for",
"key",
",",
"v",
"in",
"self",
".",
"_h",
".",
"defaults",
".",
"items",
"(",
")",
":",
"settings",
"[",
"key",
"]",
"=",
"self",
".",
"_unserialize",
"(",
... | Returns a dictionary of all settings set for this object, including
any values of its parents or hardcoded defaults. | [
"Returns",
"a",
"dictionary",
"of",
"all",
"settings",
"set",
"for",
"this",
"object",
"including",
"any",
"values",
"of",
"its",
"parents",
"or",
"hardcoded",
"defaults",
"."
] | [
"\"\"\"\n Returns a dictionary of all settings set for this object, including\n any values of its parents or hardcoded defaults.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9165a4f79131d85e1118bf1bc2cc7f92950a85a2 | rixx/django-hierarkey | hierarkey/proxy.py | [
"Apache-2.0"
] | Python | delete | None | def delete(self, key: str) -> None:
"""
Deletes a setting from this object's storage.
The write to the database is performed immediately and the cache in the cache backend is flushed.
The cache within this object will be updated correctly.
"""
if key in self._write_cache... |
Deletes a setting from this object's storage.
The write to the database is performed immediately and the cache in the cache backend is flushed.
The cache within this object will be updated correctly.
| Deletes a setting from this object's storage.
The write to the database is performed immediately and the cache in the cache backend is flushed.
The cache within this object will be updated correctly. | [
"Deletes",
"a",
"setting",
"from",
"this",
"object",
"'",
"s",
"storage",
".",
"The",
"write",
"to",
"the",
"database",
"is",
"performed",
"immediately",
"and",
"the",
"cache",
"in",
"the",
"cache",
"backend",
"is",
"flushed",
".",
"The",
"cache",
"within"... | def delete(self, key: str) -> None:
if key in self._write_cache():
self._write_cache()[key].delete()
del self._write_cache()[key]
if key in self._cache():
del self._cache()[key]
self._flush_external_cache() | [
"def",
"delete",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"None",
":",
"if",
"key",
"in",
"self",
".",
"_write_cache",
"(",
")",
":",
"self",
".",
"_write_cache",
"(",
")",
"[",
"key",
"]",
".",
"delete",
"(",
")",
"del",
"self",
".",
"_... | Deletes a setting from this object's storage. | [
"Deletes",
"a",
"setting",
"from",
"this",
"object",
"'",
"s",
"storage",
"."
] | [
"\"\"\"\n Deletes a setting from this object's storage.\n\n The write to the database is performed immediately and the cache in the cache backend is flushed.\n The cache within this object will be updated correctly.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "key",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "str",
"docstring": null,
"docstring_tokens": [... |
7c87a8a9a811d1766417700029f13134caee55c9 | rixx/django-hierarkey | hierarkey/forms.py | [
"Apache-2.0"
] | Python | save | None | def save(self) -> None:
"""
Saves all changed values to the database.
"""
for name, field in self.fields.items():
value = self.cleaned_data[name]
if isinstance(value, UploadedFile):
# Delete old file
fname = self._s.get(name, as_typ... |
Saves all changed values to the database.
| Saves all changed values to the database. | [
"Saves",
"all",
"changed",
"values",
"to",
"the",
"database",
"."
] | def save(self) -> None:
for name, field in self.fields.items():
value = self.cleaned_data[name]
if isinstance(value, UploadedFile):
fname = self._s.get(name, as_type=File)
if fname:
try:
default_storage.delete(fn... | [
"def",
"save",
"(",
"self",
")",
"->",
"None",
":",
"for",
"name",
",",
"field",
"in",
"self",
".",
"fields",
".",
"items",
"(",
")",
":",
"value",
"=",
"self",
".",
"cleaned_data",
"[",
"name",
"]",
"if",
"isinstance",
"(",
"value",
",",
"Uploaded... | Saves all changed values to the database. | [
"Saves",
"all",
"changed",
"values",
"to",
"the",
"database",
"."
] | [
"\"\"\"\n Saves all changed values to the database.\n \"\"\"",
"# Delete old file",
"# pragma: no cover",
"# Create new file",
"# file is unchanged",
"# file is deleted",
"# pragma: no cover"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6208e61ad3e3fd08412bd850573d1917773b1101 | rixx/django-hierarkey | hierarkey/models.py | [
"Apache-2.0"
] | Python | add_default | None | def add_default(self, key: str, value: Optional[str], default_type: type = str) -> None:
"""
Adds a default value and a default type for a key.
:param key: Key
:param value: *Serialized* default value, i.e. a string or ``None``.
:param default_type: The type to deserialize value... |
Adds a default value and a default type for a key.
:param key: Key
:param value: *Serialized* default value, i.e. a string or ``None``.
:param default_type: The type to deserialize values for this key to, defaults to ``str``.
| Adds a default value and a default type for a key. | [
"Adds",
"a",
"default",
"value",
"and",
"a",
"default",
"type",
"for",
"a",
"key",
"."
] | def add_default(self, key: str, value: Optional[str], default_type: type = str) -> None:
self.defaults[key] = HierarkeyDefault(value, default_type) | [
"def",
"add_default",
"(",
"self",
",",
"key",
":",
"str",
",",
"value",
":",
"Optional",
"[",
"str",
"]",
",",
"default_type",
":",
"type",
"=",
"str",
")",
"->",
"None",
":",
"self",
".",
"defaults",
"[",
"key",
"]",
"=",
"HierarkeyDefault",
"(",
... | Adds a default value and a default type for a key. | [
"Adds",
"a",
"default",
"value",
"and",
"a",
"default",
"type",
"for",
"a",
"key",
"."
] | [
"\"\"\"\n Adds a default value and a default type for a key.\n\n :param key: Key\n :param value: *Serialized* default value, i.e. a string or ``None``.\n :param default_type: The type to deserialize values for this key to, defaults to ``str``.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "key",
"type": "str"
},
{
"param": "value",
"type": "Optional[str]"
},
{
"param": "default_type",
"type": "type"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": "str",
"docstring": null,
"docstring_tokens": [... |
6208e61ad3e3fd08412bd850573d1917773b1101 | rixx/django-hierarkey | hierarkey/models.py | [
"Apache-2.0"
] | Python | add_type | None | def add_type(self, type: type, serialize: Callable[[Any], str], unserialize: Callable[[str], Any]) -> None:
"""
Adds serialization support for a new type.
:param type: The type to add support for.
:param serialize: A callable that takes an object of type ``type`` and returns a string.
... |
Adds serialization support for a new type.
:param type: The type to add support for.
:param serialize: A callable that takes an object of type ``type`` and returns a string.
:param unserialize: A callable that takes a string and returns an object of type ``type``.
| Adds serialization support for a new type. | [
"Adds",
"serialization",
"support",
"for",
"a",
"new",
"type",
"."
] | def add_type(self, type: type, serialize: Callable[[Any], str], unserialize: Callable[[str], Any]) -> None:
self.types.append(HierarkeyType(type=type, serialize=serialize, unserialize=unserialize)) | [
"def",
"add_type",
"(",
"self",
",",
"type",
":",
"type",
",",
"serialize",
":",
"Callable",
"[",
"[",
"Any",
"]",
",",
"str",
"]",
",",
"unserialize",
":",
"Callable",
"[",
"[",
"str",
"]",
",",
"Any",
"]",
")",
"->",
"None",
":",
"self",
".",
... | Adds serialization support for a new type. | [
"Adds",
"serialization",
"support",
"for",
"a",
"new",
"type",
"."
] | [
"\"\"\"\n Adds serialization support for a new type.\n\n :param type: The type to add support for.\n :param serialize: A callable that takes an object of type ``type`` and returns a string.\n :param unserialize: A callable that takes a string and returns an object of type ``type``.\n ... | [
{
"param": "self",
"type": null
},
{
"param": "type",
"type": "type"
},
{
"param": "serialize",
"type": "Callable[[Any], str]"
},
{
"param": "unserialize",
"type": "Callable[[str], Any]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "type",
"type": "type",
"docstring": "The type to add support for.",... |
6208e61ad3e3fd08412bd850573d1917773b1101 | rixx/django-hierarkey | hierarkey/models.py | [
"Apache-2.0"
] | Python | add | type | def add(self, cache_namespace: str = None, parent_field: str = None) -> type:
"""
Decorator. Attaches a global key-value store to a Django model.
:param cache_namespace: Optional. A custom namespace used for caching. By default this is
constructed from the name o... |
Decorator. Attaches a global key-value store to a Django model.
:param cache_namespace: Optional. A custom namespace used for caching. By default this is
constructed from the name of the class this is applied to and
the ``attribute_name``... | Decorator. Attaches a global key-value store to a Django model. | [
"Decorator",
".",
"Attaches",
"a",
"global",
"key",
"-",
"value",
"store",
"to",
"a",
"Django",
"model",
"."
] | def add(self, cache_namespace: str = None, parent_field: str = None) -> type:
if isinstance(cache_namespace, type):
raise ImproperlyConfigured('Incorrect decorator usage, you need to use .add() instead of .add')
def wrapper(model):
if not issubclass(model, models.Model):
... | [
"def",
"add",
"(",
"self",
",",
"cache_namespace",
":",
"str",
"=",
"None",
",",
"parent_field",
":",
"str",
"=",
"None",
")",
"->",
"type",
":",
"if",
"isinstance",
"(",
"cache_namespace",
",",
"type",
")",
":",
"raise",
"ImproperlyConfigured",
"(",
"'I... | Decorator. | [
"Decorator",
"."
] | [
"\"\"\"\n Decorator. Attaches a global key-value store to a Django model.\n\n :param cache_namespace: Optional. A custom namespace used for caching. By default this is\n constructed from the name of the class this is applied to and\n the ``... | [
{
"param": "self",
"type": null
},
{
"param": "cache_namespace",
"type": "str"
},
{
"param": "parent_field",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cache_namespace",
"type": "str",
"docstring": "Optional. A custom n... |
52728aa4e3bd3b13f9e739a1be9da31ad2dbe61f | Liatwilight/txtai | src/python/txtai/tokenizer.py | [
"Apache-2.0"
] | Python | tokenize | <not_specific> | def tokenize(text):
"""
Tokenizes input text into a list of tokens. Filters tokens that match a specific pattern and removes stop words.
Args:
text: input text
Returns:
list of tokens
"""
# Convert to all lowercase, split on whitespace, strip pu... |
Tokenizes input text into a list of tokens. Filters tokens that match a specific pattern and removes stop words.
Args:
text: input text
Returns:
list of tokens
| Tokenizes input text into a list of tokens. Filters tokens that match a specific pattern and removes stop words. | [
"Tokenizes",
"input",
"text",
"into",
"a",
"list",
"of",
"tokens",
".",
"Filters",
"tokens",
"that",
"match",
"a",
"specific",
"pattern",
"and",
"removes",
"stop",
"words",
"."
] | def tokenize(text):
tokens = [token.strip(string.punctuation) for token in text.lower().split()]
return [token for token in tokens if re.match(r"^\d*[a-z][\-.0-9:_a-z]{1,}$", token) and token not in Tokenizer.STOP_WORDS] | [
"def",
"tokenize",
"(",
"text",
")",
":",
"tokens",
"=",
"[",
"token",
".",
"strip",
"(",
"string",
".",
"punctuation",
")",
"for",
"token",
"in",
"text",
".",
"lower",
"(",
")",
".",
"split",
"(",
")",
"]",
"return",
"[",
"token",
"for",
"token",
... | Tokenizes input text into a list of tokens. | [
"Tokenizes",
"input",
"text",
"into",
"a",
"list",
"of",
"tokens",
"."
] | [
"\"\"\"\n Tokenizes input text into a list of tokens. Filters tokens that match a specific pattern and removes stop words.\n\n Args:\n text: input text\n\n Returns:\n list of tokens\n \"\"\"",
"# Convert to all lowercase, split on whitespace, strip punctuation",
... | [
{
"param": "text",
"type": null
}
] | {
"returns": [
{
"docstring": "list of tokens",
"docstring_tokens": [
"list",
"of",
"tokens"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [
"... |
46d157f74b3f98c7c401e7877af65cb60c22bc76 | Liatwilight/txtai | src/python/txtai/scoring.py | [
"Apache-2.0"
] | Python | create | <not_specific> | def create(method):
"""
Factory method to construct a Scoring object.
Args:
method: scoring method (bm25, sif, tfidf)
Returns:
Scoring object
"""
if method == "bm25":
return BM25()
elif method == "sif":
return SIF... |
Factory method to construct a Scoring object.
Args:
method: scoring method (bm25, sif, tfidf)
Returns:
Scoring object
| Factory method to construct a Scoring object. | [
"Factory",
"method",
"to",
"construct",
"a",
"Scoring",
"object",
"."
] | def create(method):
if method == "bm25":
return BM25()
elif method == "sif":
return SIF()
elif method == "tfidf":
return Scoring()
return None | [
"def",
"create",
"(",
"method",
")",
":",
"if",
"method",
"==",
"\"bm25\"",
":",
"return",
"BM25",
"(",
")",
"elif",
"method",
"==",
"\"sif\"",
":",
"return",
"SIF",
"(",
")",
"elif",
"method",
"==",
"\"tfidf\"",
":",
"return",
"Scoring",
"(",
")",
"... | Factory method to construct a Scoring object. | [
"Factory",
"method",
"to",
"construct",
"a",
"Scoring",
"object",
"."
] | [
"\"\"\"\n Factory method to construct a Scoring object.\n\n Args:\n method: scoring method (bm25, sif, tfidf)\n\n Returns:\n Scoring object\n \"\"\"",
"# Default scoring object implements tf-idf"
] | [
{
"param": "method",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "method",
"type": null,
"docstring": "scoring method (bm25, sif, tfidf)",
"docstring_tokens": [
"scoring",
... |
46d157f74b3f98c7c401e7877af65cb60c22bc76 | Liatwilight/txtai | src/python/txtai/scoring.py | [
"Apache-2.0"
] | Python | index | null | def index(self, documents):
"""
Indexes a collection of documents using a scoring method. Documents are tuples of (id, text|tokens, tags).
Args:
documents: input documents
"""
# Calculate word frequency, total tokens and total documents
for _, tokens, tags i... |
Indexes a collection of documents using a scoring method. Documents are tuples of (id, text|tokens, tags).
Args:
documents: input documents
| Indexes a collection of documents using a scoring method. Documents are tuples of (id, text|tokens, tags). | [
"Indexes",
"a",
"collection",
"of",
"documents",
"using",
"a",
"scoring",
"method",
".",
"Documents",
"are",
"tuples",
"of",
"(",
"id",
"text|tokens",
"tags",
")",
"."
] | def index(self, documents):
for _, tokens, tags in documents:
if isinstance(tokens, str):
tokens = Tokenizer.tokenize(tokens)
self.wordfreq.update(tokens)
self.docfreq.update(set(tokens))
if tags:
self.tags.update(tags.split())
... | [
"def",
"index",
"(",
"self",
",",
"documents",
")",
":",
"for",
"_",
",",
"tokens",
",",
"tags",
"in",
"documents",
":",
"if",
"isinstance",
"(",
"tokens",
",",
"str",
")",
":",
"tokens",
"=",
"Tokenizer",
".",
"tokenize",
"(",
"tokens",
")",
"self",... | Indexes a collection of documents using a scoring method. | [
"Indexes",
"a",
"collection",
"of",
"documents",
"using",
"a",
"scoring",
"method",
"."
] | [
"\"\"\"\n Indexes a collection of documents using a scoring method. Documents are tuples of (id, text|tokens, tags).\n\n Args:\n documents: input documents\n \"\"\"",
"# Calculate word frequency, total tokens and total documents",
"# Convert to tokens if necessary",
"# Total nu... | [
{
"param": "self",
"type": null
},
{
"param": "documents",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "documents",
"type": null,
"docstring": null,
"docstring_token... |
46d157f74b3f98c7c401e7877af65cb60c22bc76 | Liatwilight/txtai | src/python/txtai/scoring.py | [
"Apache-2.0"
] | Python | weights | <not_specific> | def weights(self, document):
"""
Builds weight vector for each token in the input token.
Args:
document: (id, tokens, tags)
Returns:
list of weights for each token
"""
# Weights array
weights = []
# Unpack document
_, to... |
Builds weight vector for each token in the input token.
Args:
document: (id, tokens, tags)
Returns:
list of weights for each token
| Builds weight vector for each token in the input token. | [
"Builds",
"weight",
"vector",
"for",
"each",
"token",
"in",
"the",
"input",
"token",
"."
] | def weights(self, document):
weights = []
_, tokens, _ = document
length = len(tokens)
for token in tokens:
freq = self.wordfreq[token] if token in self.wordfreq else self.avgfreq
idf = self.idf[token] if token in self.idf else self.avgidf
weights.appe... | [
"def",
"weights",
"(",
"self",
",",
"document",
")",
":",
"weights",
"=",
"[",
"]",
"_",
",",
"tokens",
",",
"_",
"=",
"document",
"length",
"=",
"len",
"(",
"tokens",
")",
"for",
"token",
"in",
"tokens",
":",
"freq",
"=",
"self",
".",
"wordfreq",
... | Builds weight vector for each token in the input token. | [
"Builds",
"weight",
"vector",
"for",
"each",
"token",
"in",
"the",
"input",
"token",
"."
] | [
"\"\"\"\n Builds weight vector for each token in the input token.\n\n Args:\n document: (id, tokens, tags)\n\n Returns:\n list of weights for each token\n \"\"\"",
"# Weights array",
"# Unpack document",
"# Document length",
"# Lookup frequency and idf score... | [
{
"param": "self",
"type": null
},
{
"param": "document",
"type": null
}
] | {
"returns": [
{
"docstring": "list of weights for each token",
"docstring_tokens": [
"list",
"of",
"weights",
"for",
"each",
"token"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": nul... |
46d157f74b3f98c7c401e7877af65cb60c22bc76 | Liatwilight/txtai | src/python/txtai/scoring.py | [
"Apache-2.0"
] | Python | load | null | def load(self, path):
"""
Loads a saved Scoring object from path.
Args:
path: directory path to load model
"""
with open("%s/scoring" % path, "rb") as handle:
self.__dict__.update(pickle.load(handle)) |
Loads a saved Scoring object from path.
Args:
path: directory path to load model
| Loads a saved Scoring object from path. | [
"Loads",
"a",
"saved",
"Scoring",
"object",
"from",
"path",
"."
] | def load(self, path):
with open("%s/scoring" % path, "rb") as handle:
self.__dict__.update(pickle.load(handle)) | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"\"%s/scoring\"",
"%",
"path",
",",
"\"rb\"",
")",
"as",
"handle",
":",
"self",
".",
"__dict__",
".",
"update",
"(",
"pickle",
".",
"load",
"(",
"handle",
")",
")"
] | Loads a saved Scoring object from path. | [
"Loads",
"a",
"saved",
"Scoring",
"object",
"from",
"path",
"."
] | [
"\"\"\"\n Loads a saved Scoring object from path.\n\n Args:\n path: directory path to load model\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": "directory path to load model",
... |
46d157f74b3f98c7c401e7877af65cb60c22bc76 | Liatwilight/txtai | src/python/txtai/scoring.py | [
"Apache-2.0"
] | Python | save | null | def save(self, path):
"""
Saves a Scoring object to path.
Args:
path: directory path to save model
"""
with open("%s/scoring" % path, "wb") as handle:
pickle.dump(self.__dict__, handle, protocol=pickle.HIGHEST_PROTOCOL) |
Saves a Scoring object to path.
Args:
path: directory path to save model
| Saves a Scoring object to path. | [
"Saves",
"a",
"Scoring",
"object",
"to",
"path",
"."
] | def save(self, path):
with open("%s/scoring" % path, "wb") as handle:
pickle.dump(self.__dict__, handle, protocol=pickle.HIGHEST_PROTOCOL) | [
"def",
"save",
"(",
"self",
",",
"path",
")",
":",
"with",
"open",
"(",
"\"%s/scoring\"",
"%",
"path",
",",
"\"wb\"",
")",
"as",
"handle",
":",
"pickle",
".",
"dump",
"(",
"self",
".",
"__dict__",
",",
"handle",
",",
"protocol",
"=",
"pickle",
".",
... | Saves a Scoring object to path. | [
"Saves",
"a",
"Scoring",
"object",
"to",
"path",
"."
] | [
"\"\"\"\n Saves a Scoring object to path.\n\n Args:\n path: directory path to save model\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": "directory path to save model",
... |
46d157f74b3f98c7c401e7877af65cb60c22bc76 | Liatwilight/txtai | src/python/txtai/scoring.py | [
"Apache-2.0"
] | Python | computeIDF | <not_specific> | def computeIDF(self, freq):
"""
Computes an idf score for word frequency.
Args:
freq: word frequency
Returns:
idf score
"""
return math.log(self.total / (1 + freq)) |
Computes an idf score for word frequency.
Args:
freq: word frequency
Returns:
idf score
| Computes an idf score for word frequency. | [
"Computes",
"an",
"idf",
"score",
"for",
"word",
"frequency",
"."
] | def computeIDF(self, freq):
return math.log(self.total / (1 + freq)) | [
"def",
"computeIDF",
"(",
"self",
",",
"freq",
")",
":",
"return",
"math",
".",
"log",
"(",
"self",
".",
"total",
"/",
"(",
"1",
"+",
"freq",
")",
")"
] | Computes an idf score for word frequency. | [
"Computes",
"an",
"idf",
"score",
"for",
"word",
"frequency",
"."
] | [
"\"\"\"\n Computes an idf score for word frequency.\n\n Args:\n freq: word frequency\n\n Returns:\n idf score\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "freq",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
46d157f74b3f98c7c401e7877af65cb60c22bc76 | Liatwilight/txtai | src/python/txtai/scoring.py | [
"Apache-2.0"
] | Python | score | <not_specific> | def score(self, freq, idf, length):
"""
Calculates a score for each token.
Args:
freq: token frequency
idf: token idf score
length: total number of tokens in source document
Returns:
token score
"""
return idf |
Calculates a score for each token.
Args:
freq: token frequency
idf: token idf score
length: total number of tokens in source document
Returns:
token score
| Calculates a score for each token. | [
"Calculates",
"a",
"score",
"for",
"each",
"token",
"."
] | def score(self, freq, idf, length):
return idf | [
"def",
"score",
"(",
"self",
",",
"freq",
",",
"idf",
",",
"length",
")",
":",
"return",
"idf"
] | Calculates a score for each token. | [
"Calculates",
"a",
"score",
"for",
"each",
"token",
"."
] | [
"\"\"\"\n Calculates a score for each token.\n\n Args:\n freq: token frequency\n idf: token idf score\n length: total number of tokens in source document\n\n Returns:\n token score\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "freq",
"type": null
},
{
"param": "idf",
"type": null
},
{
"param": "length",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
8d763637ae4f3ff379d1b82e7c8d81ad5a275193 | Liatwilight/txtai | test/python/testann.py | [
"Apache-2.0"
] | Python | normalize | null | def normalize(self, embeddings):
"""
Normalizes embeddings using L2 normalization. Operation applied directly on array.
Args:
embeddings: input embeddings matrix
"""
# Calculation is different for matrices vs vectors
if len(embeddings.shape) > 1:
... |
Normalizes embeddings using L2 normalization. Operation applied directly on array.
Args:
embeddings: input embeddings matrix
| Normalizes embeddings using L2 normalization. Operation applied directly on array. | [
"Normalizes",
"embeddings",
"using",
"L2",
"normalization",
".",
"Operation",
"applied",
"directly",
"on",
"array",
"."
] | def normalize(self, embeddings):
if len(embeddings.shape) > 1:
embeddings /= np.linalg.norm(embeddings, axis=1)[:, np.newaxis]
else:
embeddings /= np.linalg.norm(embeddings) | [
"def",
"normalize",
"(",
"self",
",",
"embeddings",
")",
":",
"if",
"len",
"(",
"embeddings",
".",
"shape",
")",
">",
"1",
":",
"embeddings",
"/=",
"np",
".",
"linalg",
".",
"norm",
"(",
"embeddings",
",",
"axis",
"=",
"1",
")",
"[",
":",
",",
"n... | Normalizes embeddings using L2 normalization. | [
"Normalizes",
"embeddings",
"using",
"L2",
"normalization",
"."
] | [
"\"\"\"\n Normalizes embeddings using L2 normalization. Operation applied directly on array.\n\n Args:\n embeddings: input embeddings matrix\n \"\"\"",
"# Calculation is different for matrices vs vectors"
] | [
{
"param": "self",
"type": null
},
{
"param": "embeddings",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "embeddings",
"type": null,
"docstring": "input embeddings matrix",
... |
6ccc780dc8c82c2f7895c92bbd39583f7749c066 | Liatwilight/txtai | test/python/testscoring.py | [
"Apache-2.0"
] | Python | testSave | null | def testSave(self):
"""
Test scoring index save/load
"""
# Generate temp file path
index = os.path.join(tempfile.gettempdir(), "bm25")
os.makedirs(index, exist_ok=True)
model = self.method("bm25")
model.save(index)
model.load(index) |
Test scoring index save/load
| Test scoring index save/load | [
"Test",
"scoring",
"index",
"save",
"/",
"load"
] | def testSave(self):
index = os.path.join(tempfile.gettempdir(), "bm25")
os.makedirs(index, exist_ok=True)
model = self.method("bm25")
model.save(index)
model.load(index) | [
"def",
"testSave",
"(",
"self",
")",
":",
"index",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tempfile",
".",
"gettempdir",
"(",
")",
",",
"\"bm25\"",
")",
"os",
".",
"makedirs",
"(",
"index",
",",
"exist_ok",
"=",
"True",
")",
"model",
"=",
"self"... | Test scoring index save/load | [
"Test",
"scoring",
"index",
"save",
"/",
"load"
] | [
"\"\"\"\n Test scoring index save/load\n \"\"\"",
"# Generate temp file path"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
431ea0fee2ef3f730b9e197f561378888de93149 | Liatwilight/txtai | src/python/txtai/api.py | [
"Apache-2.0"
] | Python | search | <not_specific> | def search(self, query, request):
"""
Runs an embeddings search for query and request. Downstream applications can override this method
to provide enriched search results.
Args:
query: input query
request: FastAPI request
Returns:
list of (ui... |
Runs an embeddings search for query and request. Downstream applications can override this method
to provide enriched search results.
Args:
query: input query
request: FastAPI request
Returns:
list of (uid, score)
| Runs an embeddings search for query and request. Downstream applications can override this method
to provide enriched search results. | [
"Runs",
"an",
"embeddings",
"search",
"for",
"query",
"and",
"request",
".",
"Downstream",
"applications",
"can",
"override",
"this",
"method",
"to",
"provide",
"enriched",
"search",
"results",
"."
] | def search(self, query, request):
return self.embeddings.search(query, self.size(request)) | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"request",
")",
":",
"return",
"self",
".",
"embeddings",
".",
"search",
"(",
"query",
",",
"self",
".",
"size",
"(",
"request",
")",
")"
] | Runs an embeddings search for query and request. | [
"Runs",
"an",
"embeddings",
"search",
"for",
"query",
"and",
"request",
"."
] | [
"\"\"\"\n Runs an embeddings search for query and request. Downstream applications can override this method\n to provide enriched search results.\n\n Args:\n query: input query\n request: FastAPI request\n\n Returns:\n list of (uid, score)\n \"\"\"... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [
{
"docstring": "list of (uid, score)",
"docstring_tokens": [
"list",
"of",
"(",
"uid",
"score",
")"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring... |
431ea0fee2ef3f730b9e197f561378888de93149 | Liatwilight/txtai | src/python/txtai/api.py | [
"Apache-2.0"
] | Python | similarity | <not_specific> | def similarity(self, text1, text2):
"""
Calculates the similarity between text1 and list of elements in text2.
Args:
text1: text
text2: list of text to compare against
Returns:
list of similarity scores
"""
return [float(x) for x in ... |
Calculates the similarity between text1 and list of elements in text2.
Args:
text1: text
text2: list of text to compare against
Returns:
list of similarity scores
| Calculates the similarity between text1 and list of elements in text2. | [
"Calculates",
"the",
"similarity",
"between",
"text1",
"and",
"list",
"of",
"elements",
"in",
"text2",
"."
] | def similarity(self, text1, text2):
return [float(x) for x in self.embeddings.similarity(text1, text2)] | [
"def",
"similarity",
"(",
"self",
",",
"text1",
",",
"text2",
")",
":",
"return",
"[",
"float",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"embeddings",
".",
"similarity",
"(",
"text1",
",",
"text2",
")",
"]"
] | Calculates the similarity between text1 and list of elements in text2. | [
"Calculates",
"the",
"similarity",
"between",
"text1",
"and",
"list",
"of",
"elements",
"in",
"text2",
"."
] | [
"\"\"\"\n Calculates the similarity between text1 and list of elements in text2.\n\n Args:\n text1: text\n text2: list of text to compare against\n\n Returns:\n list of similarity scores\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "text1",
"type": null
},
{
"param": "text2",
"type": null
}
] | {
"returns": [
{
"docstring": "list of similarity scores",
"docstring_tokens": [
"list",
"of",
"similarity",
"scores"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
... |
431ea0fee2ef3f730b9e197f561378888de93149 | Liatwilight/txtai | src/python/txtai/api.py | [
"Apache-2.0"
] | Python | transform | <not_specific> | def transform(self, text):
"""
Transforms text into an embeddings array.
Args:
text: input text
Returns:
embeddings array
"""
return [float(x) for x in self.embeddings.transform((None, text, None))] |
Transforms text into an embeddings array.
Args:
text: input text
Returns:
embeddings array
| Transforms text into an embeddings array. | [
"Transforms",
"text",
"into",
"an",
"embeddings",
"array",
"."
] | def transform(self, text):
return [float(x) for x in self.embeddings.transform((None, text, None))] | [
"def",
"transform",
"(",
"self",
",",
"text",
")",
":",
"return",
"[",
"float",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"embeddings",
".",
"transform",
"(",
"(",
"None",
",",
"text",
",",
"None",
")",
")",
"]"
] | Transforms text into an embeddings array. | [
"Transforms",
"text",
"into",
"an",
"embeddings",
"array",
"."
] | [
"\"\"\"\n Transforms text into an embeddings array.\n\n Args:\n text: input text\n\n Returns:\n embeddings array\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "text",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
431ea0fee2ef3f730b9e197f561378888de93149 | Liatwilight/txtai | src/python/txtai/api.py | [
"Apache-2.0"
] | Python | similarity | <not_specific> | def similarity(t1: str, t2: List[str]=Query(None)):
"""
Calculates the similarity between text1 and list of elements in text2.
Args:
t1: text
t2: list of text to compare against
Returns:
list of similarity scores
"""
return INDEX.similarity(t1, t2) |
Calculates the similarity between text1 and list of elements in text2.
Args:
t1: text
t2: list of text to compare against
Returns:
list of similarity scores
| Calculates the similarity between text1 and list of elements in text2. | [
"Calculates",
"the",
"similarity",
"between",
"text1",
"and",
"list",
"of",
"elements",
"in",
"text2",
"."
] | def similarity(t1: str, t2: List[str]=Query(None)):
return INDEX.similarity(t1, t2) | [
"def",
"similarity",
"(",
"t1",
":",
"str",
",",
"t2",
":",
"List",
"[",
"str",
"]",
"=",
"Query",
"(",
"None",
")",
")",
":",
"return",
"INDEX",
".",
"similarity",
"(",
"t1",
",",
"t2",
")"
] | Calculates the similarity between text1 and list of elements in text2. | [
"Calculates",
"the",
"similarity",
"between",
"text1",
"and",
"list",
"of",
"elements",
"in",
"text2",
"."
] | [
"\"\"\"\n Calculates the similarity between text1 and list of elements in text2.\n\n Args:\n t1: text\n t2: list of text to compare against\n\n Returns:\n list of similarity scores\n \"\"\""
] | [
{
"param": "t1",
"type": "str"
},
{
"param": "t2",
"type": "List[str]"
}
] | {
"returns": [
{
"docstring": "list of similarity scores",
"docstring_tokens": [
"list",
"of",
"similarity",
"scores"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "t1",
"type": "str",
"docstring": null,
... |
431ea0fee2ef3f730b9e197f561378888de93149 | Liatwilight/txtai | src/python/txtai/api.py | [
"Apache-2.0"
] | Python | embeddings | <not_specific> | def embeddings(t: str):
"""
Transforms text into an embeddings array.
Args:
t: input text
Returns:
embeddings array
"""
return INDEX.transform(t) |
Transforms text into an embeddings array.
Args:
t: input text
Returns:
embeddings array
| Transforms text into an embeddings array. | [
"Transforms",
"text",
"into",
"an",
"embeddings",
"array",
"."
] | def embeddings(t: str):
return INDEX.transform(t) | [
"def",
"embeddings",
"(",
"t",
":",
"str",
")",
":",
"return",
"INDEX",
".",
"transform",
"(",
"t",
")"
] | Transforms text into an embeddings array. | [
"Transforms",
"text",
"into",
"an",
"embeddings",
"array",
"."
] | [
"\"\"\"\n Transforms text into an embeddings array.\n\n Args:\n t: input text\n\n Returns:\n embeddings array\n \"\"\""
] | [
{
"param": "t",
"type": "str"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "t",
"type": "str",
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"i... |
49c1a1e3351a7d195abce5bc9b5ac0e34c380b46 | Liatwilight/txtai | src/python/txtai/ann.py | [
"Apache-2.0"
] | Python | search | null | def search(self, query, limit):
"""
Searches ANN model for query. Returns topn results.
Args:
query: query vector
limit: maximum results
""" |
Searches ANN model for query. Returns topn results.
Args:
query: query vector
limit: maximum results
| Searches ANN model for query. Returns topn results. | [
"Searches",
"ANN",
"model",
"for",
"query",
".",
"Returns",
"topn",
"results",
"."
] | def search(self, query, limit): | [
"def",
"search",
"(",
"self",
",",
"query",
",",
"limit",
")",
":"
] | Searches ANN model for query. | [
"Searches",
"ANN",
"model",
"for",
"query",
"."
] | [
"\"\"\"\n Searches ANN model for query. Returns topn results.\n\n Args:\n query: query vector\n limit: maximum results\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "limit",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": ... |
e04bf2df826180b9b92ae8f00c42487ab1b93f2e | Liatwilight/txtai | test/python/testembeddings.py | [
"Apache-2.0"
] | Python | testWords | null | def testWords(self):
"""
Test embeddings backed by word vectors
"""
# Initialize model path
path = os.path.join(tempfile.gettempdir(), "model")
os.makedirs(path, exist_ok=True)
# Build tokens file
with tempfile.NamedTemporaryFile(mode="w", delete=False) ... |
Test embeddings backed by word vectors
| Test embeddings backed by word vectors | [
"Test",
"embeddings",
"backed",
"by",
"word",
"vectors"
] | def testWords(self):
path = os.path.join(tempfile.gettempdir(), "model")
os.makedirs(path, exist_ok=True)
with tempfile.NamedTemporaryFile(mode="w", delete=False) as output:
tokens = output.name
for x in self.data:
output.write(x + "\n")
vectors = ... | [
"def",
"testWords",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tempfile",
".",
"gettempdir",
"(",
")",
",",
"\"model\"",
")",
"os",
".",
"makedirs",
"(",
"path",
",",
"exist_ok",
"=",
"True",
")",
"with",
"tempfile",
... | Test embeddings backed by word vectors | [
"Test",
"embeddings",
"backed",
"by",
"word",
"vectors"
] | [
"\"\"\"\n Test embeddings backed by word vectors\n \"\"\"",
"# Initialize model path",
"# Build tokens file",
"# Word vectors path",
"# Build word vectors, if they don't already exist",
"# Create dataset",
"# Create embeddings model, backed by word vectors",
"# Call scoring and index met... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2d75c8da381c4439e124833ac18a0f213c6c8d0a | Liatwilight/txtai | src/python/txtai/pipeline.py | [
"Apache-2.0"
] | Python | score | <not_specific> | def score(self, start, end, maxlength):
"""
Scores all possible combinations of start and end index up to maxlength. Returns
the best match.
Args:
start: start index scores
end: end index scores
maxlength: max number of tokens to allow in a match
... |
Scores all possible combinations of start and end index up to maxlength. Returns
the best match.
Args:
start: start index scores
end: end index scores
maxlength: max number of tokens to allow in a match
Returns:
(start index, end index, ... | Scores all possible combinations of start and end index up to maxlength. Returns
the best match. | [
"Scores",
"all",
"possible",
"combinations",
"of",
"start",
"and",
"end",
"index",
"up",
"to",
"maxlength",
".",
"Returns",
"the",
"best",
"match",
"."
] | def score(self, start, end, maxlength):
scores = np.matmul(np.expand_dims(start, -1), np.expand_dims(end, 1))
candidates = np.tril(np.triu(scores), maxlength - 1)
index = np.argmax(candidates.flatten())
start, end = np.unravel_index(index, candidates.shape)[1:]
return start, end,... | [
"def",
"score",
"(",
"self",
",",
"start",
",",
"end",
",",
"maxlength",
")",
":",
"scores",
"=",
"np",
".",
"matmul",
"(",
"np",
".",
"expand_dims",
"(",
"start",
",",
"-",
"1",
")",
",",
"np",
".",
"expand_dims",
"(",
"end",
",",
"1",
")",
")... | Scores all possible combinations of start and end index up to maxlength. | [
"Scores",
"all",
"possible",
"combinations",
"of",
"start",
"and",
"end",
"index",
"up",
"to",
"maxlength",
"."
] | [
"\"\"\"\n Scores all possible combinations of start and end index up to maxlength. Returns\n the best match.\n\n Args:\n start: start index scores\n end: end index scores\n maxlength: max number of tokens to allow in a match\n\n Returns:\n (sta... | [
{
"param": "self",
"type": null
},
{
"param": "start",
"type": null
},
{
"param": "end",
"type": null
},
{
"param": "maxlength",
"type": null
}
] | {
"returns": [
{
"docstring": "(start index, end index, score) of best scoring combination",
"docstring_tokens": [
"(",
"start",
"index",
"end",
"index",
"score",
")",
"of",
"best",
"scoring",
"combination"
]... |
2d75c8da381c4439e124833ac18a0f213c6c8d0a | Liatwilight/txtai | src/python/txtai/pipeline.py | [
"Apache-2.0"
] | Python | regex | <not_specific> | def regex(self, tokens):
"""
Builds a regular expression from tokens.
Args:
tokens: input tokens
Returns:
regex to use to extract match in original text
"""
regex = []
for token in tokens:
# Escape regex characters
... |
Builds a regular expression from tokens.
Args:
tokens: input tokens
Returns:
regex to use to extract match in original text
| Builds a regular expression from tokens. | [
"Builds",
"a",
"regular",
"expression",
"from",
"tokens",
"."
] | def regex(self, tokens):
regex = []
for token in tokens:
token = re.escape(token)
if token.startswith("\\#\\#"):
token = re.sub(r"^\\#\\#", "", token)
regex.append(token)
return "\\s?".join(regex) | [
"def",
"regex",
"(",
"self",
",",
"tokens",
")",
":",
"regex",
"=",
"[",
"]",
"for",
"token",
"in",
"tokens",
":",
"token",
"=",
"re",
".",
"escape",
"(",
"token",
")",
"if",
"token",
".",
"startswith",
"(",
"\"\\\\#\\\\#\"",
")",
":",
"token",
"="... | Builds a regular expression from tokens. | [
"Builds",
"a",
"regular",
"expression",
"from",
"tokens",
"."
] | [
"\"\"\"\n Builds a regular expression from tokens.\n\n Args:\n tokens: input tokens\n\n Returns:\n regex to use to extract match in original text\n \"\"\"",
"# Escape regex characters",
"# Handle subwords",
"# Build and return complete regular expression"
] | [
{
"param": "self",
"type": null
},
{
"param": "tokens",
"type": null
}
] | {
"returns": [
{
"docstring": "regex to use to extract match in original text",
"docstring_tokens": [
"regex",
"to",
"use",
"to",
"extract",
"match",
"in",
"original",
"text"
],
"type": null
}
],
"raises": [],
... |
4ed2ca191e6185e9b437696f51b47645021ce576 | labstructbioinf/localpdb | localpdb/utils/network.py | [
"MIT"
] | Python | download_url | <not_specific> | def download_url(url, dest, ftp=False):
"""
Method for handling downloads and replicating modification timestamps
@param url: url to download
@param dest: destination of the downloaded file
@param ftp: True if ftp protocol is used for downloads.
@return True/False denoting whether download was s... |
Method for handling downloads and replicating modification timestamps
@param url: url to download
@param dest: destination of the downloaded file
@param ftp: True if ftp protocol is used for downloads.
@return True/False denoting whether download was successful or not
| Method for handling downloads and replicating modification timestamps
@param url: url to download
@param dest: destination of the downloaded file
@param ftp: True if ftp protocol is used for downloads.
@return True/False denoting whether download was successful or not | [
"Method",
"for",
"handling",
"downloads",
"and",
"replicating",
"modification",
"timestamps",
"@param",
"url",
":",
"url",
"to",
"download",
"@param",
"dest",
":",
"destination",
"of",
"the",
"downloaded",
"file",
"@param",
"ftp",
":",
"True",
"if",
"ftp",
"pr... | def download_url(url, dest, ftp=False):
try:
urllib.request.urlretrieve(url, dest)
logger.debug(f'Downloaded url: \'{url}\' to destination: \'{dest}\'')
last_modified = get_last_modified(url, ftp=ftp)
set_last_modified(dest, last_modified)
return True
except (urllib.error... | [
"def",
"download_url",
"(",
"url",
",",
"dest",
",",
"ftp",
"=",
"False",
")",
":",
"try",
":",
"urllib",
".",
"request",
".",
"urlretrieve",
"(",
"url",
",",
"dest",
")",
"logger",
".",
"debug",
"(",
"f'Downloaded url: \\'{url}\\' to destination: \\'{dest}\\'... | Method for handling downloads and replicating modification timestamps
@param url: url to download
@param dest: destination of the downloaded file
@param ftp: True if ftp protocol is used for downloads. | [
"Method",
"for",
"handling",
"downloads",
"and",
"replicating",
"modification",
"timestamps",
"@param",
"url",
":",
"url",
"to",
"download",
"@param",
"dest",
":",
"destination",
"of",
"the",
"downloaded",
"file",
"@param",
"ftp",
":",
"True",
"if",
"ftp",
"pr... | [
"\"\"\"\n Method for handling downloads and replicating modification timestamps\n @param url: url to download\n @param dest: destination of the downloaded file\n @param ftp: True if ftp protocol is used for downloads.\n @return True/False denoting whether download was successful or not\n \"\"\"",
... | [
{
"param": "url",
"type": null
},
{
"param": "dest",
"type": null
},
{
"param": "ftp",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "url",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": null,
"docstring": null,
"docstring_tokens": []... |
16a7304bed8bfb58189babbb3430e68b71f65fcf | labstructbioinf/localpdb | localpdb/plugins/PDBClustering.py | [
"MIT"
] | Python | parse_cluster_data | <not_specific> | def parse_cluster_data(fn):
"""
Parse PDB protein sequences clustering data available from the RCSB website
@param fn: filename with clustering data
@return: dictionary with pdb_chain as keys and cluster number (integer)
"""
f = open(fn, 'r')
data = [line.rstrip() for line in f.readlines()]
... |
Parse PDB protein sequences clustering data available from the RCSB website
@param fn: filename with clustering data
@return: dictionary with pdb_chain as keys and cluster number (integer)
| Parse PDB protein sequences clustering data available from the RCSB website | [
"Parse",
"PDB",
"protein",
"sequences",
"clustering",
"data",
"available",
"from",
"the",
"RCSB",
"website"
] | def parse_cluster_data(fn):
f = open(fn, 'r')
data = [line.rstrip() for line in f.readlines()]
f.close()
cluster_data = {}
for c in range(1, len(data)+1):
for entry in data[c-1].split(' '):
pdb, chain = entry.split('_')
cluster_data['{}_{}'.format(pdb.lower(), chain)]... | [
"def",
"parse_cluster_data",
"(",
"fn",
")",
":",
"f",
"=",
"open",
"(",
"fn",
",",
"'r'",
")",
"data",
"=",
"[",
"line",
".",
"rstrip",
"(",
")",
"for",
"line",
"in",
"f",
".",
"readlines",
"(",
")",
"]",
"f",
".",
"close",
"(",
")",
"cluster_... | Parse PDB protein sequences clustering data available from the RCSB website | [
"Parse",
"PDB",
"protein",
"sequences",
"clustering",
"data",
"available",
"from",
"the",
"RCSB",
"website"
] | [
"\"\"\"\n Parse PDB protein sequences clustering data available from the RCSB website\n @param fn: filename with clustering data\n @return: dictionary with pdb_chain as keys and cluster number (integer)\n \"\"\""
] | [
{
"param": "fn",
"type": null
}
] | {
"returns": [
{
"docstring": "dictionary with pdb_chain as keys and cluster number (integer)",
"docstring_tokens": [
"dictionary",
"with",
"pdb_chain",
"as",
"keys",
"and",
"cluster",
"number",
"(",
"integer",
")"... |
760bba895d6d10e5bb0a85adc846a3671767ffab | labstructbioinf/localpdb | localpdb/utils/config.py | [
"MIT"
] | Python | load_remote_source | <not_specific> | def load_remote_source(mirror=''):
"""
Loads config file with definition of the remote data sources and formats it according to the chosen mirror.
@return: loaded config dictionary
"""
my_path = os.path.dirname(os.path.realpath(__file__))
with open('{}/remote_sources.yml'.format(my_path)) as f:
... |
Loads config file with definition of the remote data sources and formats it according to the chosen mirror.
@return: loaded config dictionary
| Loads config file with definition of the remote data sources and formats it according to the chosen mirror. | [
"Loads",
"config",
"file",
"with",
"definition",
"of",
"the",
"remote",
"data",
"sources",
"and",
"formats",
"it",
"according",
"to",
"the",
"chosen",
"mirror",
"."
] | def load_remote_source(mirror=''):
my_path = os.path.dirname(os.path.realpath(__file__))
with open('{}/remote_sources.yml'.format(my_path)) as f:
config = yaml.safe_load(f)
if mirror:
mirrors = config.pop('mirrors')
config.update(mirrors[mirror])
return config | [
"def",
"load_remote_source",
"(",
"mirror",
"=",
"''",
")",
":",
"my_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"with",
"open",
"(",
"'{}/remote_sources.yml'",
".",
"format",
"(",
... | Loads config file with definition of the remote data sources and formats it according to the chosen mirror. | [
"Loads",
"config",
"file",
"with",
"definition",
"of",
"the",
"remote",
"data",
"sources",
"and",
"formats",
"it",
"according",
"to",
"the",
"chosen",
"mirror",
"."
] | [
"\"\"\"\n Loads config file with definition of the remote data sources and formats it according to the chosen mirror.\n @return: loaded config dictionary\n \"\"\""
] | [
{
"param": "mirror",
"type": null
}
] | {
"returns": [
{
"docstring": "loaded config dictionary",
"docstring_tokens": [
"loaded",
"config",
"dictionary"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "mirror",
"type": null,
"docstring": null,
"docstrin... |
6dc30781907bcbbdc765f88d977184bcde45f3ce | labstructbioinf/localpdb | localpdb/plugins/Socket.py | [
"MIT"
] | Python | run_socket | <not_specific> | def run_socket(inps):
"""
Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. Output is written only if
coiled coil domain was found in the entry. Inputs are wrapped to allow for multiprocessing.
Order of the inputs is: pdb_id: PDB identifier, fn_biounit: filename of t... |
Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. Output is written only if
coiled coil domain was found in the entry. Inputs are wrapped to allow for multiprocessing.
Order of the inputs is: pdb_id: PDB identifier, fn_biounit: filename of the biounit, cutoffs: socket c... | Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. Output is written only if
coiled coil domain was found in the entry. Inputs are wrapped to allow for multiprocessing. | [
"Runs",
"socket",
"(",
"preceeded",
"by",
"the",
"DSSP",
"run",
")",
"and",
"writes",
"the",
"output",
"in",
"the",
"plugin",
"directory",
".",
"Output",
"is",
"written",
"only",
"if",
"coiled",
"coil",
"domain",
"was",
"found",
"in",
"the",
"entry",
"."... | def run_socket(inps):
pdb_id, fn_biounit, cutoffs, fn_out, socket_loc, dssp2_loc = inps
fh_tmp = get_unzipped_tempfile(fn_biounit)
dssp_tmp = '/tmp/{}'.format(next(tempfile._get_candidate_names()))
cmd = f'{dssp2_loc} -i {fn_biounit} -o {dssp_tmp}'
result, _ = os_cmd(cmd)
codes = [result]
i... | [
"def",
"run_socket",
"(",
"inps",
")",
":",
"pdb_id",
",",
"fn_biounit",
",",
"cutoffs",
",",
"fn_out",
",",
"socket_loc",
",",
"dssp2_loc",
"=",
"inps",
"fh_tmp",
"=",
"get_unzipped_tempfile",
"(",
"fn_biounit",
")",
"dssp_tmp",
"=",
"'/tmp/{}'",
".",
"form... | Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. | [
"Runs",
"socket",
"(",
"preceeded",
"by",
"the",
"DSSP",
"run",
")",
"and",
"writes",
"the",
"output",
"in",
"the",
"plugin",
"directory",
"."
] | [
"\"\"\"\n Runs socket (preceeded by the DSSP run) and writes the output in the plugin directory. Output is written only if\n coiled coil domain was found in the entry. Inputs are wrapped to allow for multiprocessing.\n Order of the inputs is: pdb_id: PDB identifier, fn_biounit: filename of the biounit, cut... | [
{
"param": "inps",
"type": null
}
] | {
"returns": [
{
"docstring": "dict with the job statuses (NaN or pointer to output file) with socket cutoffs as keys",
"docstring_tokens": [
"dict",
"with",
"the",
"job",
"statuses",
"(",
"NaN",
"or",
"pointer",
"to",
... |
12e7d0bd089f7b499e86900d586f8146da9b4c08 | labstructbioinf/localpdb | localpdb/PDBVersioneer.py | [
"MIT"
] | Python | init | null | def init(self):
"""
Create a ".localpdb" file to mark the directory as localpdb db
"""
Path(self.db_path / '.localpdb').touch() |
Create a ".localpdb" file to mark the directory as localpdb db
| Create a ".localpdb" file to mark the directory as localpdb db | [
"Create",
"a",
"\"",
".",
"localpdb",
"\"",
"file",
"to",
"mark",
"the",
"directory",
"as",
"localpdb",
"db"
] | def init(self):
Path(self.db_path / '.localpdb').touch() | [
"def",
"init",
"(",
"self",
")",
":",
"Path",
"(",
"self",
".",
"db_path",
"/",
"'.localpdb'",
")",
".",
"touch",
"(",
")"
] | Create a ".localpdb" file to mark the directory as localpdb db | [
"Create",
"a",
"\"",
".",
"localpdb",
"\"",
"file",
"to",
"mark",
"the",
"directory",
"as",
"localpdb",
"db"
] | [
"\"\"\"\n Create a \".localpdb\" file to mark the directory as localpdb db\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
12e7d0bd089f7b499e86900d586f8146da9b4c08 | labstructbioinf/localpdb | localpdb/PDBVersioneer.py | [
"MIT"
] | Python | check_init | <not_specific> | def check_init(self):
"""
Checks whether the localpdb init file ".localpdb" is present.
@return: True or False for the init file presence
"""
return Path(self.db_path / '.localpdb').is_file() |
Checks whether the localpdb init file ".localpdb" is present.
@return: True or False for the init file presence
| Checks whether the localpdb init file ".localpdb" is present. | [
"Checks",
"whether",
"the",
"localpdb",
"init",
"file",
"\"",
".",
"localpdb",
"\"",
"is",
"present",
"."
] | def check_init(self):
return Path(self.db_path / '.localpdb').is_file() | [
"def",
"check_init",
"(",
"self",
")",
":",
"return",
"Path",
"(",
"self",
".",
"db_path",
"/",
"'.localpdb'",
")",
".",
"is_file",
"(",
")"
] | Checks whether the localpdb init file ".localpdb" is present. | [
"Checks",
"whether",
"the",
"localpdb",
"init",
"file",
"\"",
".",
"localpdb",
"\"",
"is",
"present",
"."
] | [
"\"\"\"\n Checks whether the localpdb init file \".localpdb\" is present.\n @return: True or False for the init file presence\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "True or False for the init file presence",
"docstring_tokens": [
"True",
"or",
"False",
"for",
"the",
"init",
"file",
"presence"
],
"type": null
}
],
"raises": [],
"params": [
{
... |
12e7d0bd089f7b499e86900d586f8146da9b4c08 | labstructbioinf/localpdb | localpdb/PDBVersioneer.py | [
"MIT"
] | Python | current_local_version | <not_specific> | def current_local_version(self):
"""
Checks current (newest) available localpdb version
@return: (int) - current (newest) localpdb version
"""
try:
return self.local_pdb_versions[-1]
except IndexError:
return None |
Checks current (newest) available localpdb version
@return: (int) - current (newest) localpdb version
| Checks current (newest) available localpdb version | [
"Checks",
"current",
"(",
"newest",
")",
"available",
"localpdb",
"version"
] | def current_local_version(self):
try:
return self.local_pdb_versions[-1]
except IndexError:
return None | [
"def",
"current_local_version",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"local_pdb_versions",
"[",
"-",
"1",
"]",
"except",
"IndexError",
":",
"return",
"None"
] | Checks current (newest) available localpdb version | [
"Checks",
"current",
"(",
"newest",
")",
"available",
"localpdb",
"version"
] | [
"\"\"\"\n Checks current (newest) available localpdb version\n @return: (int) - current (newest) localpdb version\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "current (newest) localpdb version",
"docstring_tokens": [
"current",
"(",
"newest",
")",
"localpdb",
"version"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"ty... |
12e7d0bd089f7b499e86900d586f8146da9b4c08 | labstructbioinf/localpdb | localpdb/PDBVersioneer.py | [
"MIT"
] | Python | first_local_version | <not_specific> | def first_local_version(self):
"""
Checks for the first (oldest) available localpdb version
@return: (int) - first (oldest) localpdb version
"""
try:
return self.local_pdb_versions[0]
except IndexError:
return None |
Checks for the first (oldest) available localpdb version
@return: (int) - first (oldest) localpdb version
| Checks for the first (oldest) available localpdb version | [
"Checks",
"for",
"the",
"first",
"(",
"oldest",
")",
"available",
"localpdb",
"version"
] | def first_local_version(self):
try:
return self.local_pdb_versions[0]
except IndexError:
return None | [
"def",
"first_local_version",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"local_pdb_versions",
"[",
"0",
"]",
"except",
"IndexError",
":",
"return",
"None"
] | Checks for the first (oldest) available localpdb version | [
"Checks",
"for",
"the",
"first",
"(",
"oldest",
")",
"available",
"localpdb",
"version"
] | [
"\"\"\"\n Checks for the first (oldest) available localpdb version\n @return: (int) - first (oldest) localpdb version\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "first (oldest) localpdb version",
"docstring_tokens": [
"first",
"(",
"oldest",
")",
"localpdb",
"version"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type":... |
12e7d0bd089f7b499e86900d586f8146da9b4c08 | labstructbioinf/localpdb | localpdb/PDBVersioneer.py | [
"MIT"
] | Python | current_remote_version | <not_specific> | def current_remote_version(self):
"""
Checks for the current (newest) available remote PDB version
@return: (int) - current (newest) remote PDB version
"""
return self.remote_pdb_versions[-1] |
Checks for the current (newest) available remote PDB version
@return: (int) - current (newest) remote PDB version
| Checks for the current (newest) available remote PDB version | [
"Checks",
"for",
"the",
"current",
"(",
"newest",
")",
"available",
"remote",
"PDB",
"version"
] | def current_remote_version(self):
return self.remote_pdb_versions[-1] | [
"def",
"current_remote_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"remote_pdb_versions",
"[",
"-",
"1",
"]"
] | Checks for the current (newest) available remote PDB version | [
"Checks",
"for",
"the",
"current",
"(",
"newest",
")",
"available",
"remote",
"PDB",
"version"
] | [
"\"\"\"\n Checks for the current (newest) available remote PDB version\n @return: (int) - current (newest) remote PDB version\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "current (newest) remote PDB version",
"docstring_tokens": [
"current",
"(",
"newest",
")",
"remote",
"PDB",
"version"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "s... |
12e7d0bd089f7b499e86900d586f8146da9b4c08 | labstructbioinf/localpdb | localpdb/PDBVersioneer.py | [
"MIT"
] | Python | missing_remote_versions | <not_specific> | def missing_remote_versions(self):
"""
Checks for the missing localpdb version w.r.t the remote source
@return: list with missing localpdb versions
"""
return self.remote_pdb_versions[self.remote_pdb_versions.index(self.current_local_version)+1:
... |
Checks for the missing localpdb version w.r.t the remote source
@return: list with missing localpdb versions
| Checks for the missing localpdb version w.r.t the remote source | [
"Checks",
"for",
"the",
"missing",
"localpdb",
"version",
"w",
".",
"r",
".",
"t",
"the",
"remote",
"source"
] | def missing_remote_versions(self):
return self.remote_pdb_versions[self.remote_pdb_versions.index(self.current_local_version)+1:
self.remote_pdb_versions.index(self.current_remote_version)+1] | [
"def",
"missing_remote_versions",
"(",
"self",
")",
":",
"return",
"self",
".",
"remote_pdb_versions",
"[",
"self",
".",
"remote_pdb_versions",
".",
"index",
"(",
"self",
".",
"current_local_version",
")",
"+",
"1",
":",
"self",
".",
"remote_pdb_versions",
".",
... | Checks for the missing localpdb version w.r.t the remote source | [
"Checks",
"for",
"the",
"missing",
"localpdb",
"version",
"w",
".",
"r",
".",
"t",
"the",
"remote",
"source"
] | [
"\"\"\"\n Checks for the missing localpdb version w.r.t the remote source\n @return: list with missing localpdb versions\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "list with missing localpdb versions",
"docstring_tokens": [
"list",
"with",
"missing",
"localpdb",
"versions"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null... |
12e7d0bd089f7b499e86900d586f8146da9b4c08 | labstructbioinf/localpdb | localpdb/PDBVersioneer.py | [
"MIT"
] | Python | remote_pdb_versions | <not_specific> | def remote_pdb_versions(self):
"""
Checks for the remote PDB versions in the PDB ftp mirror
@return: sorted list of the remote PDB versions available in the PDB ftp mirror
"""
p = urlparse('ftp://' + self.config['url'])
ftp = ftplib.FTP(p.netloc, timeout=10)
ftp.l... |
Checks for the remote PDB versions in the PDB ftp mirror
@return: sorted list of the remote PDB versions available in the PDB ftp mirror
| Checks for the remote PDB versions in the PDB ftp mirror | [
"Checks",
"for",
"the",
"remote",
"PDB",
"versions",
"in",
"the",
"PDB",
"ftp",
"mirror"
] | def remote_pdb_versions(self):
p = urlparse('ftp://' + self.config['url'])
ftp = ftplib.FTP(p.netloc, timeout=10)
ftp.login("anonymous", "")
raw_data = []
ftp.dir(f'{p.path}/data/status/', raw_data.append)
remote_pdb_versions = sorted([int(entry.split(' ')[-1]) for entry ... | [
"def",
"remote_pdb_versions",
"(",
"self",
")",
":",
"p",
"=",
"urlparse",
"(",
"'ftp://'",
"+",
"self",
".",
"config",
"[",
"'url'",
"]",
")",
"ftp",
"=",
"ftplib",
".",
"FTP",
"(",
"p",
".",
"netloc",
",",
"timeout",
"=",
"10",
")",
"ftp",
".",
... | Checks for the remote PDB versions in the PDB ftp mirror | [
"Checks",
"for",
"the",
"remote",
"PDB",
"versions",
"in",
"the",
"PDB",
"ftp",
"mirror"
] | [
"\"\"\"\n Checks for the remote PDB versions in the PDB ftp mirror\n @return: sorted list of the remote PDB versions available in the PDB ftp mirror\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "sorted list of the remote PDB versions available in the PDB ftp mirror",
"docstring_tokens": [
"sorted",
"list",
"of",
"the",
"remote",
"PDB",
"versions",
"available",
"in",
"the",
"P... |
daeec87f0ce68d760dd7f2673040a1c7aea6bd00 | labstructbioinf/localpdb | localpdb/plugins/Plugin.py | [
"MIT"
] | Python | find_closest_historical_version | <not_specific> | def find_closest_historical_version(version, versions):
"""
Finds closest historical version in list of versions.
@param version: specified version.
@param versions: list of versions.
@return: closest historical version.
"""
diffs = {ver - version: ver for ver in ... |
Finds closest historical version in list of versions.
@param version: specified version.
@param versions: list of versions.
@return: closest historical version.
| Finds closest historical version in list of versions. | [
"Finds",
"closest",
"historical",
"version",
"in",
"list",
"of",
"versions",
"."
] | def find_closest_historical_version(version, versions):
diffs = {ver - version: ver for ver in versions if ver - version <= 0}
return diffs[max(diffs, key=lambda key: diffs[key])] if len(diffs) > 0 else None | [
"def",
"find_closest_historical_version",
"(",
"version",
",",
"versions",
")",
":",
"diffs",
"=",
"{",
"ver",
"-",
"version",
":",
"ver",
"for",
"ver",
"in",
"versions",
"if",
"ver",
"-",
"version",
"<=",
"0",
"}",
"return",
"diffs",
"[",
"max",
"(",
... | Finds closest historical version in list of versions. | [
"Finds",
"closest",
"historical",
"version",
"in",
"list",
"of",
"versions",
"."
] | [
"\"\"\"\n Finds closest historical version in list of versions.\n @param version: specified version.\n @param versions: list of versions.\n @return: closest historical version.\n \"\"\""
] | [
{
"param": "version",
"type": null
},
{
"param": "versions",
"type": null
}
] | {
"returns": [
{
"docstring": "closest historical version.",
"docstring_tokens": [
"closest",
"historical",
"version",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "version",
"type": null,
"docstring": nu... |
3d16c3f6ba1e490608dbf6f6cb5e73628c59f6a6 | labstructbioinf/localpdb | localpdb/plugins/PluginVersioneer.py | [
"MIT"
] | Python | update_logs | <not_specific> | def update_logs(self, version, additional_info = None):
"""
Updates the version log for the plugin with the OK status, time and optional additional data
:param version: localpdb version
:param additional_info: list of values with additional info, default = None
:return: 0 if ever... |
Updates the version log for the plugin with the OK status, time and optional additional data
:param version: localpdb version
:param additional_info: list of values with additional info, default = None
:return: 0 if everything went fine
| Updates the version log for the plugin with the OK status, time and optional additional data | [
"Updates",
"the",
"version",
"log",
"for",
"the",
"plugin",
"with",
"the",
"OK",
"status",
"time",
"and",
"optional",
"additional",
"data"
] | def update_logs(self, version, additional_info = None):
status = ['OK', datetime.datetime.now().strftime("%Y-%m-%d %H:%M")]
try:
json.dumps(additional_info)
status.append(additional_info)
except TypeError:
pass
self.logs[version] = status
try:... | [
"def",
"update_logs",
"(",
"self",
",",
"version",
",",
"additional_info",
"=",
"None",
")",
":",
"status",
"=",
"[",
"'OK'",
",",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"\"%Y-%m-%d %H:%M\"",
")",
"]",
"try",
":",
"jso... | Updates the version log for the plugin with the OK status, time and optional additional data | [
"Updates",
"the",
"version",
"log",
"for",
"the",
"plugin",
"with",
"the",
"OK",
"status",
"time",
"and",
"optional",
"additional",
"data"
] | [
"\"\"\"\n Updates the version log for the plugin with the OK status, time and optional additional data\n :param version: localpdb version\n :param additional_info: list of values with additional info, default = None\n :return: 0 if everything went fine\n \"\"\"",
"# Unable to du... | [
{
"param": "self",
"type": null
},
{
"param": "version",
"type": null
},
{
"param": "additional_info",
"type": null
}
] | {
"returns": [
{
"docstring": "0 if everything went fine",
"docstring_tokens": [
"0",
"if",
"everything",
"went",
"fine"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring":... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | _register_attr | null | def _register_attr(self, attr):
"""
Registers attribute donated by the Plugin to allow auto-filtering option
:param attr: attribute name to be reqistered
"""
if attr not in self.__registered_attrs:
self.__registered_attrs.append(attr)
else:
raise V... |
Registers attribute donated by the Plugin to allow auto-filtering option
:param attr: attribute name to be reqistered
| Registers attribute donated by the Plugin to allow auto-filtering option | [
"Registers",
"attribute",
"donated",
"by",
"the",
"Plugin",
"to",
"allow",
"auto",
"-",
"filtering",
"option"
] | def _register_attr(self, attr):
if attr not in self.__registered_attrs:
self.__registered_attrs.append(attr)
else:
raise ValueError(f'Attribute \'{attr}\' was already registered by other plugin!') | [
"def",
"_register_attr",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
"not",
"in",
"self",
".",
"__registered_attrs",
":",
"self",
".",
"__registered_attrs",
".",
"append",
"(",
"attr",
")",
"else",
":",
"raise",
"ValueError",
"(",
"f'Attribute \\'{attr... | Registers attribute donated by the Plugin to allow auto-filtering option | [
"Registers",
"attribute",
"donated",
"by",
"the",
"Plugin",
"to",
"allow",
"auto",
"-",
"filtering",
"option"
] | [
"\"\"\"\n Registers attribute donated by the Plugin to allow auto-filtering option\n :param attr: attribute name to be reqistered\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "attr",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attr",
"type": null,
"docstring": "attribute name to be reqistered"... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | _remove_attr | null | def _remove_attr(self, attr):
"""
Removes the attribute donated by the Plugin to allow auto-filtering option
:param attr: attribute name to be reqistered
"""
if attr in self.__registered_attrs:
self.__registered_attrs.remove(attr)
else:
raise Value... |
Removes the attribute donated by the Plugin to allow auto-filtering option
:param attr: attribute name to be reqistered
| Removes the attribute donated by the Plugin to allow auto-filtering option | [
"Removes",
"the",
"attribute",
"donated",
"by",
"the",
"Plugin",
"to",
"allow",
"auto",
"-",
"filtering",
"option"
] | def _remove_attr(self, attr):
if attr in self.__registered_attrs:
self.__registered_attrs.remove(attr)
else:
raise ValueError(f'Attribute \'{attr}\' is not registered!') | [
"def",
"_remove_attr",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
"in",
"self",
".",
"__registered_attrs",
":",
"self",
".",
"__registered_attrs",
".",
"remove",
"(",
"attr",
")",
"else",
":",
"raise",
"ValueError",
"(",
"f'Attribute \\'{attr}\\' is not... | Removes the attribute donated by the Plugin to allow auto-filtering option | [
"Removes",
"the",
"attribute",
"donated",
"by",
"the",
"Plugin",
"to",
"allow",
"auto",
"-",
"filtering",
"option"
] | [
"\"\"\"\n Removes the attribute donated by the Plugin to allow auto-filtering option\n :param attr: attribute name to be reqistered\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "attr",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attr",
"type": null,
"docstring": "attribute name to be reqistered"... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | select_updates | null | def select_updates(self, mode='am+'):
"""
Selects entries that were added or modified when compare to previous PDB release.
@param mode: Select entries that were added ("a"), modified ("m"). "+" loads new entries compared to the
previous localpdb version (important when localpdb is not u... |
Selects entries that were added or modified when compare to previous PDB release.
@param mode: Select entries that were added ("a"), modified ("m"). "+" loads new entries compared to the
previous localpdb version (important when localpdb is not updated weekly). If "+" is missing only new entrie... | Selects entries that were added or modified when compare to previous PDB release. | [
"Selects",
"entries",
"that",
"were",
"added",
"or",
"modified",
"when",
"compare",
"to",
"previous",
"PDB",
"release",
"."
] | def select_updates(self, mode='am+'):
map = {'a': 'added', 'm': 'modified_major'}
ids = set()
if not ('a' in mode or 'm' in mode):
raise ValueError('Either \'a\' or \'m\' must be included in \'mode\'!')
for m in ['a', 'm']:
if m in mode:
fn = f'{se... | [
"def",
"select_updates",
"(",
"self",
",",
"mode",
"=",
"'am+'",
")",
":",
"map",
"=",
"{",
"'a'",
":",
"'added'",
",",
"'m'",
":",
"'modified_major'",
"}",
"ids",
"=",
"set",
"(",
")",
"if",
"not",
"(",
"'a'",
"in",
"mode",
"or",
"'m'",
"in",
"m... | Selects entries that were added or modified when compare to previous PDB release. | [
"Selects",
"entries",
"that",
"were",
"added",
"or",
"modified",
"when",
"compare",
"to",
"previous",
"PDB",
"release",
"."
] | [
"\"\"\"\n Selects entries that were added or modified when compare to previous PDB release.\n @param mode: Select entries that were added (\"a\"), modified (\"m\"). \"+\" loads new entries compared to the\n previous localpdb version (important when localpdb is not updated weekly). If \"+\" is m... | [
{
"param": "self",
"type": null
},
{
"param": "mode",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "mode",
"type": null,
"docstring": "Select entries that were added (... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | reset | null | def reset(self):
"""
Resets the selections done on lpdb.structures and lpdb.chains and restores the initial state of the localpdb.
"""
del self.__entries
del self.__chains
self.__entries = self.__entries_copy.copy()
self.__chains = self.__chains_copy.copy()
... |
Resets the selections done on lpdb.structures and lpdb.chains and restores the initial state of the localpdb.
| Resets the selections done on lpdb.structures and lpdb.chains and restores the initial state of the localpdb. | [
"Resets",
"the",
"selections",
"done",
"on",
"lpdb",
".",
"structures",
"and",
"lpdb",
".",
"chains",
"and",
"restores",
"the",
"initial",
"state",
"of",
"the",
"localpdb",
"."
] | def reset(self):
del self.__entries
del self.__chains
self.__entries = self.__entries_copy.copy()
self.__chains = self.__chains_copy.copy()
for ph in self._loaded_plugins_handles:
ph._reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"del",
"self",
".",
"__entries",
"del",
"self",
".",
"__chains",
"self",
".",
"__entries",
"=",
"self",
".",
"__entries_copy",
".",
"copy",
"(",
")",
"self",
".",
"__chains",
"=",
"self",
".",
"__chains_copy",
"."... | Resets the selections done on lpdb.structures and lpdb.chains and restores the initial state of the localpdb. | [
"Resets",
"the",
"selections",
"done",
"on",
"lpdb",
".",
"structures",
"and",
"lpdb",
".",
"chains",
"and",
"restores",
"the",
"initial",
"state",
"of",
"the",
"localpdb",
"."
] | [
"\"\"\"\n Resets the selections done on lpdb.structures and lpdb.chains and restores the initial state of the localpdb.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | search_seq_motif | <not_specific> | def search_seq_motif(self, query, type_='prosite', return_type="entry", no_hits=1000, select=False):
"""
Get dataframe with pdb ids having sequence matching given sequence motif
:param query: (str) motif to find in pdb sequences, according to given type_ (i.e prosite)
:param type_: (str)... |
Get dataframe with pdb ids having sequence matching given sequence motif
:param query: (str) motif to find in pdb sequences, according to given type_ (i.e prosite)
:param type_: (str) name of type of query
:param return_type: (str) type of returned data
:param no_hits: (int) num... | Get dataframe with pdb ids having sequence matching given sequence motif | [
"Get",
"dataframe",
"with",
"pdb",
"ids",
"having",
"sequence",
"matching",
"given",
"sequence",
"motif"
] | def search_seq_motif(self, query, type_='prosite', return_type="entry", no_hits=1000, select=False):
results = self.__rest_api_commands.get('seqmotif')(query, type_,
resp_type=return_type,
rows=... | [
"def",
"search_seq_motif",
"(",
"self",
",",
"query",
",",
"type_",
"=",
"'prosite'",
",",
"return_type",
"=",
"\"entry\"",
",",
"no_hits",
"=",
"1000",
",",
"select",
"=",
"False",
")",
":",
"results",
"=",
"self",
".",
"__rest_api_commands",
".",
"get",
... | Get dataframe with pdb ids having sequence matching given sequence motif | [
"Get",
"dataframe",
"with",
"pdb",
"ids",
"having",
"sequence",
"matching",
"given",
"sequence",
"motif"
] | [
"\"\"\"\n Get dataframe with pdb ids having sequence matching given sequence motif\n :param query: (str) motif to find in pdb sequences, according to given type_ (i.e prosite)\n :param type_: (str) name of type of query\n :param return_type: (str) type of returned data\n :param no... | [
{
"param": "self",
"type": null
},
{
"param": "query",
"type": null
},
{
"param": "type_",
"type": null
},
{
"param": "return_type",
"type": null
},
{
"param": "no_hits",
"type": null
},
{
"param": "select",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | search_seq | <not_specific> | def search_seq(self, sequence, evalue=1, identity=0.9, return_type="polymer_instance",
no_hits=1000, select=False):
"""
Get dataframe with pdb ids have sequence similar to given sequence
:param sequence: (str) sequence used to fin similar ones
:param evalue: (float) mi... |
Get dataframe with pdb ids have sequence similar to given sequence
:param sequence: (str) sequence used to fin similar ones
:param evalue: (float) minimum e value
:param identity: (float) minimum identity to input sequence
:param return_type: (str) type of returned data
... | Get dataframe with pdb ids have sequence similar to given sequence | [
"Get",
"dataframe",
"with",
"pdb",
"ids",
"have",
"sequence",
"similar",
"to",
"given",
"sequence"
] | def search_seq(self, sequence, evalue=1, identity=0.9, return_type="polymer_instance",
no_hits=1000, select=False):
results = self.__rest_api_commands.get('sequence')(sequence, evalue, identity,
resp_type=return_type, rows=no_hits).ex... | [
"def",
"search_seq",
"(",
"self",
",",
"sequence",
",",
"evalue",
"=",
"1",
",",
"identity",
"=",
"0.9",
",",
"return_type",
"=",
"\"polymer_instance\"",
",",
"no_hits",
"=",
"1000",
",",
"select",
"=",
"False",
")",
":",
"results",
"=",
"self",
".",
"... | Get dataframe with pdb ids have sequence similar to given sequence | [
"Get",
"dataframe",
"with",
"pdb",
"ids",
"have",
"sequence",
"similar",
"to",
"given",
"sequence"
] | [
"\"\"\"\n Get dataframe with pdb ids have sequence similar to given sequence\n :param sequence: (str) sequence used to fin similar ones\n :param evalue: (float) minimum e value\n :param identity: (float) minimum identity to input sequence\n :param return_type: (str) type of return... | [
{
"param": "self",
"type": null
},
{
"param": "sequence",
"type": null
},
{
"param": "evalue",
"type": null
},
{
"param": "identity",
"type": null
},
{
"param": "return_type",
"type": null
},
{
"param": "no_hits",
"type": null
},
{
"param":... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | search_struct | <not_specific> | def search_struct(self, pdb_id, assembly_id=1, operator='strict_shape_match',
return_type="entry", no_hits=1000, select=False):
"""
Get dataframe with pdb ids having structure similar to structure of given pdb_id
:param pdb_id: (str) pdb id (i.e 2mnr)
:param assembl... |
Get dataframe with pdb ids having structure similar to structure of given pdb_id
:param pdb_id: (str) pdb id (i.e 2mnr)
:param assembly_id: (int) assembly number
:param operator: (str) match mode type either relaxed_shape_match or strict_shape_match
:param return_type: (str) typ... | Get dataframe with pdb ids having structure similar to structure of given pdb_id | [
"Get",
"dataframe",
"with",
"pdb",
"ids",
"having",
"structure",
"similar",
"to",
"structure",
"of",
"given",
"pdb_id"
] | def search_struct(self, pdb_id, assembly_id=1, operator='strict_shape_match',
return_type="entry", no_hits=1000, select=False):
results = self.__rest_api_commands.get('structure')(pdb_id, assembly_id, operator,
resp_type=return_ty... | [
"def",
"search_struct",
"(",
"self",
",",
"pdb_id",
",",
"assembly_id",
"=",
"1",
",",
"operator",
"=",
"'strict_shape_match'",
",",
"return_type",
"=",
"\"entry\"",
",",
"no_hits",
"=",
"1000",
",",
"select",
"=",
"False",
")",
":",
"results",
"=",
"self"... | Get dataframe with pdb ids having structure similar to structure of given pdb_id | [
"Get",
"dataframe",
"with",
"pdb",
"ids",
"having",
"structure",
"similar",
"to",
"structure",
"of",
"given",
"pdb_id"
] | [
"\"\"\"\n Get dataframe with pdb ids having structure similar to structure of given pdb_id\n :param pdb_id: (str) pdb id (i.e 2mnr)\n :param assembly_id: (int) assembly number\n :param operator: (str) match mode type either relaxed_shape_match or strict_shape_match\n :param return... | [
{
"param": "self",
"type": null
},
{
"param": "pdb_id",
"type": null
},
{
"param": "assembly_id",
"type": null
},
{
"param": "operator",
"type": null
},
{
"param": "return_type",
"type": null
},
{
"param": "no_hits",
"type": null
},
{
"para... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | search_struct_motif | <not_specific> | def search_struct_motif(self, pdb_id, residue_ids, score_cutoff=0, exchanges=None,
return_type="entry", no_hits=1000, select=False):
"""
Get dataframe with pdb ids having structure motif similar to one defined for pdb_id
:param pdb_id: (str) pdb id (i.e 2mnr)
... |
Get dataframe with pdb ids having structure motif similar to one defined for pdb_id
:param pdb_id: (str) pdb id (i.e 2mnr)
:param residue_ids: (list(dict,)) definition of motif
:param score_cutoff: (int) return matches having scores greater than this value
:param exchanges: (lis... | Get dataframe with pdb ids having structure motif similar to one defined for pdb_id | [
"Get",
"dataframe",
"with",
"pdb",
"ids",
"having",
"structure",
"motif",
"similar",
"to",
"one",
"defined",
"for",
"pdb_id"
] | def search_struct_motif(self, pdb_id, residue_ids, score_cutoff=0, exchanges=None,
return_type="entry", no_hits=1000, select=False):
results = self.__rest_api_commands.get('strucmotif')(pdb_id, residue_ids, score_cutoff, exchanges,
... | [
"def",
"search_struct_motif",
"(",
"self",
",",
"pdb_id",
",",
"residue_ids",
",",
"score_cutoff",
"=",
"0",
",",
"exchanges",
"=",
"None",
",",
"return_type",
"=",
"\"entry\"",
",",
"no_hits",
"=",
"1000",
",",
"select",
"=",
"False",
")",
":",
"results",... | Get dataframe with pdb ids having structure motif similar to one defined for pdb_id | [
"Get",
"dataframe",
"with",
"pdb",
"ids",
"having",
"structure",
"motif",
"similar",
"to",
"one",
"defined",
"for",
"pdb_id"
] | [
"\"\"\"\n Get dataframe with pdb ids having structure motif similar to one defined for pdb_id\n :param pdb_id: (str) pdb id (i.e 2mnr)\n :param residue_ids: (list(dict,)) definition of motif\n :param score_cutoff: (int) return matches having scores greater than this value\n :param... | [
{
"param": "self",
"type": null
},
{
"param": "pdb_id",
"type": null
},
{
"param": "residue_ids",
"type": null
},
{
"param": "score_cutoff",
"type": null
},
{
"param": "exchanges",
"type": null
},
{
"param": "return_type",
"type": null
},
{
... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | search | <not_specific> | def search(self, attribute, operator, value, return_type='entry', no_hits=1000, get_doc_only=False, select=False):
"""
Get dataframe with results from search for value of given attribute
:param attribute: (str) attribute to search for
:param operator: (int) operator to filter attribute b... |
Get dataframe with results from search for value of given attribute
:param attribute: (str) attribute to search for
:param operator: (int) operator to filter attribute by value i.e greater, in etc
:param value: (str) value of given attribute
:param return_type: (str) type of ret... | Get dataframe with results from search for value of given attribute | [
"Get",
"dataframe",
"with",
"results",
"from",
"search",
"for",
"value",
"of",
"given",
"attribute"
] | def search(self, attribute, operator, value, return_type='entry', no_hits=1000, get_doc_only=False, select=False):
command = self.__rest_api_commands.get('text')(attribute, operator, value,
resp_type=return_type, rows=no_hits)
if get_doc_only:
... | [
"def",
"search",
"(",
"self",
",",
"attribute",
",",
"operator",
",",
"value",
",",
"return_type",
"=",
"'entry'",
",",
"no_hits",
"=",
"1000",
",",
"get_doc_only",
"=",
"False",
",",
"select",
"=",
"False",
")",
":",
"command",
"=",
"self",
".",
"__re... | Get dataframe with results from search for value of given attribute | [
"Get",
"dataframe",
"with",
"results",
"from",
"search",
"for",
"value",
"of",
"given",
"attribute"
] | [
"\"\"\"\n Get dataframe with results from search for value of given attribute\n :param attribute: (str) attribute to search for\n :param operator: (int) operator to filter attribute by value i.e greater, in etc\n :param value: (str) value of given attribute\n :param return_type: (... | [
{
"param": "self",
"type": null
},
{
"param": "attribute",
"type": null
},
{
"param": "operator",
"type": null
},
{
"param": "value",
"type": null
},
{
"param": "return_type",
"type": null
},
{
"param": "no_hits",
"type": null
},
{
"param":... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
dfb51ce1e2105aba65a3b93ec24d86f605aa52f0 | labstructbioinf/localpdb | localpdb/PDB.py | [
"MIT"
] | Python | _get_current_indexes | <not_specific> | def _get_current_indexes(self):
"""
Returns current indexes of the structures and chains dataframes.
:return: set with structure df indexes and set with chains df indexes
"""
pdb_ids = set(self.__entries.index)
pdb_chain_ids = set(self.__chains.index)
return pdb_i... |
Returns current indexes of the structures and chains dataframes.
:return: set with structure df indexes and set with chains df indexes
| Returns current indexes of the structures and chains dataframes. | [
"Returns",
"current",
"indexes",
"of",
"the",
"structures",
"and",
"chains",
"dataframes",
"."
] | def _get_current_indexes(self):
pdb_ids = set(self.__entries.index)
pdb_chain_ids = set(self.__chains.index)
return pdb_ids, pdb_chain_ids | [
"def",
"_get_current_indexes",
"(",
"self",
")",
":",
"pdb_ids",
"=",
"set",
"(",
"self",
".",
"__entries",
".",
"index",
")",
"pdb_chain_ids",
"=",
"set",
"(",
"self",
".",
"__chains",
".",
"index",
")",
"return",
"pdb_ids",
",",
"pdb_chain_ids"
] | Returns current indexes of the structures and chains dataframes. | [
"Returns",
"current",
"indexes",
"of",
"the",
"structures",
"and",
"chains",
"dataframes",
"."
] | [
"\"\"\"\n Returns current indexes of the structures and chains dataframes.\n :return: set with structure df indexes and set with chains df indexes\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "set with structure df indexes and set with chains df indexes",
"docstring_tokens": [
"set",
"with",
"structure",
"df",
"indexes",
"and",
"set",
"with",
"chains",
"df",
"indexes"
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.