repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
TUT-ARG/sed_eval | sed_eval/sound_event.py | EventBasedMetrics.validate_offset | def validate_offset(reference_event, estimated_event, t_collar=0.200, percentage_of_length=0.5):
"""Validate estimated event based on event offset
Parameters
----------
reference_event : dict
Reference event.
estimated_event : dict
Estimated event.
... | python | def validate_offset(reference_event, estimated_event, t_collar=0.200, percentage_of_length=0.5):
"""Validate estimated event based on event offset
Parameters
----------
reference_event : dict
Reference event.
estimated_event : dict
Estimated event.
... | [
"def",
"validate_offset",
"(",
"reference_event",
",",
"estimated_event",
",",
"t_collar",
"=",
"0.200",
",",
"percentage_of_length",
"=",
"0.5",
")",
":",
"if",
"'event_offset'",
"in",
"reference_event",
"and",
"'event_offset'",
"in",
"estimated_event",
":",
"annot... | Validate estimated event based on event offset
Parameters
----------
reference_event : dict
Reference event.
estimated_event : dict
Estimated event.
t_collar : float > 0, seconds
First condition, Time collar with which the estimated offset h... | [
"Validate",
"estimated",
"event",
"based",
"on",
"event",
"offset"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/sound_event.py#L1633-L1668 | train |
TUT-ARG/sed_eval | sed_eval/io.py | load_event_list | def load_event_list(filename, **kwargs):
"""Load event list from csv formatted text-file
Supported formats (see more `dcase_util.containers.MetaDataContainer.load()` method):
- [event onset (float >= 0)][delimiter][event offset (float >= 0)]
- [event onset (float >= 0)][delimiter][event offset (float ... | python | def load_event_list(filename, **kwargs):
"""Load event list from csv formatted text-file
Supported formats (see more `dcase_util.containers.MetaDataContainer.load()` method):
- [event onset (float >= 0)][delimiter][event offset (float >= 0)]
- [event onset (float >= 0)][delimiter][event offset (float ... | [
"def",
"load_event_list",
"(",
"filename",
",",
"**",
"kwargs",
")",
":",
"return",
"dcase_util",
".",
"containers",
".",
"MetaDataContainer",
"(",
")",
".",
"load",
"(",
"filename",
"=",
"filename",
",",
"**",
"kwargs",
")"
] | Load event list from csv formatted text-file
Supported formats (see more `dcase_util.containers.MetaDataContainer.load()` method):
- [event onset (float >= 0)][delimiter][event offset (float >= 0)]
- [event onset (float >= 0)][delimiter][event offset (float >= 0)][delimiter][label]
- [filename][delimi... | [
"Load",
"event",
"list",
"from",
"csv",
"formatted",
"text",
"-",
"file"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/io.py#L22-L70 | train |
TUT-ARG/sed_eval | sed_eval/io.py | load_scene_list | def load_scene_list(filename, **kwargs):
"""Load scene list from csv formatted text-file
Supported formats (see more `dcase_util.containers.MetaDataContainer.load()` method):
- [filename][delimiter][scene label]
- [filename][delimiter][segment start (float >= 0)][delimiter][segment stop (float >= 0)][... | python | def load_scene_list(filename, **kwargs):
"""Load scene list from csv formatted text-file
Supported formats (see more `dcase_util.containers.MetaDataContainer.load()` method):
- [filename][delimiter][scene label]
- [filename][delimiter][segment start (float >= 0)][delimiter][segment stop (float >= 0)][... | [
"def",
"load_scene_list",
"(",
"filename",
",",
"**",
"kwargs",
")",
":",
"return",
"dcase_util",
".",
"containers",
".",
"MetaDataContainer",
"(",
")",
".",
"load",
"(",
"filename",
"=",
"filename",
",",
"**",
"kwargs",
")"
] | Load scene list from csv formatted text-file
Supported formats (see more `dcase_util.containers.MetaDataContainer.load()` method):
- [filename][delimiter][scene label]
- [filename][delimiter][segment start (float >= 0)][delimiter][segment stop (float >= 0)][delimiter][scene label]
Supported delimiter... | [
"Load",
"scene",
"list",
"from",
"csv",
"formatted",
"text",
"-",
"file"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/io.py#L73-L107 | train |
TUT-ARG/sed_eval | sed_eval/io.py | load_file_pair_list | def load_file_pair_list(filename):
"""Load file pair list csv formatted text-file
Format is [reference_file][delimiter][estimated_file]
Supported delimiters: ``,``, ``;``, ``tab``
Example of file-list::
office_snr0_high_v2.txt office_snr0_high_v2_detected.txt
office_snr0_med_v2.txt o... | python | def load_file_pair_list(filename):
"""Load file pair list csv formatted text-file
Format is [reference_file][delimiter][estimated_file]
Supported delimiters: ``,``, ``;``, ``tab``
Example of file-list::
office_snr0_high_v2.txt office_snr0_high_v2_detected.txt
office_snr0_med_v2.txt o... | [
"def",
"load_file_pair_list",
"(",
"filename",
")",
":",
"data",
"=",
"[",
"]",
"input_file",
"=",
"open",
"(",
"filename",
",",
"'rt'",
")",
"try",
":",
"dialect",
"=",
"csv",
".",
"Sniffer",
"(",
")",
".",
"sniff",
"(",
"input_file",
".",
"readline",... | Load file pair list csv formatted text-file
Format is [reference_file][delimiter][estimated_file]
Supported delimiters: ``,``, ``;``, ``tab``
Example of file-list::
office_snr0_high_v2.txt office_snr0_high_v2_detected.txt
office_snr0_med_v2.txt office_snr0_med_v2_detected.txt
Parame... | [
"Load",
"file",
"pair",
"list",
"csv",
"formatted",
"text",
"-",
"file"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/io.py#L110-L160 | train |
TUT-ARG/sed_eval | sed_eval/scene.py | SceneClassificationMetrics.class_wise_accuracy | def class_wise_accuracy(self, scene_label):
"""Class-wise accuracy
Returns
-------
dict
results in a dictionary format
"""
if len(self.accuracies_per_class.shape) == 2:
return {
'accuracy': float(numpy.mean(self.accuracies_per_cl... | python | def class_wise_accuracy(self, scene_label):
"""Class-wise accuracy
Returns
-------
dict
results in a dictionary format
"""
if len(self.accuracies_per_class.shape) == 2:
return {
'accuracy': float(numpy.mean(self.accuracies_per_cl... | [
"def",
"class_wise_accuracy",
"(",
"self",
",",
"scene_label",
")",
":",
"if",
"len",
"(",
"self",
".",
"accuracies_per_class",
".",
"shape",
")",
"==",
"2",
":",
"return",
"{",
"'accuracy'",
":",
"float",
"(",
"numpy",
".",
"mean",
"(",
"self",
".",
"... | Class-wise accuracy
Returns
-------
dict
results in a dictionary format | [
"Class",
"-",
"wise",
"accuracy"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/scene.py#L466-L484 | train |
TUT-ARG/sed_eval | sed_eval/util/scene_list.py | unique_scene_labels | def unique_scene_labels(scene_list):
"""Find the unique scene labels
Parameters
----------
scene_list : list, shape=(n,)
A list containing scene dicts
Returns
-------
labels: list, shape=(n,)
Unique labels in alphabetical order
"""
if isinstance(scene_list, dcase_u... | python | def unique_scene_labels(scene_list):
"""Find the unique scene labels
Parameters
----------
scene_list : list, shape=(n,)
A list containing scene dicts
Returns
-------
labels: list, shape=(n,)
Unique labels in alphabetical order
"""
if isinstance(scene_list, dcase_u... | [
"def",
"unique_scene_labels",
"(",
"scene_list",
")",
":",
"if",
"isinstance",
"(",
"scene_list",
",",
"dcase_util",
".",
"containers",
".",
"MetaDataContainer",
")",
":",
"return",
"scene_list",
".",
"unique_scene_labels",
"else",
":",
"labels",
"=",
"[",
"]",
... | Find the unique scene labels
Parameters
----------
scene_list : list, shape=(n,)
A list containing scene dicts
Returns
-------
labels: list, shape=(n,)
Unique labels in alphabetical order | [
"Find",
"the",
"unique",
"scene",
"labels"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/util/scene_list.py#L11-L35 | train |
TUT-ARG/sed_eval | sed_eval/util/event_roll.py | event_list_to_event_roll | def event_list_to_event_roll(source_event_list, event_label_list=None, time_resolution=0.01):
"""Convert event list into event roll, binary activity matrix
Parameters
----------
source_event_list : list, shape=(n,)
A list containing event dicts
event_label_list : list, shape=(k,) or None
... | python | def event_list_to_event_roll(source_event_list, event_label_list=None, time_resolution=0.01):
"""Convert event list into event roll, binary activity matrix
Parameters
----------
source_event_list : list, shape=(n,)
A list containing event dicts
event_label_list : list, shape=(k,) or None
... | [
"def",
"event_list_to_event_roll",
"(",
"source_event_list",
",",
"event_label_list",
"=",
"None",
",",
"time_resolution",
"=",
"0.01",
")",
":",
"if",
"isinstance",
"(",
"source_event_list",
",",
"dcase_util",
".",
"containers",
".",
"MetaDataContainer",
")",
":",
... | Convert event list into event roll, binary activity matrix
Parameters
----------
source_event_list : list, shape=(n,)
A list containing event dicts
event_label_list : list, shape=(k,) or None
A list of containing unique labels in alphabetical order
(Default value = None)
ti... | [
"Convert",
"event",
"list",
"into",
"event",
"roll",
"binary",
"activity",
"matrix"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/util/event_roll.py#L13-L71 | train |
TUT-ARG/sed_eval | sed_eval/util/event_roll.py | pad_event_roll | def pad_event_roll(event_roll, length):
"""Pad event roll's length to given length
Parameters
----------
event_roll: np.ndarray, shape=(m,k)
Event roll
length : int
Length to be padded
Returns
-------
event_roll: np.ndarray, shape=(m,k)
Padded event roll
"... | python | def pad_event_roll(event_roll, length):
"""Pad event roll's length to given length
Parameters
----------
event_roll: np.ndarray, shape=(m,k)
Event roll
length : int
Length to be padded
Returns
-------
event_roll: np.ndarray, shape=(m,k)
Padded event roll
"... | [
"def",
"pad_event_roll",
"(",
"event_roll",
",",
"length",
")",
":",
"if",
"length",
">",
"event_roll",
".",
"shape",
"[",
"0",
"]",
":",
"padding",
"=",
"numpy",
".",
"zeros",
"(",
"(",
"length",
"-",
"event_roll",
".",
"shape",
"[",
"0",
"]",
",",
... | Pad event roll's length to given length
Parameters
----------
event_roll: np.ndarray, shape=(m,k)
Event roll
length : int
Length to be padded
Returns
-------
event_roll: np.ndarray, shape=(m,k)
Padded event roll | [
"Pad",
"event",
"roll",
"s",
"length",
"to",
"given",
"length"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/util/event_roll.py#L74-L96 | train |
TUT-ARG/sed_eval | sed_eval/util/event_roll.py | match_event_roll_lengths | def match_event_roll_lengths(event_roll_a, event_roll_b, length=None):
"""Fix the length of two event rolls
Parameters
----------
event_roll_a: np.ndarray, shape=(m1,k)
Event roll A
event_roll_b: np.ndarray, shape=(m2,k)
Event roll B
length: int, optional
Length of the... | python | def match_event_roll_lengths(event_roll_a, event_roll_b, length=None):
"""Fix the length of two event rolls
Parameters
----------
event_roll_a: np.ndarray, shape=(m1,k)
Event roll A
event_roll_b: np.ndarray, shape=(m2,k)
Event roll B
length: int, optional
Length of the... | [
"def",
"match_event_roll_lengths",
"(",
"event_roll_a",
",",
"event_roll_b",
",",
"length",
"=",
"None",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"max",
"(",
"event_roll_b",
".",
"shape",
"[",
"0",
"]",
",",
"event_roll_a",
".",
"shape",... | Fix the length of two event rolls
Parameters
----------
event_roll_a: np.ndarray, shape=(m1,k)
Event roll A
event_roll_b: np.ndarray, shape=(m2,k)
Event roll B
length: int, optional
Length of the event roll, if none given, shorter event roll is padded to match longer one.
... | [
"Fix",
"the",
"length",
"of",
"two",
"event",
"rolls"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/util/event_roll.py#L99-L148 | train |
TUT-ARG/sed_eval | sed_eval/util/event_list.py | filter_event_list | def filter_event_list(event_list, scene_label=None, event_label=None, filename=None):
"""Filter event list based on given fields
Parameters
----------
event_list : list, shape=(n,)
A list containing event dicts
scene_label : str
Scene label
event_label : str
Event labe... | python | def filter_event_list(event_list, scene_label=None, event_label=None, filename=None):
"""Filter event list based on given fields
Parameters
----------
event_list : list, shape=(n,)
A list containing event dicts
scene_label : str
Scene label
event_label : str
Event labe... | [
"def",
"filter_event_list",
"(",
"event_list",
",",
"scene_label",
"=",
"None",
",",
"event_label",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"return",
"dcase_util",
".",
"containers",
".",
"MetaDataContainer",
"(",
"event_list",
")",
".",
"filter",... | Filter event list based on given fields
Parameters
----------
event_list : list, shape=(n,)
A list containing event dicts
scene_label : str
Scene label
event_label : str
Event label
filename : str
Filename
Returns
-------
event_list: list, shape=(... | [
"Filter",
"event",
"list",
"based",
"on",
"given",
"fields"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/util/event_list.py#L15-L43 | train |
TUT-ARG/sed_eval | sed_eval/util/event_list.py | unique_files | def unique_files(event_list):
"""Find the unique files
Parameters
----------
event_list : list or dcase_util.containers.MetaDataContainer
A list containing event dicts
Returns
-------
list
Unique filenames in alphabetical order
"""
if isinstance(event_list, dcase_... | python | def unique_files(event_list):
"""Find the unique files
Parameters
----------
event_list : list or dcase_util.containers.MetaDataContainer
A list containing event dicts
Returns
-------
list
Unique filenames in alphabetical order
"""
if isinstance(event_list, dcase_... | [
"def",
"unique_files",
"(",
"event_list",
")",
":",
"if",
"isinstance",
"(",
"event_list",
",",
"dcase_util",
".",
"containers",
".",
"MetaDataContainer",
")",
":",
"return",
"event_list",
".",
"unique_files",
"else",
":",
"files",
"=",
"{",
"}",
"for",
"eve... | Find the unique files
Parameters
----------
event_list : list or dcase_util.containers.MetaDataContainer
A list containing event dicts
Returns
-------
list
Unique filenames in alphabetical order | [
"Find",
"the",
"unique",
"files"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/util/event_list.py#L46-L75 | train |
TUT-ARG/sed_eval | sed_eval/util/event_list.py | unique_event_labels | def unique_event_labels(event_list):
"""Find the unique event labels
Parameters
----------
event_list : list or dcase_util.containers.MetaDataContainer
A list containing event dicts
Returns
-------
list
Unique labels in alphabetical order
"""
if isinstance(event_l... | python | def unique_event_labels(event_list):
"""Find the unique event labels
Parameters
----------
event_list : list or dcase_util.containers.MetaDataContainer
A list containing event dicts
Returns
-------
list
Unique labels in alphabetical order
"""
if isinstance(event_l... | [
"def",
"unique_event_labels",
"(",
"event_list",
")",
":",
"if",
"isinstance",
"(",
"event_list",
",",
"dcase_util",
".",
"containers",
".",
"MetaDataContainer",
")",
":",
"return",
"event_list",
".",
"unique_event_labels",
"else",
":",
"labels",
"=",
"[",
"]",
... | Find the unique event labels
Parameters
----------
event_list : list or dcase_util.containers.MetaDataContainer
A list containing event dicts
Returns
-------
list
Unique labels in alphabetical order | [
"Find",
"the",
"unique",
"event",
"labels"
] | 0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb | https://github.com/TUT-ARG/sed_eval/blob/0cb1b6d11ceec4fe500cc9b31079c9d8666ed6eb/sed_eval/util/event_list.py#L78-L103 | train |
rasguanabana/ytfs | ytfs/actions.py | YTActions.__getChannelId | def __getChannelId(self):
"""
Obtain channel id for channel name, if present in ``self.search_params``.
"""
if not self.search_params.get("channelId"):
return
api_fixed_url = "https://www.googleapis.com/youtube/v3/channels?part=id&maxResults=1&fields=items%2Fid&"
... | python | def __getChannelId(self):
"""
Obtain channel id for channel name, if present in ``self.search_params``.
"""
if not self.search_params.get("channelId"):
return
api_fixed_url = "https://www.googleapis.com/youtube/v3/channels?part=id&maxResults=1&fields=items%2Fid&"
... | [
"def",
"__getChannelId",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"search_params",
".",
"get",
"(",
"\"channelId\"",
")",
":",
"return",
"api_fixed_url",
"=",
"\"https://www.googleapis.com/youtube/v3/channels?part=id&maxResults=1&fields=items%2Fid&\"",
"url",
"=",... | Obtain channel id for channel name, if present in ``self.search_params``. | [
"Obtain",
"channel",
"id",
"for",
"channel",
"name",
"if",
"present",
"in",
"self",
".",
"search_params",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/actions.py#L113-L141 | train |
rasguanabana/ytfs | ytfs/actions.py | YTActions.__searchParser | def __searchParser(self, query):
"""
Parse `query` for advanced search options.
Parameters
----------
query : str
Search query to parse. Besides a search query, user can specify additional search parameters and YTFS
specific options. Syntax:
... | python | def __searchParser(self, query):
"""
Parse `query` for advanced search options.
Parameters
----------
query : str
Search query to parse. Besides a search query, user can specify additional search parameters and YTFS
specific options. Syntax:
... | [
"def",
"__searchParser",
"(",
"self",
",",
"query",
")",
":",
"ret",
"=",
"dict",
"(",
")",
"parse_params",
"=",
"True",
"buf",
"=",
"\"\"",
"ptr",
"=",
"\"\"",
"p_avail",
"=",
"(",
"\"channel\"",
",",
"\"max\"",
",",
"\"before\"",
",",
"\"after\"",
",... | Parse `query` for advanced search options.
Parameters
----------
query : str
Search query to parse. Besides a search query, user can specify additional search parameters and YTFS
specific options. Syntax:
Additional search parameters: ``option:value``. if `va... | [
"Parse",
"query",
"for",
"advanced",
"search",
"options",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/actions.py#L143-L274 | train |
rasguanabana/ytfs | ytfs/actions.py | YTActions.__search | def __search(self, pt=""):
"""
Method responsible for searching using YouTube API.
Parameters
----------
pt : str
Token of search results page. If ``None``, then the first page is downloaded.
Returns
-------
results : dict
Parsed... | python | def __search(self, pt=""):
"""
Method responsible for searching using YouTube API.
Parameters
----------
pt : str
Token of search results page. If ``None``, then the first page is downloaded.
Returns
-------
results : dict
Parsed... | [
"def",
"__search",
"(",
"self",
",",
"pt",
"=",
"\"\"",
")",
":",
"if",
"not",
"self",
".",
"search_params",
".",
"get",
"(",
"'q'",
")",
"and",
"not",
"self",
".",
"search_params",
".",
"get",
"(",
"'channelId'",
")",
":",
"return",
"{",
"'items'",
... | Method responsible for searching using YouTube API.
Parameters
----------
pt : str
Token of search results page. If ``None``, then the first page is downloaded.
Returns
-------
results : dict
Parsed JSON returned by YouTube API. | [
"Method",
"responsible",
"for",
"searching",
"using",
"YouTube",
"API",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/actions.py#L276-L309 | train |
rasguanabana/ytfs | ytfs/actions.py | YTActions.clean | def clean(self):
"""Clear the data. For each ``YTStor`` object present in this object ``clean`` method is executed."""
for s in self.visible_files.values():
s.clean()
for s in [sub[1][x] for sub in self.avail_files.values() for x in sub[1]]: # Double list comprehensions aren't very... | python | def clean(self):
"""Clear the data. For each ``YTStor`` object present in this object ``clean`` method is executed."""
for s in self.visible_files.values():
s.clean()
for s in [sub[1][x] for sub in self.avail_files.values() for x in sub[1]]: # Double list comprehensions aren't very... | [
"def",
"clean",
"(",
"self",
")",
":",
"for",
"s",
"in",
"self",
".",
"visible_files",
".",
"values",
"(",
")",
":",
"s",
".",
"clean",
"(",
")",
"for",
"s",
"in",
"[",
"sub",
"[",
"1",
"]",
"[",
"x",
"]",
"for",
"sub",
"in",
"self",
".",
"... | Clear the data. For each ``YTStor`` object present in this object ``clean`` method is executed. | [
"Clear",
"the",
"data",
".",
"For",
"each",
"YTStor",
"object",
"present",
"in",
"this",
"object",
"clean",
"method",
"is",
"executed",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/actions.py#L477-L484 | train |
rasguanabana/ytfs | ytfs/stor.py | YTStor.obtainInfo | def obtainInfo(self):
"""
Method for obtaining information about the movie.
"""
try:
info = self.ytdl.extract_info(self.yid, download=False)
except youtube_dl.utils.DownloadError:
raise ConnectionError
if not self.preferences['stream']:
... | python | def obtainInfo(self):
"""
Method for obtaining information about the movie.
"""
try:
info = self.ytdl.extract_info(self.yid, download=False)
except youtube_dl.utils.DownloadError:
raise ConnectionError
if not self.preferences['stream']:
... | [
"def",
"obtainInfo",
"(",
"self",
")",
":",
"try",
":",
"info",
"=",
"self",
".",
"ytdl",
".",
"extract_info",
"(",
"self",
".",
"yid",
",",
"download",
"=",
"False",
")",
"except",
"youtube_dl",
".",
"utils",
".",
"DownloadError",
":",
"raise",
"Conne... | Method for obtaining information about the movie. | [
"Method",
"for",
"obtaining",
"information",
"about",
"the",
"movie",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/stor.py#L205-L264 | train |
rasguanabana/ytfs | ytfs/stor.py | YTStor.registerHandler | def registerHandler(self, fh): # Do I even need that? possible FIXME.
"""
Register new file descriptor.
Parameters
----------
fh : int
File descriptor.
"""
self.fds.add(fh)
self.atime = int(time()) # update access time
self.lock.acq... | python | def registerHandler(self, fh): # Do I even need that? possible FIXME.
"""
Register new file descriptor.
Parameters
----------
fh : int
File descriptor.
"""
self.fds.add(fh)
self.atime = int(time()) # update access time
self.lock.acq... | [
"def",
"registerHandler",
"(",
"self",
",",
"fh",
")",
":",
"self",
".",
"fds",
".",
"add",
"(",
"fh",
")",
"self",
".",
"atime",
"=",
"int",
"(",
"time",
"(",
")",
")",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"(",
"0... | Register new file descriptor.
Parameters
----------
fh : int
File descriptor. | [
"Register",
"new",
"file",
"descriptor",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/stor.py#L266-L290 | train |
rasguanabana/ytfs | ytfs/stor.py | YTStor.read | def read(self, offset, length, fh):
"""
Read data. Method returns data instantly, if they're avaialable and in ``self.safe_range``. Otherwise data is
downloaded and then returned.
Parameters
----------
offset : int
Read offset
length : int
... | python | def read(self, offset, length, fh):
"""
Read data. Method returns data instantly, if they're avaialable and in ``self.safe_range``. Otherwise data is
downloaded and then returned.
Parameters
----------
offset : int
Read offset
length : int
... | [
"def",
"read",
"(",
"self",
",",
"offset",
",",
"length",
",",
"fh",
")",
":",
"current",
"=",
"(",
"offset",
",",
"offset",
"+",
"length",
")",
"safe",
"=",
"[",
"current",
"[",
"0",
"]",
"-",
"(",
"8",
"*",
"length",
")",
",",
"current",
"[",... | Read data. Method returns data instantly, if they're avaialable and in ``self.safe_range``. Otherwise data is
downloaded and then returned.
Parameters
----------
offset : int
Read offset
length : int
Length of data to read.
fh : int
Fi... | [
"Read",
"data",
".",
"Method",
"returns",
"data",
"instantly",
"if",
"they",
"re",
"avaialable",
"and",
"in",
"self",
".",
"safe_range",
".",
"Otherwise",
"data",
"is",
"downloaded",
"and",
"then",
"returned",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/stor.py#L292-L335 | train |
rasguanabana/ytfs | ytfs/stor.py | YTStor.clean | def clean(self):
"""
Clear data. Explicitly close ``self.data`` if object is unused.
"""
self.closing = True # schedule for closing.
if not self.fds:
self.data.close() | python | def clean(self):
"""
Clear data. Explicitly close ``self.data`` if object is unused.
"""
self.closing = True # schedule for closing.
if not self.fds:
self.data.close() | [
"def",
"clean",
"(",
"self",
")",
":",
"self",
".",
"closing",
"=",
"True",
"if",
"not",
"self",
".",
"fds",
":",
"self",
".",
"data",
".",
"close",
"(",
")"
] | Clear data. Explicitly close ``self.data`` if object is unused. | [
"Clear",
"data",
".",
"Explicitly",
"close",
"self",
".",
"data",
"if",
"object",
"is",
"unused",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/stor.py#L337-L346 | train |
rasguanabana/ytfs | ytfs/stor.py | YTStor.unregisterHandler | def unregisterHandler(self, fh):
"""
Unregister a file descriptor. Clean data, if such operation has been scheduled.
Parameters
----------
fh : int
File descriptor.
"""
try:
self.fds.remove(fh)
except KeyError:
pass
... | python | def unregisterHandler(self, fh):
"""
Unregister a file descriptor. Clean data, if such operation has been scheduled.
Parameters
----------
fh : int
File descriptor.
"""
try:
self.fds.remove(fh)
except KeyError:
pass
... | [
"def",
"unregisterHandler",
"(",
"self",
",",
"fh",
")",
":",
"try",
":",
"self",
".",
"fds",
".",
"remove",
"(",
"fh",
")",
"except",
"KeyError",
":",
"pass",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"try",
":",
"self",
".",
"data",
".",
"... | Unregister a file descriptor. Clean data, if such operation has been scheduled.
Parameters
----------
fh : int
File descriptor. | [
"Unregister",
"a",
"file",
"descriptor",
".",
"Clean",
"data",
"if",
"such",
"operation",
"has",
"been",
"scheduled",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/stor.py#L348-L374 | train |
rasguanabana/ytfs | ytfs/ytfs.py | fd_dict.push | def push(self, yts):
"""
Search for, add and return new file descriptor.
Parameters
----------
yts : YTStor-obj or None
``YTStor`` object for which we want to allocate a descriptor or ``None``, if we allocate descriptor for a
control file.
Retur... | python | def push(self, yts):
"""
Search for, add and return new file descriptor.
Parameters
----------
yts : YTStor-obj or None
``YTStor`` object for which we want to allocate a descriptor or ``None``, if we allocate descriptor for a
control file.
Retur... | [
"def",
"push",
"(",
"self",
",",
"yts",
")",
":",
"if",
"not",
"isinstance",
"(",
"yts",
",",
"(",
"YTStor",
",",
"YTMetaStor",
",",
"type",
"(",
"None",
")",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected YTStor object, YTMetaStor object or None.\"",... | Search for, add and return new file descriptor.
Parameters
----------
yts : YTStor-obj or None
``YTStor`` object for which we want to allocate a descriptor or ``None``, if we allocate descriptor for a
control file.
Returns
-------
k : int
... | [
"Search",
"for",
"add",
"and",
"return",
"new",
"file",
"descriptor",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L70-L95 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.__pathToTuple | def __pathToTuple(self, path):
"""
Convert directory or file path to its tuple identifier.
Parameters
----------
path : str
Path to convert. It can look like /, /directory, /directory/ or /directory/filename.
Returns
-------
tup_id : tuple
... | python | def __pathToTuple(self, path):
"""
Convert directory or file path to its tuple identifier.
Parameters
----------
path : str
Path to convert. It can look like /, /directory, /directory/ or /directory/filename.
Returns
-------
tup_id : tuple
... | [
"def",
"__pathToTuple",
"(",
"self",
",",
"path",
")",
":",
"if",
"not",
"path",
"or",
"path",
".",
"count",
"(",
"'/'",
")",
">",
"2",
":",
"raise",
"YTFS",
".",
"PathConvertError",
"(",
"\"Bad path given\"",
")",
"try",
":",
"split",
"=",
"path",
"... | Convert directory or file path to its tuple identifier.
Parameters
----------
path : str
Path to convert. It can look like /, /directory, /directory/ or /directory/filename.
Returns
-------
tup_id : tuple
Two element tuple identifier of directory... | [
"Convert",
"directory",
"or",
"file",
"path",
"to",
"its",
"tuple",
"identifier",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L222-L277 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.__exists | def __exists(self, p):
"""
Check if file of given path exists.
Parameters
----------
p : str or tuple
Path or tuple identifier.
Returns
-------
exists : bool
``True``, if file exists. Otherwise ``False``.
"""
try... | python | def __exists(self, p):
"""
Check if file of given path exists.
Parameters
----------
p : str or tuple
Path or tuple identifier.
Returns
-------
exists : bool
``True``, if file exists. Otherwise ``False``.
"""
try... | [
"def",
"__exists",
"(",
"self",
",",
"p",
")",
":",
"try",
":",
"p",
"=",
"self",
".",
"__pathToTuple",
"(",
"p",
")",
"except",
"TypeError",
":",
"pass",
"return",
"(",
"(",
"not",
"p",
"[",
"0",
"]",
"and",
"not",
"p",
"[",
"1",
"]",
")",
"... | Check if file of given path exists.
Parameters
----------
p : str or tuple
Path or tuple identifier.
Returns
-------
exists : bool
``True``, if file exists. Otherwise ``False``. | [
"Check",
"if",
"file",
"of",
"given",
"path",
"exists",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L279-L301 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS._pathdec | def _pathdec(method):
"""
Decorator that replaces string `path` argument with its tuple identifier.
Parameters
----------
method : function
Function/method to decorate.
Returns
-------
mod : function
Function/method after decarot... | python | def _pathdec(method):
"""
Decorator that replaces string `path` argument with its tuple identifier.
Parameters
----------
method : function
Function/method to decorate.
Returns
-------
mod : function
Function/method after decarot... | [
"def",
"_pathdec",
"(",
"method",
")",
":",
"@",
"wraps",
"(",
"method",
")",
"def",
"mod",
"(",
"self",
",",
"path",
",",
"*",
"args",
")",
":",
"try",
":",
"return",
"method",
"(",
"self",
",",
"self",
".",
"__pathToTuple",
"(",
"path",
")",
",... | Decorator that replaces string `path` argument with its tuple identifier.
Parameters
----------
method : function
Function/method to decorate.
Returns
-------
mod : function
Function/method after decarotion. | [
"Decorator",
"that",
"replaces",
"string",
"path",
"argument",
"with",
"its",
"tuple",
"identifier",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L303-L328 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.getattr | def getattr(self, tid, fh=None):
"""
File attributes.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
fh : int
File descriptor. Unnecessary, therefore ignored.
... | python | def getattr(self, tid, fh=None):
"""
File attributes.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
fh : int
File descriptor. Unnecessary, therefore ignored.
... | [
"def",
"getattr",
"(",
"self",
",",
"tid",
",",
"fh",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"__exists",
"(",
"tid",
")",
":",
"raise",
"FuseOSError",
"(",
"errno",
".",
"ENOENT",
")",
"pt",
"=",
"self",
".",
"PathType",
".",
"get",
"("... | File attributes.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
fh : int
File descriptor. Unnecessary, therefore ignored.
Returns
-------
st : dict
... | [
"File",
"attributes",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L331-L380 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.readdir | def readdir(self, tid, fh):
"""
Read directory contents. Lists visible elements of ``YTActions`` object.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
fh : int
F... | python | def readdir(self, tid, fh):
"""
Read directory contents. Lists visible elements of ``YTActions`` object.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
fh : int
F... | [
"def",
"readdir",
"(",
"self",
",",
"tid",
",",
"fh",
")",
":",
"ret",
"=",
"[",
"]",
"pt",
"=",
"self",
".",
"PathType",
".",
"get",
"(",
"tid",
")",
"try",
":",
"if",
"pt",
"is",
"self",
".",
"PathType",
".",
"main",
":",
"ret",
"=",
"list"... | Read directory contents. Lists visible elements of ``YTActions`` object.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
fh : int
File descriptor. Ommited in the function body.
... | [
"Read",
"directory",
"contents",
".",
"Lists",
"visible",
"elements",
"of",
"YTActions",
"object",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L383-L419 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.mkdir | def mkdir(self, tid, mode):
"""
Directory creation. Search is performed.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
mode : int
Ignored.
"""
p... | python | def mkdir(self, tid, mode):
"""
Directory creation. Search is performed.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
mode : int
Ignored.
"""
p... | [
"def",
"mkdir",
"(",
"self",
",",
"tid",
",",
"mode",
")",
":",
"pt",
"=",
"self",
".",
"PathType",
".",
"get",
"(",
"tid",
")",
"if",
"pt",
"is",
"self",
".",
"PathType",
".",
"invalid",
"or",
"pt",
"is",
"self",
".",
"PathType",
".",
"file",
... | Directory creation. Search is performed.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
mode : int
Ignored. | [
"Directory",
"creation",
".",
"Search",
"is",
"performed",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L422-L451 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.rename | def rename(self, old, new):
"""
Directory renaming support. Needed because many file managers create directories with default names, wich
makes it impossible to perform a search without CLI. Name changes for files are not allowed, only for
directories.
Parameters
------... | python | def rename(self, old, new):
"""
Directory renaming support. Needed because many file managers create directories with default names, wich
makes it impossible to perform a search without CLI. Name changes for files are not allowed, only for
directories.
Parameters
------... | [
"def",
"rename",
"(",
"self",
",",
"old",
",",
"new",
")",
":",
"new",
"=",
"self",
".",
"__pathToTuple",
"(",
"new",
")",
"if",
"not",
"self",
".",
"__exists",
"(",
"old",
")",
":",
"raise",
"FuseOSError",
"(",
"errno",
".",
"ENOENT",
")",
"if",
... | Directory renaming support. Needed because many file managers create directories with default names, wich
makes it impossible to perform a search without CLI. Name changes for files are not allowed, only for
directories.
Parameters
----------
old : str
Old name. Conv... | [
"Directory",
"renaming",
"support",
".",
"Needed",
"because",
"many",
"file",
"managers",
"create",
"directories",
"with",
"default",
"names",
"wich",
"makes",
"it",
"impossible",
"to",
"perform",
"a",
"search",
"without",
"CLI",
".",
"Name",
"changes",
"for",
... | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L454-L494 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.rmdir | def rmdir(self, tid):
"""
Directory removal. ``YTActions`` object under `tid` is told to clean all data, and then it is deleted.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
... | python | def rmdir(self, tid):
"""
Directory removal. ``YTActions`` object under `tid` is told to clean all data, and then it is deleted.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
... | [
"def",
"rmdir",
"(",
"self",
",",
"tid",
")",
":",
"pt",
"=",
"self",
".",
"PathType",
".",
"get",
"(",
"tid",
")",
"if",
"pt",
"is",
"self",
".",
"PathType",
".",
"main",
":",
"raise",
"FuseOSError",
"(",
"errno",
".",
"EINVAL",
")",
"elif",
"pt... | Directory removal. ``YTActions`` object under `tid` is told to clean all data, and then it is deleted.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator. | [
"Directory",
"removal",
".",
"YTActions",
"object",
"under",
"tid",
"is",
"told",
"to",
"clean",
"all",
"data",
"and",
"then",
"it",
"is",
"deleted",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L497-L522 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.open | def open(self, tid, flags):
"""
File open. ``YTStor`` object associated with this file is initialised and written to ``self.fds``.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
... | python | def open(self, tid, flags):
"""
File open. ``YTStor`` object associated with this file is initialised and written to ``self.fds``.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
... | [
"def",
"open",
"(",
"self",
",",
"tid",
",",
"flags",
")",
":",
"pt",
"=",
"self",
".",
"PathType",
".",
"get",
"(",
"tid",
")",
"if",
"pt",
"is",
"not",
"self",
".",
"PathType",
".",
"file",
"and",
"pt",
"is",
"not",
"self",
".",
"PathType",
"... | File open. ``YTStor`` object associated with this file is initialised and written to ``self.fds``.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
flags : int
File open mode. Read-... | [
"File",
"open",
".",
"YTStor",
"object",
"associated",
"with",
"this",
"file",
"is",
"initialised",
"and",
"written",
"to",
"self",
".",
"fds",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L539-L589 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.write | def write(self, tid, data, offset, fh):
"""
Write operation. Applicable only for control files - updateResults is called.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
data ... | python | def write(self, tid, data, offset, fh):
"""
Write operation. Applicable only for control files - updateResults is called.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
data ... | [
"def",
"write",
"(",
"self",
",",
"tid",
",",
"data",
",",
"offset",
",",
"fh",
")",
":",
"if",
"tid",
"[",
"1",
"]",
"==",
"\" next\"",
":",
"d",
"=",
"True",
"elif",
"tid",
"[",
"1",
"]",
"==",
"\" prev\"",
":",
"d",
"=",
"False",
"else",
"... | Write operation. Applicable only for control files - updateResults is called.
Parameters
----------
tid : str
Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator.
data : bytes
Ignored.
offset : int
... | [
"Write",
"operation",
".",
"Applicable",
"only",
"for",
"control",
"files",
"-",
"updateResults",
"is",
"called",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L633-L669 | train |
rasguanabana/ytfs | ytfs/ytfs.py | YTFS.release | def release(self, tid, fh):
"""
Close file. Descriptor is removed from ``self.fds``.
Parameters
----------
tid : str
Path to file. Ignored.
fh : int
File descriptor to release.
"""
try:
try:
self.fds[f... | python | def release(self, tid, fh):
"""
Close file. Descriptor is removed from ``self.fds``.
Parameters
----------
tid : str
Path to file. Ignored.
fh : int
File descriptor to release.
"""
try:
try:
self.fds[f... | [
"def",
"release",
"(",
"self",
",",
"tid",
",",
"fh",
")",
":",
"try",
":",
"try",
":",
"self",
".",
"fds",
"[",
"fh",
"]",
".",
"unregisterHandler",
"(",
"fh",
")",
"except",
"AttributeError",
":",
"pass",
"del",
"self",
".",
"fds",
"[",
"fh",
"... | Close file. Descriptor is removed from ``self.fds``.
Parameters
----------
tid : str
Path to file. Ignored.
fh : int
File descriptor to release. | [
"Close",
"file",
".",
"Descriptor",
"is",
"removed",
"from",
"self",
".",
"fds",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/ytfs.py#L672-L697 | train |
rasguanabana/ytfs | ytfs/range_t.py | range_t.__match_l | def __match_l(self, k, _set):
"""
Method for searching subranges from `_set` that overlap on `k` range.
Parameters
----------
k : tuple or list or range
Range for which we search overlapping subranges from `_set`.
_set : set
Subranges set.
... | python | def __match_l(self, k, _set):
"""
Method for searching subranges from `_set` that overlap on `k` range.
Parameters
----------
k : tuple or list or range
Range for which we search overlapping subranges from `_set`.
_set : set
Subranges set.
... | [
"def",
"__match_l",
"(",
"self",
",",
"k",
",",
"_set",
")",
":",
"return",
"{",
"r",
"for",
"r",
"in",
"_set",
"if",
"k",
"[",
"0",
"]",
"in",
"range",
"(",
"*",
"r",
")",
"or",
"k",
"[",
"1",
"]",
"in",
"range",
"(",
"*",
"r",
")",
"or"... | Method for searching subranges from `_set` that overlap on `k` range.
Parameters
----------
k : tuple or list or range
Range for which we search overlapping subranges from `_set`.
_set : set
Subranges set.
Returns
-------
matched : set
... | [
"Method",
"for",
"searching",
"subranges",
"from",
"_set",
"that",
"overlap",
"on",
"k",
"range",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/range_t.py#L39-L57 | train |
rasguanabana/ytfs | ytfs/range_t.py | range_t.contains | def contains(self, val):
"""
Check if given value or range is present.
Parameters
----------
val : int or tuple or list or range
Range or integer being checked.
Returns
-------
retlen : int
Length of overlapping with `val` subran... | python | def contains(self, val):
"""
Check if given value or range is present.
Parameters
----------
val : int or tuple or list or range
Range or integer being checked.
Returns
-------
retlen : int
Length of overlapping with `val` subran... | [
"def",
"contains",
"(",
"self",
",",
"val",
")",
":",
"(",
"start",
",",
"end",
")",
"=",
"self",
".",
"__val_convert",
"(",
"val",
")",
"retlen",
"=",
"0",
"for",
"r",
"in",
"self",
".",
"__has",
":",
"if",
"start",
"<",
"r",
"[",
"1",
"]",
... | Check if given value or range is present.
Parameters
----------
val : int or tuple or list or range
Range or integer being checked.
Returns
-------
retlen : int
Length of overlapping with `val` subranges. | [
"Check",
"if",
"given",
"value",
"or",
"range",
"is",
"present",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/range_t.py#L118-L141 | train |
rasguanabana/ytfs | ytfs/range_t.py | range_t.__add | def __add(self, val):
"""
Helper method for range addition. It is allowed to add only one compact subrange or ``range_t`` object at once.
Parameters
----------
val : int or tuple or list or range
Integer or range to add.
Returns
-------
__ha... | python | def __add(self, val):
"""
Helper method for range addition. It is allowed to add only one compact subrange or ``range_t`` object at once.
Parameters
----------
val : int or tuple or list or range
Integer or range to add.
Returns
-------
__ha... | [
"def",
"__add",
"(",
"self",
",",
"val",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"range_t",
")",
":",
"val",
"=",
"{",
"self",
".",
"__val_convert",
"(",
"val",
")",
"}",
"else",
":",
"val",
"=",
"val",
".",
"toset",
"(",
")",
"__... | Helper method for range addition. It is allowed to add only one compact subrange or ``range_t`` object at once.
Parameters
----------
val : int or tuple or list or range
Integer or range to add.
Returns
-------
__has : set
``self.__has`` extended... | [
"Helper",
"method",
"for",
"range",
"addition",
".",
"It",
"is",
"allowed",
"to",
"add",
"only",
"one",
"compact",
"subrange",
"or",
"range_t",
"object",
"at",
"once",
"."
] | 67dd9536a1faea09c8394f697529124f78e77cfa | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/range_t.py#L195-L221 | train |
proycon/pynlpl | pynlpl/evaluation.py | AbstractExperiment.done | def done(self, warn=True):
"""Is the subprocess done?"""
if not self.process:
raise Exception("Not implemented yet or process not started yet, make sure to overload the done() method in your Experiment class")
self.process.poll()
if self.process.returncode == None:
... | python | def done(self, warn=True):
"""Is the subprocess done?"""
if not self.process:
raise Exception("Not implemented yet or process not started yet, make sure to overload the done() method in your Experiment class")
self.process.poll()
if self.process.returncode == None:
... | [
"def",
"done",
"(",
"self",
",",
"warn",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"process",
":",
"raise",
"Exception",
"(",
"\"Not implemented yet or process not started yet, make sure to overload the done() method in your Experiment class\"",
")",
"self",
".",
... | Is the subprocess done? | [
"Is",
"the",
"subprocess",
"done?"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/evaluation.py#L453-L464 | train |
proycon/pynlpl | pynlpl/formats/giza.py | GizaSentenceAlignment.getalignedtarget | def getalignedtarget(self, index):
"""Returns target range only if source index aligns to a single consecutive range of target tokens."""
targetindices = []
target = None
foundindex = -1
for sourceindex, targetindex in self.alignment:
if sourceindex == index:
... | python | def getalignedtarget(self, index):
"""Returns target range only if source index aligns to a single consecutive range of target tokens."""
targetindices = []
target = None
foundindex = -1
for sourceindex, targetindex in self.alignment:
if sourceindex == index:
... | [
"def",
"getalignedtarget",
"(",
"self",
",",
"index",
")",
":",
"targetindices",
"=",
"[",
"]",
"target",
"=",
"None",
"foundindex",
"=",
"-",
"1",
"for",
"sourceindex",
",",
"targetindex",
"in",
"self",
".",
"alignment",
":",
"if",
"sourceindex",
"==",
... | Returns target range only if source index aligns to a single consecutive range of target tokens. | [
"Returns",
"target",
"range",
"only",
"if",
"source",
"index",
"aligns",
"to",
"a",
"single",
"consecutive",
"range",
"of",
"target",
"tokens",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/giza.py#L108-L126 | train |
proycon/pynlpl | pynlpl/formats/giza.py | WordAlignment.targetword | def targetword(self, index, targetwords, alignment):
"""Return the aligned targetword for a specified index in the source words"""
if alignment[index]:
return targetwords[alignment[index]]
else:
return None | python | def targetword(self, index, targetwords, alignment):
"""Return the aligned targetword for a specified index in the source words"""
if alignment[index]:
return targetwords[alignment[index]]
else:
return None | [
"def",
"targetword",
"(",
"self",
",",
"index",
",",
"targetwords",
",",
"alignment",
")",
":",
"if",
"alignment",
"[",
"index",
"]",
":",
"return",
"targetwords",
"[",
"alignment",
"[",
"index",
"]",
"]",
"else",
":",
"return",
"None"
] | Return the aligned targetword for a specified index in the source words | [
"Return",
"the",
"aligned",
"targetword",
"for",
"a",
"specified",
"index",
"in",
"the",
"source",
"words"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/giza.py#L225-L230 | train |
proycon/pynlpl | pynlpl/formats/giza.py | MultiWordAlignment.targetwords | def targetwords(self, index, targetwords, alignment):
"""Return the aligned targetwords for a specified index in the source words"""
return [ targetwords[x] for x in alignment[index] ] | python | def targetwords(self, index, targetwords, alignment):
"""Return the aligned targetwords for a specified index in the source words"""
return [ targetwords[x] for x in alignment[index] ] | [
"def",
"targetwords",
"(",
"self",
",",
"index",
",",
"targetwords",
",",
"alignment",
")",
":",
"return",
"[",
"targetwords",
"[",
"x",
"]",
"for",
"x",
"in",
"alignment",
"[",
"index",
"]",
"]"
] | Return the aligned targetwords for a specified index in the source words | [
"Return",
"the",
"aligned",
"targetwords",
"for",
"a",
"specified",
"index",
"in",
"the",
"source",
"words"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/giza.py#L274-L276 | train |
proycon/pynlpl | pynlpl/algorithms.py | sum_to_n | def sum_to_n(n, size, limit=None): #from http://stackoverflow.com/questions/2065553/python-get-all-numbers-that-add-up-to-a-number
"""Produce all lists of `size` positive integers in decreasing order
that add up to `n`."""
if size == 1:
yield [n]
return
if limit is None:
limit = ... | python | def sum_to_n(n, size, limit=None): #from http://stackoverflow.com/questions/2065553/python-get-all-numbers-that-add-up-to-a-number
"""Produce all lists of `size` positive integers in decreasing order
that add up to `n`."""
if size == 1:
yield [n]
return
if limit is None:
limit = ... | [
"def",
"sum_to_n",
"(",
"n",
",",
"size",
",",
"limit",
"=",
"None",
")",
":",
"if",
"size",
"==",
"1",
":",
"yield",
"[",
"n",
"]",
"return",
"if",
"limit",
"is",
"None",
":",
"limit",
"=",
"n",
"start",
"=",
"(",
"n",
"+",
"size",
"-",
"1",... | Produce all lists of `size` positive integers in decreasing order
that add up to `n`. | [
"Produce",
"all",
"lists",
"of",
"size",
"positive",
"integers",
"in",
"decreasing",
"order",
"that",
"add",
"up",
"to",
"n",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/algorithms.py#L19-L31 | train |
proycon/pynlpl | pynlpl/formats/cql.py | TokenExpression.nfa | def nfa(self, nextstate):
"""Returns an initial state for an NFA"""
if self.interval:
mininterval, maxinterval = self.interval #pylint: disable=unpacking-non-sequence
nextstate2 = nextstate
for i in range(maxinterval):
state = State(transitions=[(self,... | python | def nfa(self, nextstate):
"""Returns an initial state for an NFA"""
if self.interval:
mininterval, maxinterval = self.interval #pylint: disable=unpacking-non-sequence
nextstate2 = nextstate
for i in range(maxinterval):
state = State(transitions=[(self,... | [
"def",
"nfa",
"(",
"self",
",",
"nextstate",
")",
":",
"if",
"self",
".",
"interval",
":",
"mininterval",
",",
"maxinterval",
"=",
"self",
".",
"interval",
"nextstate2",
"=",
"nextstate",
"for",
"i",
"in",
"range",
"(",
"maxinterval",
")",
":",
"state",
... | Returns an initial state for an NFA | [
"Returns",
"an",
"initial",
"state",
"for",
"an",
"NFA"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/cql.py#L170-L186 | train |
proycon/pynlpl | pynlpl/formats/cql.py | Query.nfa | def nfa(self):
"""convert the expression into an NFA"""
finalstate = State(final=True)
nextstate = finalstate
for tokenexpr in reversed(self):
state = tokenexpr.nfa(nextstate)
nextstate = state
return NFA(state) | python | def nfa(self):
"""convert the expression into an NFA"""
finalstate = State(final=True)
nextstate = finalstate
for tokenexpr in reversed(self):
state = tokenexpr.nfa(nextstate)
nextstate = state
return NFA(state) | [
"def",
"nfa",
"(",
"self",
")",
":",
"finalstate",
"=",
"State",
"(",
"final",
"=",
"True",
")",
"nextstate",
"=",
"finalstate",
"for",
"tokenexpr",
"in",
"reversed",
"(",
"self",
")",
":",
"state",
"=",
"tokenexpr",
".",
"nfa",
"(",
"nextstate",
")",
... | convert the expression into an NFA | [
"convert",
"the",
"expression",
"into",
"an",
"NFA"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/cql.py#L236-L243 | train |
proycon/pynlpl | pynlpl/statistics.py | stddev | def stddev(values, meanval=None): #from AI: A Modern Appproach
"""The standard deviation of a set of values.
Pass in the mean if you already know it."""
if meanval == None: meanval = mean(values)
return math.sqrt( sum([(x - meanval)**2 for x in values]) / (len(values)-1) ) | python | def stddev(values, meanval=None): #from AI: A Modern Appproach
"""The standard deviation of a set of values.
Pass in the mean if you already know it."""
if meanval == None: meanval = mean(values)
return math.sqrt( sum([(x - meanval)**2 for x in values]) / (len(values)-1) ) | [
"def",
"stddev",
"(",
"values",
",",
"meanval",
"=",
"None",
")",
":",
"if",
"meanval",
"==",
"None",
":",
"meanval",
"=",
"mean",
"(",
"values",
")",
"return",
"math",
".",
"sqrt",
"(",
"sum",
"(",
"[",
"(",
"x",
"-",
"meanval",
")",
"**",
"2",
... | The standard deviation of a set of values.
Pass in the mean if you already know it. | [
"The",
"standard",
"deviation",
"of",
"a",
"set",
"of",
"values",
".",
"Pass",
"in",
"the",
"mean",
"if",
"you",
"already",
"know",
"it",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/statistics.py#L588-L592 | train |
proycon/pynlpl | pynlpl/statistics.py | FrequencyList.save | def save(self, filename, addnormalised=False):
"""Save a frequency list to file, can be loaded later using the load method"""
f = io.open(filename,'w',encoding='utf-8')
for line in self.output("\t", addnormalised):
f.write(line + '\n')
f.close() | python | def save(self, filename, addnormalised=False):
"""Save a frequency list to file, can be loaded later using the load method"""
f = io.open(filename,'w',encoding='utf-8')
for line in self.output("\t", addnormalised):
f.write(line + '\n')
f.close() | [
"def",
"save",
"(",
"self",
",",
"filename",
",",
"addnormalised",
"=",
"False",
")",
":",
"f",
"=",
"io",
".",
"open",
"(",
"filename",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"for",
"line",
"in",
"self",
".",
"output",
"(",
"\"\\t\"",
"... | Save a frequency list to file, can be loaded later using the load method | [
"Save",
"a",
"frequency",
"list",
"to",
"file",
"can",
"be",
"loaded",
"later",
"using",
"the",
"load",
"method"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/statistics.py#L64-L69 | train |
proycon/pynlpl | pynlpl/statistics.py | FrequencyList.output | def output(self,delimiter = '\t', addnormalised=False):
"""Print a representation of the frequency list"""
for type, count in self:
if isinstance(type,tuple) or isinstance(type,list):
if addnormalised:
yield " ".join((u(x) for x in type)) + delimiter + str... | python | def output(self,delimiter = '\t', addnormalised=False):
"""Print a representation of the frequency list"""
for type, count in self:
if isinstance(type,tuple) or isinstance(type,list):
if addnormalised:
yield " ".join((u(x) for x in type)) + delimiter + str... | [
"def",
"output",
"(",
"self",
",",
"delimiter",
"=",
"'\\t'",
",",
"addnormalised",
"=",
"False",
")",
":",
"for",
"type",
",",
"count",
"in",
"self",
":",
"if",
"isinstance",
"(",
"type",
",",
"tuple",
")",
"or",
"isinstance",
"(",
"type",
",",
"lis... | Print a representation of the frequency list | [
"Print",
"a",
"representation",
"of",
"the",
"frequency",
"list"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/statistics.py#L182-L199 | train |
proycon/pynlpl | pynlpl/statistics.py | Distribution.entropy | def entropy(self, base = 2):
"""Compute the entropy of the distribution"""
entropy = 0
if not base and self.base: base = self.base
for type in self._dist:
if not base:
entropy += self._dist[type] * -math.log(self._dist[type])
else:
... | python | def entropy(self, base = 2):
"""Compute the entropy of the distribution"""
entropy = 0
if not base and self.base: base = self.base
for type in self._dist:
if not base:
entropy += self._dist[type] * -math.log(self._dist[type])
else:
... | [
"def",
"entropy",
"(",
"self",
",",
"base",
"=",
"2",
")",
":",
"entropy",
"=",
"0",
"if",
"not",
"base",
"and",
"self",
".",
"base",
":",
"base",
"=",
"self",
".",
"base",
"for",
"type",
"in",
"self",
".",
"_dist",
":",
"if",
"not",
"base",
":... | Compute the entropy of the distribution | [
"Compute",
"the",
"entropy",
"of",
"the",
"distribution"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/statistics.py#L270-L279 | train |
proycon/pynlpl | pynlpl/statistics.py | Distribution.output | def output(self,delimiter = '\t', freqlist = None):
"""Generator yielding formatted strings expressing the time and probabily for each item in the distribution"""
for type, prob in self:
if freqlist:
if isinstance(type,list) or isinstance(type, tuple):
yie... | python | def output(self,delimiter = '\t', freqlist = None):
"""Generator yielding formatted strings expressing the time and probabily for each item in the distribution"""
for type, prob in self:
if freqlist:
if isinstance(type,list) or isinstance(type, tuple):
yie... | [
"def",
"output",
"(",
"self",
",",
"delimiter",
"=",
"'\\t'",
",",
"freqlist",
"=",
"None",
")",
":",
"for",
"type",
",",
"prob",
"in",
"self",
":",
"if",
"freqlist",
":",
"if",
"isinstance",
"(",
"type",
",",
"list",
")",
"or",
"isinstance",
"(",
... | Generator yielding formatted strings expressing the time and probabily for each item in the distribution | [
"Generator",
"yielding",
"formatted",
"strings",
"expressing",
"the",
"time",
"and",
"probabily",
"for",
"each",
"item",
"in",
"the",
"distribution"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/statistics.py#L316-L328 | train |
proycon/pynlpl | pynlpl/clients/freeling.py | FreeLingClient.process | def process(self, sourcewords, debug=False):
"""Process a list of words, passing it to the server and realigning the output with the original words"""
if isinstance( sourcewords, list ) or isinstance( sourcewords, tuple ):
sourcewords_s = " ".join(sourcewords)
else:
... | python | def process(self, sourcewords, debug=False):
"""Process a list of words, passing it to the server and realigning the output with the original words"""
if isinstance( sourcewords, list ) or isinstance( sourcewords, tuple ):
sourcewords_s = " ".join(sourcewords)
else:
... | [
"def",
"process",
"(",
"self",
",",
"sourcewords",
",",
"debug",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"sourcewords",
",",
"list",
")",
"or",
"isinstance",
"(",
"sourcewords",
",",
"tuple",
")",
":",
"sourcewords_s",
"=",
"\" \"",
".",
"join",... | Process a list of words, passing it to the server and realigning the output with the original words | [
"Process",
"a",
"list",
"of",
"words",
"passing",
"it",
"to",
"the",
"server",
"and",
"realigning",
"the",
"output",
"with",
"the",
"original",
"words"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/clients/freeling.py#L43-L101 | train |
proycon/pynlpl | pynlpl/formats/folia.py | checkversion | def checkversion(version, REFVERSION=FOLIAVERSION):
"""Checks FoLiA version, returns 1 if the document is newer than the library, -1 if it is older, 0 if it is equal"""
try:
for refversion, docversion in zip([int(x) for x in REFVERSION.split('.')], [int(x) for x in version.split('.')]):
if d... | python | def checkversion(version, REFVERSION=FOLIAVERSION):
"""Checks FoLiA version, returns 1 if the document is newer than the library, -1 if it is older, 0 if it is equal"""
try:
for refversion, docversion in zip([int(x) for x in REFVERSION.split('.')], [int(x) for x in version.split('.')]):
if d... | [
"def",
"checkversion",
"(",
"version",
",",
"REFVERSION",
"=",
"FOLIAVERSION",
")",
":",
"try",
":",
"for",
"refversion",
",",
"docversion",
"in",
"zip",
"(",
"[",
"int",
"(",
"x",
")",
"for",
"x",
"in",
"REFVERSION",
".",
"split",
"(",
"'.'",
")",
"... | Checks FoLiA version, returns 1 if the document is newer than the library, -1 if it is older, 0 if it is equal | [
"Checks",
"FoLiA",
"version",
"returns",
"1",
"if",
"the",
"document",
"is",
"newer",
"than",
"the",
"library",
"-",
"1",
"if",
"it",
"is",
"older",
"0",
"if",
"it",
"is",
"equal"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L199-L209 | train |
proycon/pynlpl | pynlpl/formats/folia.py | xmltreefromstring | def xmltreefromstring(s):
"""Internal function, deals with different Python versions, unicode strings versus bytes, and with the leak bug in lxml"""
if sys.version < '3':
#Python 2
if isinstance(s,unicode): #pylint: disable=undefined-variable
s = s.encode('utf-8')
try:
... | python | def xmltreefromstring(s):
"""Internal function, deals with different Python versions, unicode strings versus bytes, and with the leak bug in lxml"""
if sys.version < '3':
#Python 2
if isinstance(s,unicode): #pylint: disable=undefined-variable
s = s.encode('utf-8')
try:
... | [
"def",
"xmltreefromstring",
"(",
"s",
")",
":",
"if",
"sys",
".",
"version",
"<",
"'3'",
":",
"if",
"isinstance",
"(",
"s",
",",
"unicode",
")",
":",
"s",
"=",
"s",
".",
"encode",
"(",
"'utf-8'",
")",
"try",
":",
"return",
"ElementTree",
".",
"pars... | Internal function, deals with different Python versions, unicode strings versus bytes, and with the leak bug in lxml | [
"Internal",
"function",
"deals",
"with",
"different",
"Python",
"versions",
"unicode",
"strings",
"versus",
"bytes",
"and",
"with",
"the",
"leak",
"bug",
"in",
"lxml"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L543-L560 | train |
proycon/pynlpl | pynlpl/formats/folia.py | xmltreefromfile | def xmltreefromfile(filename):
"""Internal function to read an XML file"""
try:
return ElementTree.parse(filename, ElementTree.XMLParser(collect_ids=False))
except TypeError:
return ElementTree.parse(filename, ElementTree.XMLParser()) | python | def xmltreefromfile(filename):
"""Internal function to read an XML file"""
try:
return ElementTree.parse(filename, ElementTree.XMLParser(collect_ids=False))
except TypeError:
return ElementTree.parse(filename, ElementTree.XMLParser()) | [
"def",
"xmltreefromfile",
"(",
"filename",
")",
":",
"try",
":",
"return",
"ElementTree",
".",
"parse",
"(",
"filename",
",",
"ElementTree",
".",
"XMLParser",
"(",
"collect_ids",
"=",
"False",
")",
")",
"except",
"TypeError",
":",
"return",
"ElementTree",
".... | Internal function to read an XML file | [
"Internal",
"function",
"to",
"read",
"an",
"XML",
"file"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L562-L567 | train |
proycon/pynlpl | pynlpl/formats/folia.py | commonancestors | def commonancestors(Class, *args):
"""Generator function to find common ancestors of a particular type for any two or more FoLiA element instances.
The function produces all common ancestors of the type specified, starting from the closest one up to the most distant one.
Parameters:
Class: The typ... | python | def commonancestors(Class, *args):
"""Generator function to find common ancestors of a particular type for any two or more FoLiA element instances.
The function produces all common ancestors of the type specified, starting from the closest one up to the most distant one.
Parameters:
Class: The typ... | [
"def",
"commonancestors",
"(",
"Class",
",",
"*",
"args",
")",
":",
"commonancestors",
"=",
"None",
"for",
"sibling",
"in",
"args",
":",
"ancestors",
"=",
"list",
"(",
"sibling",
".",
"ancestors",
"(",
"Class",
")",
")",
"if",
"commonancestors",
"is",
"N... | Generator function to find common ancestors of a particular type for any two or more FoLiA element instances.
The function produces all common ancestors of the type specified, starting from the closest one up to the most distant one.
Parameters:
Class: The type of ancestor to find, should be the :clas... | [
"Generator",
"function",
"to",
"find",
"common",
"ancestors",
"of",
"a",
"particular",
"type",
"for",
"any",
"two",
"or",
"more",
"FoLiA",
"element",
"instances",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L594-L621 | train |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.description | def description(self):
"""Obtain the description associated with the element.
Raises:
:class:`NoSuchAnnotation` if there is no associated description."""
for e in self:
if isinstance(e, Description):
return e.value
raise NoSuchAnnotation | python | def description(self):
"""Obtain the description associated with the element.
Raises:
:class:`NoSuchAnnotation` if there is no associated description."""
for e in self:
if isinstance(e, Description):
return e.value
raise NoSuchAnnotation | [
"def",
"description",
"(",
"self",
")",
":",
"for",
"e",
"in",
"self",
":",
"if",
"isinstance",
"(",
"e",
",",
"Description",
")",
":",
"return",
"e",
".",
"value",
"raise",
"NoSuchAnnotation"
] | Obtain the description associated with the element.
Raises:
:class:`NoSuchAnnotation` if there is no associated description. | [
"Obtain",
"the",
"description",
"associated",
"with",
"the",
"element",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L722-L730 | train |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.findcorrectionhandling | def findcorrectionhandling(self, cls):
"""Find the proper correctionhandling given a textclass by looking in the underlying corrections where it is reused"""
if cls == "current":
return CorrectionHandling.CURRENT
elif cls == "original":
return CorrectionHandling.ORIGINAL ... | python | def findcorrectionhandling(self, cls):
"""Find the proper correctionhandling given a textclass by looking in the underlying corrections where it is reused"""
if cls == "current":
return CorrectionHandling.CURRENT
elif cls == "original":
return CorrectionHandling.ORIGINAL ... | [
"def",
"findcorrectionhandling",
"(",
"self",
",",
"cls",
")",
":",
"if",
"cls",
"==",
"\"current\"",
":",
"return",
"CorrectionHandling",
".",
"CURRENT",
"elif",
"cls",
"==",
"\"original\"",
":",
"return",
"CorrectionHandling",
".",
"ORIGINAL",
"else",
":",
"... | Find the proper correctionhandling given a textclass by looking in the underlying corrections where it is reused | [
"Find",
"the",
"proper",
"correctionhandling",
"given",
"a",
"textclass",
"by",
"looking",
"in",
"the",
"underlying",
"corrections",
"where",
"it",
"is",
"reused"
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L774-L826 | train |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.textvalidation | def textvalidation(self, warnonly=None):
"""Run text validation on this element. Checks whether any text redundancy is consistent and whether offsets are valid.
Parameters:
warnonly (bool): Warn only (True) or raise exceptions (False). If set to None then this value will be determined based... | python | def textvalidation(self, warnonly=None):
"""Run text validation on this element. Checks whether any text redundancy is consistent and whether offsets are valid.
Parameters:
warnonly (bool): Warn only (True) or raise exceptions (False). If set to None then this value will be determined based... | [
"def",
"textvalidation",
"(",
"self",
",",
"warnonly",
"=",
"None",
")",
":",
"if",
"warnonly",
"is",
"None",
"and",
"self",
".",
"doc",
"and",
"self",
".",
"doc",
".",
"version",
":",
"warnonly",
"=",
"(",
"checkversion",
"(",
"self",
".",
"doc",
".... | Run text validation on this element. Checks whether any text redundancy is consistent and whether offsets are valid.
Parameters:
warnonly (bool): Warn only (True) or raise exceptions (False). If set to None then this value will be determined based on the document's FoLiA version (Warn only before F... | [
"Run",
"text",
"validation",
"on",
"this",
"element",
".",
"Checks",
"whether",
"any",
"text",
"redundancy",
"is",
"consistent",
"and",
"whether",
"offsets",
"are",
"valid",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L829-L873 | train |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.speech_speaker | def speech_speaker(self):
"""Retrieves the speaker of the audio or video file associated with the element.
The source is inherited from ancestor elements if none is specified. For this reason, always use this method rather than access the ``src`` attribute directly.
Returns:
str or... | python | def speech_speaker(self):
"""Retrieves the speaker of the audio or video file associated with the element.
The source is inherited from ancestor elements if none is specified. For this reason, always use this method rather than access the ``src`` attribute directly.
Returns:
str or... | [
"def",
"speech_speaker",
"(",
"self",
")",
":",
"if",
"self",
".",
"speaker",
":",
"return",
"self",
".",
"speaker",
"elif",
"self",
".",
"parent",
":",
"return",
"self",
".",
"parent",
".",
"speech_speaker",
"(",
")",
"else",
":",
"return",
"None"
] | Retrieves the speaker of the audio or video file associated with the element.
The source is inherited from ancestor elements if none is specified. For this reason, always use this method rather than access the ``src`` attribute directly.
Returns:
str or None if not found | [
"Retrieves",
"the",
"speaker",
"of",
"the",
"audio",
"or",
"video",
"file",
"associated",
"with",
"the",
"element",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1004-L1017 | train |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.feat | def feat(self,subset):
"""Obtain the feature class value of the specific subset.
If a feature occurs multiple times, the values will be returned in a list.
Example::
sense = word.annotation(folia.Sense)
synset = sense.feat('synset')
Returns:
str or... | python | def feat(self,subset):
"""Obtain the feature class value of the specific subset.
If a feature occurs multiple times, the values will be returned in a list.
Example::
sense = word.annotation(folia.Sense)
synset = sense.feat('synset')
Returns:
str or... | [
"def",
"feat",
"(",
"self",
",",
"subset",
")",
":",
"r",
"=",
"None",
"for",
"f",
"in",
"self",
":",
"if",
"isinstance",
"(",
"f",
",",
"Feature",
")",
"and",
"f",
".",
"subset",
"==",
"subset",
":",
"if",
"r",
":",
"if",
"isinstance",
"(",
"r... | Obtain the feature class value of the specific subset.
If a feature occurs multiple times, the values will be returned in a list.
Example::
sense = word.annotation(folia.Sense)
synset = sense.feat('synset')
Returns:
str or list | [
"Obtain",
"the",
"feature",
"class",
"value",
"of",
"the",
"specific",
"subset",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1114-L1140 | train |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.copy | def copy(self, newdoc=None, idsuffix=""):
"""Make a deep copy of this element and all its children.
Parameters:
newdoc (:class:`Document`): The document the copy should be associated with.
idsuffix (str or bool): If set to a string, the ID of the copy will be append with this (p... | python | def copy(self, newdoc=None, idsuffix=""):
"""Make a deep copy of this element and all its children.
Parameters:
newdoc (:class:`Document`): The document the copy should be associated with.
idsuffix (str or bool): If set to a string, the ID of the copy will be append with this (p... | [
"def",
"copy",
"(",
"self",
",",
"newdoc",
"=",
"None",
",",
"idsuffix",
"=",
"\"\"",
")",
":",
"if",
"idsuffix",
"is",
"True",
":",
"idsuffix",
"=",
"\".copy.\"",
"+",
"\"%08x\"",
"%",
"random",
".",
"getrandbits",
"(",
"32",
")",
"c",
"=",
"deepcop... | Make a deep copy of this element and all its children.
Parameters:
newdoc (:class:`Document`): The document the copy should be associated with.
idsuffix (str or bool): If set to a string, the ID of the copy will be append with this (prevents duplicate IDs when making copies for the same... | [
"Make",
"a",
"deep",
"copy",
"of",
"this",
"element",
"and",
"all",
"its",
"children",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1234-L1250 | train |
proycon/pynlpl | pynlpl/formats/folia.py | AbstractElement.copychildren | def copychildren(self, newdoc=None, idsuffix=""):
"""Generator creating a deep copy of the children of this element.
Invokes :meth:`copy` on all children, parameters are the same.
"""
if idsuffix is True: idsuffix = ".copy." + "%08x" % random.getrandbits(32) #random 32-bit hash for each... | python | def copychildren(self, newdoc=None, idsuffix=""):
"""Generator creating a deep copy of the children of this element.
Invokes :meth:`copy` on all children, parameters are the same.
"""
if idsuffix is True: idsuffix = ".copy." + "%08x" % random.getrandbits(32) #random 32-bit hash for each... | [
"def",
"copychildren",
"(",
"self",
",",
"newdoc",
"=",
"None",
",",
"idsuffix",
"=",
"\"\"",
")",
":",
"if",
"idsuffix",
"is",
"True",
":",
"idsuffix",
"=",
"\".copy.\"",
"+",
"\"%08x\"",
"%",
"random",
".",
"getrandbits",
"(",
"32",
")",
"for",
"c",
... | Generator creating a deep copy of the children of this element.
Invokes :meth:`copy` on all children, parameters are the same. | [
"Generator",
"creating",
"a",
"deep",
"copy",
"of",
"the",
"children",
"of",
"this",
"element",
"."
] | 7707f69a91caaa6cde037f0d0379f1d42500a68b | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L1252-L1260 | train |
noxdafox/clipspy | clips/classes.py | ClassSlot.public | def public(self):
"""True if the Slot is public."""
return bool(lib.EnvSlotPublicP(self._env, self._cls, self._name)) | python | def public(self):
"""True if the Slot is public."""
return bool(lib.EnvSlotPublicP(self._env, self._cls, self._name)) | [
"def",
"public",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"lib",
".",
"EnvSlotPublicP",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_name",
")",
")"
] | True if the Slot is public. | [
"True",
"if",
"the",
"Slot",
"is",
"public",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L441-L443 | train |
noxdafox/clipspy | clips/classes.py | ClassSlot.initializable | def initializable(self):
"""True if the Slot is initializable."""
return bool(lib.EnvSlotInitableP(self._env, self._cls, self._name)) | python | def initializable(self):
"""True if the Slot is initializable."""
return bool(lib.EnvSlotInitableP(self._env, self._cls, self._name)) | [
"def",
"initializable",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"lib",
".",
"EnvSlotInitableP",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_name",
")",
")"
] | True if the Slot is initializable. | [
"True",
"if",
"the",
"Slot",
"is",
"initializable",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L446-L448 | train |
noxdafox/clipspy | clips/classes.py | ClassSlot.writable | def writable(self):
"""True if the Slot is writable."""
return bool(lib.EnvSlotWritableP(self._env, self._cls, self._name)) | python | def writable(self):
"""True if the Slot is writable."""
return bool(lib.EnvSlotWritableP(self._env, self._cls, self._name)) | [
"def",
"writable",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"lib",
".",
"EnvSlotWritableP",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_name",
")",
")"
] | True if the Slot is writable. | [
"True",
"if",
"the",
"Slot",
"is",
"writable",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L451-L453 | train |
noxdafox/clipspy | clips/classes.py | ClassSlot.accessible | def accessible(self):
"""True if the Slot is directly accessible."""
return bool(lib.EnvSlotDirectAccessP(self._env, self._cls, self._name)) | python | def accessible(self):
"""True if the Slot is directly accessible."""
return bool(lib.EnvSlotDirectAccessP(self._env, self._cls, self._name)) | [
"def",
"accessible",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"lib",
".",
"EnvSlotDirectAccessP",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_name",
")",
")"
] | True if the Slot is directly accessible. | [
"True",
"if",
"the",
"Slot",
"is",
"directly",
"accessible",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L456-L458 | train |
noxdafox/clipspy | clips/classes.py | ClassSlot.sources | def sources(self):
"""A tuple containing the names of the Class sources for this Slot.
The Python equivalent of the CLIPS slot-sources function.
"""
data = clips.data.DataObject(self._env)
lib.EnvSlotSources(self._env, self._cls, self._name, data.byref)
return tuple(d... | python | def sources(self):
"""A tuple containing the names of the Class sources for this Slot.
The Python equivalent of the CLIPS slot-sources function.
"""
data = clips.data.DataObject(self._env)
lib.EnvSlotSources(self._env, self._cls, self._name, data.byref)
return tuple(d... | [
"def",
"sources",
"(",
"self",
")",
":",
"data",
"=",
"clips",
".",
"data",
".",
"DataObject",
"(",
"self",
".",
"_env",
")",
"lib",
".",
"EnvSlotSources",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_name",
",",
"data",
... | A tuple containing the names of the Class sources for this Slot.
The Python equivalent of the CLIPS slot-sources function. | [
"A",
"tuple",
"containing",
"the",
"names",
"of",
"the",
"Class",
"sources",
"for",
"this",
"Slot",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L474-L484 | train |
noxdafox/clipspy | clips/classes.py | ClassSlot.facets | def facets(self):
"""A tuple containing the facets for this Slot.
The Python equivalent of the CLIPS slot-facets function.
"""
data = clips.data.DataObject(self._env)
lib.EnvSlotFacets(self._env, self._cls, self._name, data.byref)
return tuple(data.value) if isinstanc... | python | def facets(self):
"""A tuple containing the facets for this Slot.
The Python equivalent of the CLIPS slot-facets function.
"""
data = clips.data.DataObject(self._env)
lib.EnvSlotFacets(self._env, self._cls, self._name, data.byref)
return tuple(data.value) if isinstanc... | [
"def",
"facets",
"(",
"self",
")",
":",
"data",
"=",
"clips",
".",
"data",
".",
"DataObject",
"(",
"self",
".",
"_env",
")",
"lib",
".",
"EnvSlotFacets",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_name",
",",
"data",
... | A tuple containing the facets for this Slot.
The Python equivalent of the CLIPS slot-facets function. | [
"A",
"tuple",
"containing",
"the",
"facets",
"for",
"this",
"Slot",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L500-L510 | train |
noxdafox/clipspy | clips/classes.py | ClassSlot.allowed_classes | def allowed_classes(self):
"""Iterate over the allowed classes for this slot.
The Python equivalent of the CLIPS slot-allowed-classes function.
"""
data = clips.data.DataObject(self._env)
lib.EnvSlotAllowedClasses(
self._env, self._cls, self._name, data.byref)
... | python | def allowed_classes(self):
"""Iterate over the allowed classes for this slot.
The Python equivalent of the CLIPS slot-allowed-classes function.
"""
data = clips.data.DataObject(self._env)
lib.EnvSlotAllowedClasses(
self._env, self._cls, self._name, data.byref)
... | [
"def",
"allowed_classes",
"(",
"self",
")",
":",
"data",
"=",
"clips",
".",
"data",
".",
"DataObject",
"(",
"self",
".",
"_env",
")",
"lib",
".",
"EnvSlotAllowedClasses",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_name",
... | Iterate over the allowed classes for this slot.
The Python equivalent of the CLIPS slot-allowed-classes function. | [
"Iterate",
"over",
"the",
"allowed",
"classes",
"for",
"this",
"slot",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L554-L567 | train |
noxdafox/clipspy | clips/classes.py | Instance.name | def name(self):
"""Instance name."""
return ffi.string(lib.EnvGetInstanceName(self._env, self._ist)).decode() | python | def name(self):
"""Instance name."""
return ffi.string(lib.EnvGetInstanceName(self._env, self._ist)).decode() | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"ffi",
".",
"string",
"(",
"lib",
".",
"EnvGetInstanceName",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_ist",
")",
")",
".",
"decode",
"(",
")"
] | Instance name. | [
"Instance",
"name",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L627-L629 | train |
noxdafox/clipspy | clips/classes.py | Instance.instance_class | def instance_class(self):
"""Instance class."""
return Class(self._env, lib.EnvGetInstanceClass(self._env, self._ist)) | python | def instance_class(self):
"""Instance class."""
return Class(self._env, lib.EnvGetInstanceClass(self._env, self._ist)) | [
"def",
"instance_class",
"(",
"self",
")",
":",
"return",
"Class",
"(",
"self",
".",
"_env",
",",
"lib",
".",
"EnvGetInstanceClass",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_ist",
")",
")"
] | Instance class. | [
"Instance",
"class",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L632-L634 | train |
noxdafox/clipspy | clips/classes.py | Instance.send | def send(self, message, arguments=None):
"""Send a message to the Instance.
Message arguments must be provided as a string.
"""
output = clips.data.DataObject(self._env)
instance = clips.data.DataObject(
self._env, dtype=CLIPSType.INSTANCE_ADDRESS)
instance.... | python | def send(self, message, arguments=None):
"""Send a message to the Instance.
Message arguments must be provided as a string.
"""
output = clips.data.DataObject(self._env)
instance = clips.data.DataObject(
self._env, dtype=CLIPSType.INSTANCE_ADDRESS)
instance.... | [
"def",
"send",
"(",
"self",
",",
"message",
",",
"arguments",
"=",
"None",
")",
":",
"output",
"=",
"clips",
".",
"data",
".",
"DataObject",
"(",
"self",
".",
"_env",
")",
"instance",
"=",
"clips",
".",
"data",
".",
"DataObject",
"(",
"self",
".",
... | Send a message to the Instance.
Message arguments must be provided as a string. | [
"Send",
"a",
"message",
"to",
"the",
"Instance",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L636-L652 | train |
noxdafox/clipspy | clips/classes.py | Instance.delete | def delete(self):
"""Delete the instance."""
if lib.EnvDeleteInstance(self._env, self._ist) != 1:
raise CLIPSError(self._env) | python | def delete(self):
"""Delete the instance."""
if lib.EnvDeleteInstance(self._env, self._ist) != 1:
raise CLIPSError(self._env) | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"lib",
".",
"EnvDeleteInstance",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_ist",
")",
"!=",
"1",
":",
"raise",
"CLIPSError",
"(",
"self",
".",
"_env",
")"
] | Delete the instance. | [
"Delete",
"the",
"instance",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L654-L657 | train |
noxdafox/clipspy | clips/classes.py | Instance.unmake | def unmake(self):
"""This method is equivalent to delete except that it uses
message-passing instead of directly deleting the instance.
"""
if lib.EnvUnmakeInstance(self._env, self._ist) != 1:
raise CLIPSError(self._env) | python | def unmake(self):
"""This method is equivalent to delete except that it uses
message-passing instead of directly deleting the instance.
"""
if lib.EnvUnmakeInstance(self._env, self._ist) != 1:
raise CLIPSError(self._env) | [
"def",
"unmake",
"(",
"self",
")",
":",
"if",
"lib",
".",
"EnvUnmakeInstance",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_ist",
")",
"!=",
"1",
":",
"raise",
"CLIPSError",
"(",
"self",
".",
"_env",
")"
] | This method is equivalent to delete except that it uses
message-passing instead of directly deleting the instance. | [
"This",
"method",
"is",
"equivalent",
"to",
"delete",
"except",
"that",
"it",
"uses",
"message",
"-",
"passing",
"instead",
"of",
"directly",
"deleting",
"the",
"instance",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L659-L665 | train |
noxdafox/clipspy | clips/classes.py | MessageHandler.name | def name(self):
"""MessageHandler name."""
return ffi.string(lib.EnvGetDefmessageHandlerName(
self._env, self._cls, self._idx)).decode() | python | def name(self):
"""MessageHandler name."""
return ffi.string(lib.EnvGetDefmessageHandlerName(
self._env, self._cls, self._idx)).decode() | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"ffi",
".",
"string",
"(",
"lib",
".",
"EnvGetDefmessageHandlerName",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_idx",
")",
")",
".",
"decode",
"(",
")"
] | MessageHandler name. | [
"MessageHandler",
"name",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L700-L703 | train |
noxdafox/clipspy | clips/classes.py | MessageHandler.type | def type(self):
"""MessageHandler type."""
return ffi.string(lib.EnvGetDefmessageHandlerType(
self._env, self._cls, self._idx)).decode() | python | def type(self):
"""MessageHandler type."""
return ffi.string(lib.EnvGetDefmessageHandlerType(
self._env, self._cls, self._idx)).decode() | [
"def",
"type",
"(",
"self",
")",
":",
"return",
"ffi",
".",
"string",
"(",
"lib",
".",
"EnvGetDefmessageHandlerType",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_idx",
")",
")",
".",
"decode",
"(",
")"
] | MessageHandler type. | [
"MessageHandler",
"type",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L706-L709 | train |
noxdafox/clipspy | clips/classes.py | MessageHandler.deletable | def deletable(self):
"""True if the MessageHandler can be deleted."""
return bool(lib.EnvIsDefmessageHandlerDeletable(
self._env, self._cls, self._idx)) | python | def deletable(self):
"""True if the MessageHandler can be deleted."""
return bool(lib.EnvIsDefmessageHandlerDeletable(
self._env, self._cls, self._idx)) | [
"def",
"deletable",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"lib",
".",
"EnvIsDefmessageHandlerDeletable",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_idx",
")",
")"
] | True if the MessageHandler can be deleted. | [
"True",
"if",
"the",
"MessageHandler",
"can",
"be",
"deleted",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L724-L727 | train |
noxdafox/clipspy | clips/classes.py | MessageHandler.undefine | def undefine(self):
"""Undefine the MessageHandler.
Python equivalent of the CLIPS undefmessage-handler command.
The object becomes unusable after this method has been called.
"""
if lib.EnvUndefmessageHandler(self._env, self._cls, self._idx) != 1:
raise CLIPSError... | python | def undefine(self):
"""Undefine the MessageHandler.
Python equivalent of the CLIPS undefmessage-handler command.
The object becomes unusable after this method has been called.
"""
if lib.EnvUndefmessageHandler(self._env, self._cls, self._idx) != 1:
raise CLIPSError... | [
"def",
"undefine",
"(",
"self",
")",
":",
"if",
"lib",
".",
"EnvUndefmessageHandler",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_cls",
",",
"self",
".",
"_idx",
")",
"!=",
"1",
":",
"raise",
"CLIPSError",
"(",
"self",
".",
"_env",
")",
"self",
"... | Undefine the MessageHandler.
Python equivalent of the CLIPS undefmessage-handler command.
The object becomes unusable after this method has been called. | [
"Undefine",
"the",
"MessageHandler",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/classes.py#L729-L740 | train |
noxdafox/clipspy | clips/environment.py | Environment.load | def load(self, path):
"""Load a set of constructs into the CLIPS data base.
Constructs can be in text or binary format.
The Python equivalent of the CLIPS load command.
"""
try:
self._load_binary(path)
except CLIPSError:
self._load_text(path) | python | def load(self, path):
"""Load a set of constructs into the CLIPS data base.
Constructs can be in text or binary format.
The Python equivalent of the CLIPS load command.
"""
try:
self._load_binary(path)
except CLIPSError:
self._load_text(path) | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"self",
".",
"_load_binary",
"(",
"path",
")",
"except",
"CLIPSError",
":",
"self",
".",
"_load_text",
"(",
"path",
")"
] | Load a set of constructs into the CLIPS data base.
Constructs can be in text or binary format.
The Python equivalent of the CLIPS load command. | [
"Load",
"a",
"set",
"of",
"constructs",
"into",
"the",
"CLIPS",
"data",
"base",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/environment.py#L103-L114 | train |
noxdafox/clipspy | clips/environment.py | Environment.save | def save(self, path, binary=False):
"""Save a set of constructs into the CLIPS data base.
If binary is True, the constructs will be saved in binary format.
The Python equivalent of the CLIPS load command.
"""
if binary:
ret = lib.EnvBsave(self._env, path.encode())
... | python | def save(self, path, binary=False):
"""Save a set of constructs into the CLIPS data base.
If binary is True, the constructs will be saved in binary format.
The Python equivalent of the CLIPS load command.
"""
if binary:
ret = lib.EnvBsave(self._env, path.encode())
... | [
"def",
"save",
"(",
"self",
",",
"path",
",",
"binary",
"=",
"False",
")",
":",
"if",
"binary",
":",
"ret",
"=",
"lib",
".",
"EnvBsave",
"(",
"self",
".",
"_env",
",",
"path",
".",
"encode",
"(",
")",
")",
"else",
":",
"ret",
"=",
"lib",
".",
... | Save a set of constructs into the CLIPS data base.
If binary is True, the constructs will be saved in binary format.
The Python equivalent of the CLIPS load command. | [
"Save",
"a",
"set",
"of",
"constructs",
"into",
"the",
"CLIPS",
"data",
"base",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/environment.py#L126-L139 | train |
noxdafox/clipspy | clips/environment.py | Environment.batch_star | def batch_star(self, path):
"""Evaluate the commands contained in the specific path.
The Python equivalent of the CLIPS batch* command.
"""
if lib.EnvBatchStar(self._env, path.encode()) != 1:
raise CLIPSError(self._env) | python | def batch_star(self, path):
"""Evaluate the commands contained in the specific path.
The Python equivalent of the CLIPS batch* command.
"""
if lib.EnvBatchStar(self._env, path.encode()) != 1:
raise CLIPSError(self._env) | [
"def",
"batch_star",
"(",
"self",
",",
"path",
")",
":",
"if",
"lib",
".",
"EnvBatchStar",
"(",
"self",
".",
"_env",
",",
"path",
".",
"encode",
"(",
")",
")",
"!=",
"1",
":",
"raise",
"CLIPSError",
"(",
"self",
".",
"_env",
")"
] | Evaluate the commands contained in the specific path.
The Python equivalent of the CLIPS batch* command. | [
"Evaluate",
"the",
"commands",
"contained",
"in",
"the",
"specific",
"path",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/environment.py#L141-L148 | train |
noxdafox/clipspy | clips/environment.py | Environment.build | def build(self, construct):
"""Build a single construct in CLIPS.
The Python equivalent of the CLIPS build command.
"""
if lib.EnvBuild(self._env, construct.encode()) != 1:
raise CLIPSError(self._env) | python | def build(self, construct):
"""Build a single construct in CLIPS.
The Python equivalent of the CLIPS build command.
"""
if lib.EnvBuild(self._env, construct.encode()) != 1:
raise CLIPSError(self._env) | [
"def",
"build",
"(",
"self",
",",
"construct",
")",
":",
"if",
"lib",
".",
"EnvBuild",
"(",
"self",
".",
"_env",
",",
"construct",
".",
"encode",
"(",
")",
")",
"!=",
"1",
":",
"raise",
"CLIPSError",
"(",
"self",
".",
"_env",
")"
] | Build a single construct in CLIPS.
The Python equivalent of the CLIPS build command. | [
"Build",
"a",
"single",
"construct",
"in",
"CLIPS",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/environment.py#L150-L157 | train |
noxdafox/clipspy | clips/environment.py | Environment.eval | def eval(self, construct):
"""Evaluate an expression returning its value.
The Python equivalent of the CLIPS eval command.
"""
data = clips.data.DataObject(self._env)
if lib.EnvEval(self._env, construct.encode(), data.byref) != 1:
raise CLIPSError(self._env)
... | python | def eval(self, construct):
"""Evaluate an expression returning its value.
The Python equivalent of the CLIPS eval command.
"""
data = clips.data.DataObject(self._env)
if lib.EnvEval(self._env, construct.encode(), data.byref) != 1:
raise CLIPSError(self._env)
... | [
"def",
"eval",
"(",
"self",
",",
"construct",
")",
":",
"data",
"=",
"clips",
".",
"data",
".",
"DataObject",
"(",
"self",
".",
"_env",
")",
"if",
"lib",
".",
"EnvEval",
"(",
"self",
".",
"_env",
",",
"construct",
".",
"encode",
"(",
")",
",",
"d... | Evaluate an expression returning its value.
The Python equivalent of the CLIPS eval command. | [
"Evaluate",
"an",
"expression",
"returning",
"its",
"value",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/environment.py#L159-L170 | train |
noxdafox/clipspy | clips/environment.py | Environment.define_function | def define_function(self, function, name=None):
"""Define the Python function within the CLIPS environment.
If a name is given, it will be the function name within CLIPS.
Otherwise, the name of the Python function will be used.
The Python function will be accessible within CLIPS via it... | python | def define_function(self, function, name=None):
"""Define the Python function within the CLIPS environment.
If a name is given, it will be the function name within CLIPS.
Otherwise, the name of the Python function will be used.
The Python function will be accessible within CLIPS via it... | [
"def",
"define_function",
"(",
"self",
",",
"function",
",",
"name",
"=",
"None",
")",
":",
"name",
"=",
"name",
"if",
"name",
"is",
"not",
"None",
"else",
"function",
".",
"__name__",
"ENVIRONMENT_DATA",
"[",
"self",
".",
"_env",
"]",
".",
"user_functio... | Define the Python function within the CLIPS environment.
If a name is given, it will be the function name within CLIPS.
Otherwise, the name of the Python function will be used.
The Python function will be accessible within CLIPS via its name
as if it was defined via the `deffunction` c... | [
"Define",
"the",
"Python",
"function",
"within",
"the",
"CLIPS",
"environment",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/environment.py#L188-L202 | train |
noxdafox/clipspy | clips/router.py | Router.activate | def activate(self):
"""Activate the Router."""
if lib.EnvActivateRouter(self._env, self._name.encode()) == 0:
raise RuntimeError("Unable to activate router %s" % self._name) | python | def activate(self):
"""Activate the Router."""
if lib.EnvActivateRouter(self._env, self._name.encode()) == 0:
raise RuntimeError("Unable to activate router %s" % self._name) | [
"def",
"activate",
"(",
"self",
")",
":",
"if",
"lib",
".",
"EnvActivateRouter",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_name",
".",
"encode",
"(",
")",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to activate router %s\"",
"%",
"se... | Activate the Router. | [
"Activate",
"the",
"Router",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/router.py#L45-L48 | train |
noxdafox/clipspy | clips/router.py | Router.deactivate | def deactivate(self):
"""Deactivate the Router."""
if lib.EnvDeactivateRouter(self._env, self._name.encode()) == 0:
raise RuntimeError("Unable to deactivate router %s" % self._name) | python | def deactivate(self):
"""Deactivate the Router."""
if lib.EnvDeactivateRouter(self._env, self._name.encode()) == 0:
raise RuntimeError("Unable to deactivate router %s" % self._name) | [
"def",
"deactivate",
"(",
"self",
")",
":",
"if",
"lib",
".",
"EnvDeactivateRouter",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_name",
".",
"encode",
"(",
")",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to deactivate router %s\"",
"%",... | Deactivate the Router. | [
"Deactivate",
"the",
"Router",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/router.py#L50-L53 | train |
noxdafox/clipspy | clips/router.py | Router.delete | def delete(self):
"""Delete the Router."""
if lib.EnvDeleteRouter(self._env, self._name.encode()) == 0:
raise RuntimeError("Unable to delete router %s" % self._name) | python | def delete(self):
"""Delete the Router."""
if lib.EnvDeleteRouter(self._env, self._name.encode()) == 0:
raise RuntimeError("Unable to delete router %s" % self._name) | [
"def",
"delete",
"(",
"self",
")",
":",
"if",
"lib",
".",
"EnvDeleteRouter",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_name",
".",
"encode",
"(",
")",
")",
"==",
"0",
":",
"raise",
"RuntimeError",
"(",
"\"Unable to delete router %s\"",
"%",
"self",
... | Delete the Router. | [
"Delete",
"the",
"Router",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/router.py#L55-L58 | train |
noxdafox/clipspy | clips/router.py | Router.add_to_environment | def add_to_environment(self, environment):
"""Add the router to the given environment."""
self._env = environment._env
self._userdata = ffi.new_handle(self)
ENVIRONMENT_DATA[self._env].routers[self.name] = self
lib.EnvAddRouterWithContext(
self._env, self._name.enco... | python | def add_to_environment(self, environment):
"""Add the router to the given environment."""
self._env = environment._env
self._userdata = ffi.new_handle(self)
ENVIRONMENT_DATA[self._env].routers[self.name] = self
lib.EnvAddRouterWithContext(
self._env, self._name.enco... | [
"def",
"add_to_environment",
"(",
"self",
",",
"environment",
")",
":",
"self",
".",
"_env",
"=",
"environment",
".",
"_env",
"self",
".",
"_userdata",
"=",
"ffi",
".",
"new_handle",
"(",
"self",
")",
"ENVIRONMENT_DATA",
"[",
"self",
".",
"_env",
"]",
".... | Add the router to the given environment. | [
"Add",
"the",
"router",
"to",
"the",
"given",
"environment",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/router.py#L60-L74 | train |
noxdafox/clipspy | clips/data.py | DataObject.value | def value(self):
"""Return the DATA_OBJECT stored value."""
dtype = lib.get_data_type(self._data)
dvalue = lib.get_data_value(self._data)
if dvalue == ffi.NULL:
return None
return self.python_value(dtype, dvalue) | python | def value(self):
"""Return the DATA_OBJECT stored value."""
dtype = lib.get_data_type(self._data)
dvalue = lib.get_data_value(self._data)
if dvalue == ffi.NULL:
return None
return self.python_value(dtype, dvalue) | [
"def",
"value",
"(",
"self",
")",
":",
"dtype",
"=",
"lib",
".",
"get_data_type",
"(",
"self",
".",
"_data",
")",
"dvalue",
"=",
"lib",
".",
"get_data_value",
"(",
"self",
".",
"_data",
")",
"if",
"dvalue",
"==",
"ffi",
".",
"NULL",
":",
"return",
... | Return the DATA_OBJECT stored value. | [
"Return",
"the",
"DATA_OBJECT",
"stored",
"value",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/data.py#L58-L66 | train |
noxdafox/clipspy | clips/data.py | DataObject.value | def value(self, value):
"""Sets the DATA_OBJECT stored value."""
dtype = TYPES[type(value)] if self._type is None else self._type
lib.set_data_type(self._data, dtype)
lib.set_data_value(self._data, self.clips_value(value)) | python | def value(self, value):
"""Sets the DATA_OBJECT stored value."""
dtype = TYPES[type(value)] if self._type is None else self._type
lib.set_data_type(self._data, dtype)
lib.set_data_value(self._data, self.clips_value(value)) | [
"def",
"value",
"(",
"self",
",",
"value",
")",
":",
"dtype",
"=",
"TYPES",
"[",
"type",
"(",
"value",
")",
"]",
"if",
"self",
".",
"_type",
"is",
"None",
"else",
"self",
".",
"_type",
"lib",
".",
"set_data_type",
"(",
"self",
".",
"_data",
",",
... | Sets the DATA_OBJECT stored value. | [
"Sets",
"the",
"DATA_OBJECT",
"stored",
"value",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/data.py#L69-L74 | train |
noxdafox/clipspy | clips/data.py | DataObject.python_value | def python_value(self, dtype, dvalue):
"""Convert a CLIPS type into Python."""
try:
return CONVERTERS[dtype](dvalue)
except KeyError:
if dtype == clips.common.CLIPSType.MULTIFIELD:
return self.multifield_to_list()
if dtype == clips.common.CLIPS... | python | def python_value(self, dtype, dvalue):
"""Convert a CLIPS type into Python."""
try:
return CONVERTERS[dtype](dvalue)
except KeyError:
if dtype == clips.common.CLIPSType.MULTIFIELD:
return self.multifield_to_list()
if dtype == clips.common.CLIPS... | [
"def",
"python_value",
"(",
"self",
",",
"dtype",
",",
"dvalue",
")",
":",
"try",
":",
"return",
"CONVERTERS",
"[",
"dtype",
"]",
"(",
"dvalue",
")",
"except",
"KeyError",
":",
"if",
"dtype",
"==",
"clips",
".",
"common",
".",
"CLIPSType",
".",
"MULTIF... | Convert a CLIPS type into Python. | [
"Convert",
"a",
"CLIPS",
"type",
"into",
"Python",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/data.py#L76-L88 | train |
noxdafox/clipspy | clips/data.py | DataObject.clips_value | def clips_value(self, dvalue):
"""Convert a Python type into CLIPS."""
try:
return VALUES[type(dvalue)](self._env, dvalue)
except KeyError:
if isinstance(dvalue, (list, tuple)):
return self.list_to_multifield(dvalue)
if isinstance(dvalue, (clip... | python | def clips_value(self, dvalue):
"""Convert a Python type into CLIPS."""
try:
return VALUES[type(dvalue)](self._env, dvalue)
except KeyError:
if isinstance(dvalue, (list, tuple)):
return self.list_to_multifield(dvalue)
if isinstance(dvalue, (clip... | [
"def",
"clips_value",
"(",
"self",
",",
"dvalue",
")",
":",
"try",
":",
"return",
"VALUES",
"[",
"type",
"(",
"dvalue",
")",
"]",
"(",
"self",
".",
"_env",
",",
"dvalue",
")",
"except",
"KeyError",
":",
"if",
"isinstance",
"(",
"dvalue",
",",
"(",
... | Convert a Python type into CLIPS. | [
"Convert",
"a",
"Python",
"type",
"into",
"CLIPS",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/data.py#L90-L102 | train |
noxdafox/clipspy | clips/agenda.py | Agenda.agenda_changed | def agenda_changed(self):
"""True if any rule activation changes have occurred."""
value = bool(lib.EnvGetAgendaChanged(self._env))
lib.EnvSetAgendaChanged(self._env, int(False))
return value | python | def agenda_changed(self):
"""True if any rule activation changes have occurred."""
value = bool(lib.EnvGetAgendaChanged(self._env))
lib.EnvSetAgendaChanged(self._env, int(False))
return value | [
"def",
"agenda_changed",
"(",
"self",
")",
":",
"value",
"=",
"bool",
"(",
"lib",
".",
"EnvGetAgendaChanged",
"(",
"self",
".",
"_env",
")",
")",
"lib",
".",
"EnvSetAgendaChanged",
"(",
"self",
".",
"_env",
",",
"int",
"(",
"False",
")",
")",
"return",... | True if any rule activation changes have occurred. | [
"True",
"if",
"any",
"rule",
"activation",
"changes",
"have",
"occurred",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L64-L69 | train |
noxdafox/clipspy | clips/agenda.py | Agenda.rules | def rules(self):
"""Iterate over the defined Rules."""
rule = lib.EnvGetNextDefrule(self._env, ffi.NULL)
while rule != ffi.NULL:
yield Rule(self._env, rule)
rule = lib.EnvGetNextDefrule(self._env, rule) | python | def rules(self):
"""Iterate over the defined Rules."""
rule = lib.EnvGetNextDefrule(self._env, ffi.NULL)
while rule != ffi.NULL:
yield Rule(self._env, rule)
rule = lib.EnvGetNextDefrule(self._env, rule) | [
"def",
"rules",
"(",
"self",
")",
":",
"rule",
"=",
"lib",
".",
"EnvGetNextDefrule",
"(",
"self",
".",
"_env",
",",
"ffi",
".",
"NULL",
")",
"while",
"rule",
"!=",
"ffi",
".",
"NULL",
":",
"yield",
"Rule",
"(",
"self",
".",
"_env",
",",
"rule",
"... | Iterate over the defined Rules. | [
"Iterate",
"over",
"the",
"defined",
"Rules",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L125-L132 | train |
noxdafox/clipspy | clips/agenda.py | Agenda.find_rule | def find_rule(self, rule):
"""Find a Rule by name."""
defrule = lib.EnvFindDefrule(self._env, rule.encode())
if defrule == ffi.NULL:
raise LookupError("Rule '%s' not found" % defrule)
return Rule(self._env, defrule) | python | def find_rule(self, rule):
"""Find a Rule by name."""
defrule = lib.EnvFindDefrule(self._env, rule.encode())
if defrule == ffi.NULL:
raise LookupError("Rule '%s' not found" % defrule)
return Rule(self._env, defrule) | [
"def",
"find_rule",
"(",
"self",
",",
"rule",
")",
":",
"defrule",
"=",
"lib",
".",
"EnvFindDefrule",
"(",
"self",
".",
"_env",
",",
"rule",
".",
"encode",
"(",
")",
")",
"if",
"defrule",
"==",
"ffi",
".",
"NULL",
":",
"raise",
"LookupError",
"(",
... | Find a Rule by name. | [
"Find",
"a",
"Rule",
"by",
"name",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L134-L140 | train |
noxdafox/clipspy | clips/agenda.py | Agenda.reorder | def reorder(self, module=None):
"""Reorder the Activations in the Agenda.
If no Module is specified, the current one is used.
To be called after changing the conflict resolution strategy.
"""
module = module._mdl if module is not None else ffi.NULL
lib.EnvReorderAgend... | python | def reorder(self, module=None):
"""Reorder the Activations in the Agenda.
If no Module is specified, the current one is used.
To be called after changing the conflict resolution strategy.
"""
module = module._mdl if module is not None else ffi.NULL
lib.EnvReorderAgend... | [
"def",
"reorder",
"(",
"self",
",",
"module",
"=",
"None",
")",
":",
"module",
"=",
"module",
".",
"_mdl",
"if",
"module",
"is",
"not",
"None",
"else",
"ffi",
".",
"NULL",
"lib",
".",
"EnvReorderAgenda",
"(",
"self",
".",
"_env",
",",
"module",
")"
] | Reorder the Activations in the Agenda.
If no Module is specified, the current one is used.
To be called after changing the conflict resolution strategy. | [
"Reorder",
"the",
"Activations",
"in",
"the",
"Agenda",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L142-L152 | train |
noxdafox/clipspy | clips/agenda.py | Agenda.refresh | def refresh(self, module=None):
"""Recompute the salience values of the Activations on the Agenda
and then reorder the agenda.
The Python equivalent of the CLIPS refresh-agenda command.
If no Module is specified, the current one is used.
"""
module = module._mdl if modu... | python | def refresh(self, module=None):
"""Recompute the salience values of the Activations on the Agenda
and then reorder the agenda.
The Python equivalent of the CLIPS refresh-agenda command.
If no Module is specified, the current one is used.
"""
module = module._mdl if modu... | [
"def",
"refresh",
"(",
"self",
",",
"module",
"=",
"None",
")",
":",
"module",
"=",
"module",
".",
"_mdl",
"if",
"module",
"is",
"not",
"None",
"else",
"ffi",
".",
"NULL",
"lib",
".",
"EnvRefreshAgenda",
"(",
"self",
".",
"_env",
",",
"module",
")"
] | Recompute the salience values of the Activations on the Agenda
and then reorder the agenda.
The Python equivalent of the CLIPS refresh-agenda command.
If no Module is specified, the current one is used. | [
"Recompute",
"the",
"salience",
"values",
"of",
"the",
"Activations",
"on",
"the",
"Agenda",
"and",
"then",
"reorder",
"the",
"agenda",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L154-L164 | train |
noxdafox/clipspy | clips/agenda.py | Agenda.activations | def activations(self):
"""Iterate over the Activations in the Agenda."""
activation = lib.EnvGetNextActivation(self._env, ffi.NULL)
while activation != ffi.NULL:
yield Activation(self._env, activation)
activation = lib.EnvGetNextActivation(self._env, activation) | python | def activations(self):
"""Iterate over the Activations in the Agenda."""
activation = lib.EnvGetNextActivation(self._env, ffi.NULL)
while activation != ffi.NULL:
yield Activation(self._env, activation)
activation = lib.EnvGetNextActivation(self._env, activation) | [
"def",
"activations",
"(",
"self",
")",
":",
"activation",
"=",
"lib",
".",
"EnvGetNextActivation",
"(",
"self",
".",
"_env",
",",
"ffi",
".",
"NULL",
")",
"while",
"activation",
"!=",
"ffi",
".",
"NULL",
":",
"yield",
"Activation",
"(",
"self",
".",
"... | Iterate over the Activations in the Agenda. | [
"Iterate",
"over",
"the",
"Activations",
"in",
"the",
"Agenda",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L166-L173 | train |
noxdafox/clipspy | clips/agenda.py | Agenda.clear | def clear(self):
"""Deletes all activations in the agenda."""
if lib.EnvDeleteActivation(self._env, ffi.NULL) != 1:
raise CLIPSError(self._env) | python | def clear(self):
"""Deletes all activations in the agenda."""
if lib.EnvDeleteActivation(self._env, ffi.NULL) != 1:
raise CLIPSError(self._env) | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"lib",
".",
"EnvDeleteActivation",
"(",
"self",
".",
"_env",
",",
"ffi",
".",
"NULL",
")",
"!=",
"1",
":",
"raise",
"CLIPSError",
"(",
"self",
".",
"_env",
")"
] | Deletes all activations in the agenda. | [
"Deletes",
"all",
"activations",
"in",
"the",
"agenda",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L175-L178 | train |
noxdafox/clipspy | clips/agenda.py | Rule.name | def name(self):
"""Rule name."""
return ffi.string(lib.EnvGetDefruleName(self._env, self._rule)).decode() | python | def name(self):
"""Rule name."""
return ffi.string(lib.EnvGetDefruleName(self._env, self._rule)).decode() | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"ffi",
".",
"string",
"(",
"lib",
".",
"EnvGetDefruleName",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_rule",
")",
")",
".",
"decode",
"(",
")"
] | Rule name. | [
"Rule",
"name",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L228-L230 | train |
noxdafox/clipspy | clips/agenda.py | Rule.module | def module(self):
"""The module in which the Rule is defined.
Python equivalent of the CLIPS defrule-module command.
"""
modname = ffi.string(lib.EnvDefruleModule(self._env, self._rule))
defmodule = lib.EnvFindDefmodule(self._env, modname)
return Module(self._env, defm... | python | def module(self):
"""The module in which the Rule is defined.
Python equivalent of the CLIPS defrule-module command.
"""
modname = ffi.string(lib.EnvDefruleModule(self._env, self._rule))
defmodule = lib.EnvFindDefmodule(self._env, modname)
return Module(self._env, defm... | [
"def",
"module",
"(",
"self",
")",
":",
"modname",
"=",
"ffi",
".",
"string",
"(",
"lib",
".",
"EnvDefruleModule",
"(",
"self",
".",
"_env",
",",
"self",
".",
"_rule",
")",
")",
"defmodule",
"=",
"lib",
".",
"EnvFindDefmodule",
"(",
"self",
".",
"_en... | The module in which the Rule is defined.
Python equivalent of the CLIPS defrule-module command. | [
"The",
"module",
"in",
"which",
"the",
"Rule",
"is",
"defined",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L233-L242 | train |
noxdafox/clipspy | clips/agenda.py | Rule.watch_firings | def watch_firings(self, flag):
"""Whether or not the Rule firings are being watched."""
lib.EnvSetDefruleWatchFirings(self._env, int(flag), self._rule) | python | def watch_firings(self, flag):
"""Whether or not the Rule firings are being watched."""
lib.EnvSetDefruleWatchFirings(self._env, int(flag), self._rule) | [
"def",
"watch_firings",
"(",
"self",
",",
"flag",
")",
":",
"lib",
".",
"EnvSetDefruleWatchFirings",
"(",
"self",
".",
"_env",
",",
"int",
"(",
"flag",
")",
",",
"self",
".",
"_rule",
")"
] | Whether or not the Rule firings are being watched. | [
"Whether",
"or",
"not",
"the",
"Rule",
"firings",
"are",
"being",
"watched",
"."
] | b22d71a6da821c1715d8fa00d7d75cabc09ed364 | https://github.com/noxdafox/clipspy/blob/b22d71a6da821c1715d8fa00d7d75cabc09ed364/clips/agenda.py#L255-L257 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.