hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
4a93d79d729d6505850ab973e59336e879d9b911
jakeogh/Qcodes
qcodes/utils/slack.py
[ "MIT" ]
Python
run
null
def run(self): """ Thread event loop that periodically checks for updates. Can be stopped via :meth:`stop` , after which the Thread is stopped. Returns: None. """ while not self._exit: # Continue event loop if self._is_active: ...
Thread event loop that periodically checks for updates. Can be stopped via :meth:`stop` , after which the Thread is stopped. Returns: None.
Thread event loop that periodically checks for updates. Can be stopped via :meth:`stop` , after which the Thread is stopped.
[ "Thread", "event", "loop", "that", "periodically", "checks", "for", "updates", ".", "Can", "be", "stopped", "via", ":", "meth", ":", "`", "stop", "`", "after", "which", "the", "Thread", "is", "stopped", "." ]
def run(self): while not self._exit: if self._is_active: self.update() sleep(self.interval)
[ "def", "run", "(", "self", ")", ":", "while", "not", "self", ".", "_exit", ":", "if", "self", ".", "_is_active", ":", "self", ".", "update", "(", ")", "sleep", "(", "self", ".", "interval", ")" ]
Thread event loop that periodically checks for updates.
[ "Thread", "event", "loop", "that", "periodically", "checks", "for", "updates", "." ]
[ "\"\"\"\n Thread event loop that periodically checks for updates.\n Can be stopped via :meth:`stop` , after which the Thread is stopped.\n Returns:\n None.\n \"\"\"", "# Continue event loop", "# check for updates" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
4a93d79d729d6505850ab973e59336e879d9b911
jakeogh/Qcodes
qcodes/utils/slack.py
[ "MIT" ]
Python
exit
null
def exit(self): """ Exit event loop, stop Thread. Returns: None """ self._stop = True
Exit event loop, stop Thread. Returns: None
Exit event loop, stop Thread.
[ "Exit", "event", "loop", "stop", "Thread", "." ]
def exit(self): self._stop = True
[ "def", "exit", "(", "self", ")", ":", "self", ".", "_stop", "=", "True" ]
Exit event loop, stop Thread.
[ "Exit", "event", "loop", "stop", "Thread", "." ]
[ "\"\"\"\n Exit event loop, stop Thread.\n Returns:\n None\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
4a93d79d729d6505850ab973e59336e879d9b911
jakeogh/Qcodes
qcodes/utils/slack.py
[ "MIT" ]
Python
user_from_id
<not_specific>
def user_from_id(self, user_id): """ Retrieve user from user id. Args: user_id: Id from which to retrieve user information. Returns: dict: User information. """ return self.slack.users_info(user=user_id)['user']
Retrieve user from user id. Args: user_id: Id from which to retrieve user information. Returns: dict: User information.
Retrieve user from user id.
[ "Retrieve", "user", "from", "user", "id", "." ]
def user_from_id(self, user_id): return self.slack.users_info(user=user_id)['user']
[ "def", "user_from_id", "(", "self", ",", "user_id", ")", ":", "return", "self", ".", "slack", ".", "users_info", "(", "user", "=", "user_id", ")", "[", "'user'", "]" ]
Retrieve user from user id.
[ "Retrieve", "user", "from", "user", "id", "." ]
[ "\"\"\"\n Retrieve user from user id.\n Args:\n user_id: Id from which to retrieve user information.\n\n Returns:\n dict: User information.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "user_id", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "dict" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
4a93d79d729d6505850ab973e59336e879d9b911
jakeogh/Qcodes
qcodes/utils/slack.py
[ "MIT" ]
Python
update
null
def update(self): """ Performs tasks, and checks for new messages. Periodically called from widget update. Returns: None. """ new_tasks = [] for task in self.tasks: task_finished = task() if not task_finished: ne...
Performs tasks, and checks for new messages. Periodically called from widget update. Returns: None.
Performs tasks, and checks for new messages. Periodically called from widget update.
[ "Performs", "tasks", "and", "checks", "for", "new", "messages", ".", "Periodically", "called", "from", "widget", "update", "." ]
def update(self): new_tasks = [] for task in self.tasks: task_finished = task() if not task_finished: new_tasks.append(task) self.tasks = new_tasks new_messages = {} try: new_messages = self.get_new_im_messages() except ...
[ "def", "update", "(", "self", ")", ":", "new_tasks", "=", "[", "]", "for", "task", "in", "self", ".", "tasks", ":", "task_finished", "=", "task", "(", ")", "if", "not", "task_finished", ":", "new_tasks", ".", "append", "(", "task", ")", "self", ".", ...
Performs tasks, and checks for new messages.
[ "Performs", "tasks", "and", "checks", "for", "new", "messages", "." ]
[ "\"\"\"\n Performs tasks, and checks for new messages.\n Periodically called from widget update.\n Returns:\n None.\n \"\"\"", "# catch any timeouts caused by network delays" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
4a93d79d729d6505850ab973e59336e879d9b911
jakeogh/Qcodes
qcodes/utils/slack.py
[ "MIT" ]
Python
handle_messages
null
def handle_messages(self, messages): """ Performs commands depending on messages. This includes adding tasks to be performed during each update. """ for user, user_messages in messages.items(): for message in user_messages: if message.get('user', None)...
Performs commands depending on messages. This includes adding tasks to be performed during each update.
Performs commands depending on messages. This includes adding tasks to be performed during each update.
[ "Performs", "commands", "depending", "on", "messages", ".", "This", "includes", "adding", "tasks", "to", "be", "performed", "during", "each", "update", "." ]
def handle_messages(self, messages): for user, user_messages in messages.items(): for message in user_messages: if message.get('user', None) != self.users[user]['id']: continue channel = self.users[user]['im_id'] command, args, kwar...
[ "def", "handle_messages", "(", "self", ",", "messages", ")", ":", "for", "user", ",", "user_messages", "in", "messages", ".", "items", "(", ")", ":", "for", "message", "in", "user_messages", ":", "if", "message", ".", "get", "(", "'user'", ",", "None", ...
Performs commands depending on messages.
[ "Performs", "commands", "depending", "on", "messages", "." ]
[ "\"\"\"\n Performs commands depending on messages.\n This includes adding tasks to be performed during each update.\n \"\"\"", "# Filter out bot messages", "# Extract command (first word) and possible args", "# Only add channel and Slack if they are explicit", "# kwargs" ]
[ { "param": "self", "type": null }, { "param": "messages", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "messages", "type": null, "docstring": null, "docstring_tokens...
4a93d79d729d6505850ab973e59336e879d9b911
jakeogh/Qcodes
qcodes/utils/slack.py
[ "MIT" ]
Python
add_task
null
def add_task(self, command, *args, channel, **kwargs): """ Add a task to self.tasks, which will be executed during each update Args: command: Task command. *args: Additional args for command. channel: Slack channel (can also be IM channel). **kwarg...
Add a task to self.tasks, which will be executed during each update Args: command: Task command. *args: Additional args for command. channel: Slack channel (can also be IM channel). **kwargs: Additional kwargs for particular. Returns: ...
Add a task to self.tasks, which will be executed during each update
[ "Add", "a", "task", "to", "self", ".", "tasks", "which", "will", "be", "executed", "during", "each", "update" ]
def add_task(self, command, *args, channel, **kwargs): if command in self.task_commands: self.slack.chat_postMessage( text=f'Added task "{command}"', channel=channel) func = self.task_commands[command] self.tasks.append(partial(func, *args, cha...
[ "def", "add_task", "(", "self", ",", "command", ",", "*", "args", ",", "channel", ",", "**", "kwargs", ")", ":", "if", "command", "in", "self", ".", "task_commands", ":", "self", ".", "slack", ".", "chat_postMessage", "(", "text", "=", "f'Added task \"{c...
Add a task to self.tasks, which will be executed during each update
[ "Add", "a", "task", "to", "self", ".", "tasks", "which", "will", "be", "executed", "during", "each", "update" ]
[ "\"\"\"\n Add a task to self.tasks, which will be executed during each update\n Args:\n command: Task command.\n *args: Additional args for command.\n channel: Slack channel (can also be IM channel).\n **kwargs: Additional kwargs for particular.\n\n R...
[ { "param": "self", "type": null }, { "param": "command", "type": null }, { "param": "channel", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
4a93d79d729d6505850ab973e59336e879d9b911
jakeogh/Qcodes
qcodes/utils/slack.py
[ "MIT" ]
Python
print_measurement_information
null
def print_measurement_information(self, channel, **kwargs): """ Prints information about the current measurement. Information printed is percentage complete, and dataset representation. Dataset is retrieved from DataSet.latest_dataset, which updates itself every time a new datase...
Prints information about the current measurement. Information printed is percentage complete, and dataset representation. Dataset is retrieved from DataSet.latest_dataset, which updates itself every time a new dataset is created Args: channel: Slack channel (can also...
Prints information about the current measurement. Information printed is percentage complete, and dataset representation. Dataset is retrieved from DataSet.latest_dataset, which updates itself every time a new dataset is created
[ "Prints", "information", "about", "the", "current", "measurement", ".", "Information", "printed", "is", "percentage", "complete", "and", "dataset", "representation", ".", "Dataset", "is", "retrieved", "from", "DataSet", ".", "latest_dataset", "which", "updates", "it...
def print_measurement_information(self, channel, **kwargs): dataset = active_data_set() if dataset is not None: self.slack.chat_postMessage( text='Measurement is {:.0f}% complete'.format( 100 * dataset.fraction_complete()), channel=channel)...
[ "def", "print_measurement_information", "(", "self", ",", "channel", ",", "**", "kwargs", ")", ":", "dataset", "=", "active_data_set", "(", ")", "if", "dataset", "is", "not", "None", ":", "self", ".", "slack", ".", "chat_postMessage", "(", "text", "=", "'M...
Prints information about the current measurement.
[ "Prints", "information", "about", "the", "current", "measurement", "." ]
[ "\"\"\"\n Prints information about the current measurement.\n Information printed is percentage complete, and dataset representation.\n Dataset is retrieved from DataSet.latest_dataset, which updates itself\n every time a new dataset is created\n Args:\n channel: Slack ...
[ { "param": "self", "type": null }, { "param": "channel", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
4a93d79d729d6505850ab973e59336e879d9b911
jakeogh/Qcodes
qcodes/utils/slack.py
[ "MIT" ]
Python
check_msmt_finished
<not_specific>
def check_msmt_finished(self, channel, **kwargs): """ Checks if the latest measurement is completed. Args: channel: Slack channel (can also be IM channel). **kwargs: Not used. Returns: bool: True if measurement is finished, False otherwise. ""...
Checks if the latest measurement is completed. Args: channel: Slack channel (can also be IM channel). **kwargs: Not used. Returns: bool: True if measurement is finished, False otherwise.
Checks if the latest measurement is completed.
[ "Checks", "if", "the", "latest", "measurement", "is", "completed", "." ]
def check_msmt_finished(self, channel, **kwargs): if active_loop() is None: self.slack.chat_postMessage( text='Measurement complete', channel=channel) return True else: return False
[ "def", "check_msmt_finished", "(", "self", ",", "channel", ",", "**", "kwargs", ")", ":", "if", "active_loop", "(", ")", "is", "None", ":", "self", ".", "slack", ".", "chat_postMessage", "(", "text", "=", "'Measurement complete'", ",", "channel", "=", "cha...
Checks if the latest measurement is completed.
[ "Checks", "if", "the", "latest", "measurement", "is", "completed", "." ]
[ "\"\"\"\n Checks if the latest measurement is completed.\n Args:\n channel: Slack channel (can also be IM channel).\n **kwargs: Not used.\n\n Returns:\n bool: True if measurement is finished, False otherwise.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "channel", "type": null } ]
{ "returns": [ { "docstring": "True if measurement is finished, False otherwise.", "docstring_tokens": [ "True", "if", "measurement", "is", "finished", "False", "otherwise", "." ], "type": "bool" } ], "raises": [], "...
c8a45b17a72767bc121a98efc135387781c3ea14
jakeogh/Qcodes
qcodes/dataset/sqlite/settings.py
[ "MIT" ]
Python
_read_settings
Tuple[Dict[str, Union[str,int]], Dict[str, Union[bool, int, str]]]
def _read_settings() -> Tuple[Dict[str, Union[str,int]], Dict[str, Union[bool, int, str]]]: """ Function to read the local SQLite settings at import time. We mainly care about the SQLite limits, since these play a role when committing large amounts of data to the DB, but w...
Function to read the local SQLite settings at import time. We mainly care about the SQLite limits, since these play a role when committing large amounts of data to the DB, but we record everything for good measures. Returns: Two dictionaries, one with the limits, one with all other settin...
Function to read the local SQLite settings at import time. We mainly care about the SQLite limits, since these play a role when committing large amounts of data to the DB, but we record everything for good measures.
[ "Function", "to", "read", "the", "local", "SQLite", "settings", "at", "import", "time", ".", "We", "mainly", "care", "about", "the", "SQLite", "limits", "since", "these", "play", "a", "role", "when", "committing", "large", "amounts", "of", "data", "to", "t...
def _read_settings() -> Tuple[Dict[str, Union[str,int]], Dict[str, Union[bool, int, str]]]: DEFAULT_LIMITS: Dict[str, Optional[Union[str, int]]] DEFAULT_LIMITS = {'MAX_ATTACHED': 10, 'MAX_COLUMN': 2000, 'MAX_COMPOUND_SELECT': 500, ...
[ "def", "_read_settings", "(", ")", "->", "Tuple", "[", "Dict", "[", "str", ",", "Union", "[", "str", ",", "int", "]", "]", ",", "Dict", "[", "str", ",", "Union", "[", "bool", ",", "int", ",", "str", "]", "]", "]", ":", "DEFAULT_LIMITS", ":", "D...
Function to read the local SQLite settings at import time.
[ "Function", "to", "read", "the", "local", "SQLite", "settings", "at", "import", "time", "." ]
[ "\"\"\"\n Function to read the local SQLite settings at import time.\n\n We mainly care about the SQLite limits, since these play a role\n when committing large amounts of data to the DB, but we record\n everything for good measures.\n\n Returns:\n Two dictionaries, one with the limits, one wi...
[]
{ "returns": [ { "docstring": "Two dictionaries, one with the limits, one with all other settings.\nIf a setting has a value, that value is provided. Else a boolean\nindicating wether SQLite was compiled with that option. A missing\noption, say, 'FOOBAR' is equivalent to {'FOOBAR': False}.", "docstrin...
cf122b15c26e5f8ee44f0d38993ad3522c9d5734
jakeogh/Qcodes
qcodes/dataset/descriptions/dependencies.py
[ "MIT" ]
Python
_to_dict
InterDependencies_Dict
def _to_dict(self) -> InterDependencies_Dict: """ Write out this object as a dictionary """ parameters = {key: value._to_dict() for key, value in self._id_to_paramspec.items()} dependencies = self._construct_subdict('dependencies') inferences = self....
Write out this object as a dictionary
Write out this object as a dictionary
[ "Write", "out", "this", "object", "as", "a", "dictionary" ]
def _to_dict(self) -> InterDependencies_Dict: parameters = {key: value._to_dict() for key, value in self._id_to_paramspec.items()} dependencies = self._construct_subdict('dependencies') inferences = self._construct_subdict('inferences') standalones = [self._paramspe...
[ "def", "_to_dict", "(", "self", ")", "->", "InterDependencies_Dict", ":", "parameters", "=", "{", "key", ":", "value", ".", "_to_dict", "(", ")", "for", "key", ",", "value", "in", "self", ".", "_id_to_paramspec", ".", "items", "(", ")", "}", "dependencie...
Write out this object as a dictionary
[ "Write", "out", "this", "object", "as", "a", "dictionary" ]
[ "\"\"\"\n Write out this object as a dictionary\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cf122b15c26e5f8ee44f0d38993ad3522c9d5734
jakeogh/Qcodes
qcodes/dataset/descriptions/dependencies.py
[ "MIT" ]
Python
extend
'InterDependencies_'
def extend( self, dependencies: Optional[ParamSpecTree] = None, inferences: Optional[ParamSpecTree] = None, standalones: Tuple[ParamSpecBase, ...] = ()) -> 'InterDependencies_': """ Create a new InterDependencies_ object that is an extension of this ...
Create a new InterDependencies_ object that is an extension of this instance with the provided input
Create a new InterDependencies_ object that is an extension of this instance with the provided input
[ "Create", "a", "new", "InterDependencies_", "object", "that", "is", "an", "extension", "of", "this", "instance", "with", "the", "provided", "input" ]
def extend( self, dependencies: Optional[ParamSpecTree] = None, inferences: Optional[ParamSpecTree] = None, standalones: Tuple[ParamSpecBase, ...] = ()) -> 'InterDependencies_': dependencies = {} if dependencies is None else dependencies inferences = {} if...
[ "def", "extend", "(", "self", ",", "dependencies", ":", "Optional", "[", "ParamSpecTree", "]", "=", "None", ",", "inferences", ":", "Optional", "[", "ParamSpecTree", "]", "=", "None", ",", "standalones", ":", "Tuple", "[", "ParamSpecBase", ",", "...", "]",...
Create a new InterDependencies_ object that is an extension of this instance with the provided input
[ "Create", "a", "new", "InterDependencies_", "object", "that", "is", "an", "extension", "of", "this", "instance", "with", "the", "provided", "input" ]
[ "\"\"\"\n Create a new InterDependencies_ object that is an extension of this\n instance with the provided input\n \"\"\"", "# first step: remove parameters from standalones if they no longer", "# stand alone", "# then update deps and inffs", "# add new standalones" ]
[ { "param": "self", "type": null }, { "param": "dependencies", "type": "Optional[ParamSpecTree]" }, { "param": "inferences", "type": "Optional[ParamSpecTree]" }, { "param": "standalones", "type": "Tuple[ParamSpecBase, ...]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dependencies", "type": "Optional[ParamSpecTree]", "docstring": null...
cf122b15c26e5f8ee44f0d38993ad3522c9d5734
jakeogh/Qcodes
qcodes/dataset/descriptions/dependencies.py
[ "MIT" ]
Python
remove
'InterDependencies_'
def remove(self, parameter: ParamSpecBase) -> 'InterDependencies_': """ Create a new InterDependencies_ object that is similar to this instance, but has the given parameter removed. """ if parameter not in self: raise ValueError(f'Unknown parameter: {parameter}.') ...
Create a new InterDependencies_ object that is similar to this instance, but has the given parameter removed.
Create a new InterDependencies_ object that is similar to this instance, but has the given parameter removed.
[ "Create", "a", "new", "InterDependencies_", "object", "that", "is", "similar", "to", "this", "instance", "but", "has", "the", "given", "parameter", "removed", "." ]
def remove(self, parameter: ParamSpecBase) -> 'InterDependencies_': if parameter not in self: raise ValueError(f'Unknown parameter: {parameter}.') if parameter in self._dependencies_inv: raise ValueError(f'Cannot remove {parameter.name}, other ' 'para...
[ "def", "remove", "(", "self", ",", "parameter", ":", "ParamSpecBase", ")", "->", "'InterDependencies_'", ":", "if", "parameter", "not", "in", "self", ":", "raise", "ValueError", "(", "f'Unknown parameter: {parameter}.'", ")", "if", "parameter", "in", "self", "."...
Create a new InterDependencies_ object that is similar to this instance, but has the given parameter removed.
[ "Create", "a", "new", "InterDependencies_", "object", "that", "is", "similar", "to", "this", "instance", "but", "has", "the", "given", "parameter", "removed", "." ]
[ "\"\"\"\n Create a new InterDependencies_ object that is similar to this\n instance, but has the given parameter removed.\n \"\"\"", "# figure out whether removing this parameter will make any other", "# parameters standalone" ]
[ { "param": "self", "type": null }, { "param": "parameter", "type": "ParamSpecBase" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parameter", "type": "ParamSpecBase", "docstring": null, "docs...
cf122b15c26e5f8ee44f0d38993ad3522c9d5734
jakeogh/Qcodes
qcodes/dataset/descriptions/dependencies.py
[ "MIT" ]
Python
validate_subset
None
def validate_subset(self, parameters: Sequence[ParamSpecBase]) -> None: """ Validate that the given parameters form a valid subset of the parameters of this instance, meaning that all the given parameters are actually found in this instance and that there are no missing dependenc...
Validate that the given parameters form a valid subset of the parameters of this instance, meaning that all the given parameters are actually found in this instance and that there are no missing dependencies/inferences. Args: parameters: The collection of ParamSpecB...
Validate that the given parameters form a valid subset of the parameters of this instance, meaning that all the given parameters are actually found in this instance and that there are no missing dependencies/inferences. The collection of ParamSpecBases to validate DependencyError, if a dependency is missing Inference...
[ "Validate", "that", "the", "given", "parameters", "form", "a", "valid", "subset", "of", "the", "parameters", "of", "this", "instance", "meaning", "that", "all", "the", "given", "parameters", "are", "actually", "found", "in", "this", "instance", "and", "that", ...
def validate_subset(self, parameters: Sequence[ParamSpecBase]) -> None: params = {p.name for p in parameters} for param in params: ps = self._id_to_paramspec.get(param, None) if ps is None: raise ValueError(f'Unknown parameter: {param}') deps = set(sel...
[ "def", "validate_subset", "(", "self", ",", "parameters", ":", "Sequence", "[", "ParamSpecBase", "]", ")", "->", "None", ":", "params", "=", "{", "p", ".", "name", "for", "p", "in", "parameters", "}", "for", "param", "in", "params", ":", "ps", "=", "...
Validate that the given parameters form a valid subset of the parameters of this instance, meaning that all the given parameters are actually found in this instance and that there are no missing dependencies/inferences.
[ "Validate", "that", "the", "given", "parameters", "form", "a", "valid", "subset", "of", "the", "parameters", "of", "this", "instance", "meaning", "that", "all", "the", "given", "parameters", "are", "actually", "found", "in", "this", "instance", "and", "that", ...
[ "\"\"\"\n Validate that the given parameters form a valid subset of the\n parameters of this instance, meaning that all the given parameters are\n actually found in this instance and that there are no missing\n dependencies/inferences.\n\n Args:\n parameters: The collec...
[ { "param": "self", "type": null }, { "param": "parameters", "type": "Sequence[ParamSpecBase]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "parameters", "type": "Sequence[ParamSpecBase]", "docstring": null, ...
cf122b15c26e5f8ee44f0d38993ad3522c9d5734
jakeogh/Qcodes
qcodes/dataset/descriptions/dependencies.py
[ "MIT" ]
Python
_from_dict
'InterDependencies_'
def _from_dict(cls, ser: InterDependencies_Dict) -> 'InterDependencies_': """ Construct an InterDependencies_ object from a dictionary representation of such an object """ params = ser['parameters'] deps = cls._extract_deps_from_dict(ser) inffs = cls._extract_inf...
Construct an InterDependencies_ object from a dictionary representation of such an object
Construct an InterDependencies_ object from a dictionary representation of such an object
[ "Construct", "an", "InterDependencies_", "object", "from", "a", "dictionary", "representation", "of", "such", "an", "object" ]
def _from_dict(cls, ser: InterDependencies_Dict) -> 'InterDependencies_': params = ser['parameters'] deps = cls._extract_deps_from_dict(ser) inffs = cls._extract_inffs_from_dict(ser) stdls = tuple(ParamSpecBase._from_dict(params[ps_id]) for ps_id in ser['standalones...
[ "def", "_from_dict", "(", "cls", ",", "ser", ":", "InterDependencies_Dict", ")", "->", "'InterDependencies_'", ":", "params", "=", "ser", "[", "'parameters'", "]", "deps", "=", "cls", ".", "_extract_deps_from_dict", "(", "ser", ")", "inffs", "=", "cls", ".",...
Construct an InterDependencies_ object from a dictionary representation of such an object
[ "Construct", "an", "InterDependencies_", "object", "from", "a", "dictionary", "representation", "of", "such", "an", "object" ]
[ "\"\"\"\n Construct an InterDependencies_ object from a dictionary\n representation of such an object\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "ser", "type": "InterDependencies_Dict" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ser", "type": "InterDependencies_Dict", "docstring": null, "do...
d445be79d631f75f81d4eba2e64cca76d65d933e
jakeogh/Qcodes
qcodes/dataset/descriptions/rundescriber.py
[ "MIT" ]
Python
_verify_interdeps_shape
None
def _verify_interdeps_shape(interdeps: InterDependencies_, shapes: Shapes) -> None: """ Verify that interdeps and shape are consistent """ for dependent, dependencies in interdeps.dependencies.items(): if shapes is not None: sha...
Verify that interdeps and shape are consistent
Verify that interdeps and shape are consistent
[ "Verify", "that", "interdeps", "and", "shape", "are", "consistent" ]
def _verify_interdeps_shape(interdeps: InterDependencies_, shapes: Shapes) -> None: for dependent, dependencies in interdeps.dependencies.items(): if shapes is not None: shape = shapes.get(dependent.name) if shape is not None: ...
[ "def", "_verify_interdeps_shape", "(", "interdeps", ":", "InterDependencies_", ",", "shapes", ":", "Shapes", ")", "->", "None", ":", "for", "dependent", ",", "dependencies", "in", "interdeps", ".", "dependencies", ".", "items", "(", ")", ":", "if", "shapes", ...
Verify that interdeps and shape are consistent
[ "Verify", "that", "interdeps", "and", "shape", "are", "consistent" ]
[ "\"\"\"\n Verify that interdeps and shape are consistent\n \"\"\"" ]
[ { "param": "interdeps", "type": "InterDependencies_" }, { "param": "shapes", "type": "Shapes" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "interdeps", "type": "InterDependencies_", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "shapes", "type": "Shapes", "docstring": null, ...
d445be79d631f75f81d4eba2e64cca76d65d933e
jakeogh/Qcodes
qcodes/dataset/descriptions/rundescriber.py
[ "MIT" ]
Python
_to_dict
RunDescriberV3Dict
def _to_dict(self) -> RunDescriberV3Dict: """ Convert this object into a dictionary. This method is intended to be used only by the serialization routines. """ ser: RunDescriberV3Dict = { 'version': self._version, 'interdependencies': new_to_old(self.inter...
Convert this object into a dictionary. This method is intended to be used only by the serialization routines.
Convert this object into a dictionary. This method is intended to be used only by the serialization routines.
[ "Convert", "this", "object", "into", "a", "dictionary", ".", "This", "method", "is", "intended", "to", "be", "used", "only", "by", "the", "serialization", "routines", "." ]
def _to_dict(self) -> RunDescriberV3Dict: ser: RunDescriberV3Dict = { 'version': self._version, 'interdependencies': new_to_old(self.interdeps)._to_dict(), 'interdependencies_': self.interdeps._to_dict(), 'shapes': self.shapes } return ser
[ "def", "_to_dict", "(", "self", ")", "->", "RunDescriberV3Dict", ":", "ser", ":", "RunDescriberV3Dict", "=", "{", "'version'", ":", "self", ".", "_version", ",", "'interdependencies'", ":", "new_to_old", "(", "self", ".", "interdeps", ")", ".", "_to_dict", "...
Convert this object into a dictionary.
[ "Convert", "this", "object", "into", "a", "dictionary", "." ]
[ "\"\"\"\n Convert this object into a dictionary. This method is intended to\n be used only by the serialization routines.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d445be79d631f75f81d4eba2e64cca76d65d933e
jakeogh/Qcodes
qcodes/dataset/descriptions/rundescriber.py
[ "MIT" ]
Python
_from_dict
'RunDescriber'
def _from_dict(cls, ser: RunDescriberDicts) -> 'RunDescriber': """ Make a RunDescriber object from a dictionary. This method is intended to be used only by the deserialization routines. """ if ser['version'] == 0: ser = cast(RunDescriberV0Dict, ser) rundes...
Make a RunDescriber object from a dictionary. This method is intended to be used only by the deserialization routines.
Make a RunDescriber object from a dictionary. This method is intended to be used only by the deserialization routines.
[ "Make", "a", "RunDescriber", "object", "from", "a", "dictionary", ".", "This", "method", "is", "intended", "to", "be", "used", "only", "by", "the", "deserialization", "routines", "." ]
def _from_dict(cls, ser: RunDescriberDicts) -> 'RunDescriber': if ser['version'] == 0: ser = cast(RunDescriberV0Dict, ser) rundesc = cls( old_to_new( InterDependencies._from_dict(ser['interdependencies']) ) ) elif se...
[ "def", "_from_dict", "(", "cls", ",", "ser", ":", "RunDescriberDicts", ")", "->", "'RunDescriber'", ":", "if", "ser", "[", "'version'", "]", "==", "0", ":", "ser", "=", "cast", "(", "RunDescriberV0Dict", ",", "ser", ")", "rundesc", "=", "cls", "(", "ol...
Make a RunDescriber object from a dictionary.
[ "Make", "a", "RunDescriber", "object", "from", "a", "dictionary", "." ]
[ "\"\"\"\n Make a RunDescriber object from a dictionary. This method is\n intended to be used only by the deserialization routines.\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "ser", "type": "RunDescriberDicts" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ser", "type": "RunDescriberDicts", "docstring": null, "docstri...
498deb392ef4eb6b1604307a1fd5b74e7a1a18a0
jakeogh/Qcodes
qcodes/tests/dataset/test_paramspec.py
[ "MIT" ]
Python
version_0_objects
<not_specific>
def version_0_objects(): """ The ParamSpecs that the dictionaries above represent """ ps = [] ps.append(ParamSpec('dmm_v1', paramtype='numeric', label='Gate v1', unit='V', inferred_from=[], depends_on=['dac_ch1', 'dac_ch2'])) ps.append(ParamSpec('s...
The ParamSpecs that the dictionaries above represent
The ParamSpecs that the dictionaries above represent
[ "The", "ParamSpecs", "that", "the", "dictionaries", "above", "represent" ]
def version_0_objects(): ps = [] ps.append(ParamSpec('dmm_v1', paramtype='numeric', label='Gate v1', unit='V', inferred_from=[], depends_on=['dac_ch1', 'dac_ch2'])) ps.append(ParamSpec('some_name', paramtype='array', label='My Array Par...
[ "def", "version_0_objects", "(", ")", ":", "ps", "=", "[", "]", "ps", ".", "append", "(", "ParamSpec", "(", "'dmm_v1'", ",", "paramtype", "=", "'numeric'", ",", "label", "=", "'Gate v1'", ",", "unit", "=", "'V'", ",", "inferred_from", "=", "[", "]", ...
The ParamSpecs that the dictionaries above represent
[ "The", "ParamSpecs", "that", "the", "dictionaries", "above", "represent" ]
[ "\"\"\"\n The ParamSpecs that the dictionaries above represent\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
335bba8c56a1825ba9c148edaa6e357d7eca9210
jakeogh/Qcodes
qcodes/instrument/group_parameter.py
[ "MIT" ]
Python
group
Optional['Group']
def group(self) -> Optional['Group']: """ The group that this parameter belongs to. """ return self._group
The group that this parameter belongs to.
The group that this parameter belongs to.
[ "The", "group", "that", "this", "parameter", "belongs", "to", "." ]
def group(self) -> Optional['Group']: return self._group
[ "def", "group", "(", "self", ")", "->", "Optional", "[", "'Group'", "]", ":", "return", "self", ".", "_group" ]
The group that this parameter belongs to.
[ "The", "group", "that", "this", "parameter", "belongs", "to", "." ]
[ "\"\"\"\n The group that this parameter belongs to.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
335bba8c56a1825ba9c148edaa6e357d7eca9210
jakeogh/Qcodes
qcodes/instrument/group_parameter.py
[ "MIT" ]
Python
_separator_parser
Callable[[str], Dict[str, ParamRawDataType]]
def _separator_parser(self, separator: str ) -> Callable[[str], Dict[str, ParamRawDataType]]: """A default separator-based string parser""" def parser(ret_str: str) -> Dict[str, Any]: keys = self.parameters.keys() values = ret_str.split(separator) ...
A default separator-based string parser
A default separator-based string parser
[ "A", "default", "separator", "-", "based", "string", "parser" ]
def _separator_parser(self, separator: str ) -> Callable[[str], Dict[str, ParamRawDataType]]: def parser(ret_str: str) -> Dict[str, Any]: keys = self.parameters.keys() values = ret_str.split(separator) return dict(zip(keys, values)) return pa...
[ "def", "_separator_parser", "(", "self", ",", "separator", ":", "str", ")", "->", "Callable", "[", "[", "str", "]", ",", "Dict", "[", "str", ",", "ParamRawDataType", "]", "]", ":", "def", "parser", "(", "ret_str", ":", "str", ")", "->", "Dict", "[", ...
A default separator-based string parser
[ "A", "default", "separator", "-", "based", "string", "parser" ]
[ "\"\"\"A default separator-based string parser\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "separator", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "separator", "type": "str", "docstring": null, "docstring_toke...
335bba8c56a1825ba9c148edaa6e357d7eca9210
jakeogh/Qcodes
qcodes/instrument/group_parameter.py
[ "MIT" ]
Python
_set_one_parameter_from_raw
None
def _set_one_parameter_from_raw(self, set_parameter: GroupParameter, raw_value: ParamRawDataType) -> None: """ Sets the raw_value of the given parameter within a group to the given raw_value by calling the ``set_cmd``. Args: set_parameter:...
Sets the raw_value of the given parameter within a group to the given raw_value by calling the ``set_cmd``. Args: set_parameter: The parameter within the group to set. raw_value: The new raw_value for this parameter.
Sets the raw_value of the given parameter within a group to the given raw_value by calling the ``set_cmd``.
[ "Sets", "the", "raw_value", "of", "the", "given", "parameter", "within", "a", "group", "to", "the", "given", "raw_value", "by", "calling", "the", "`", "`", "set_cmd", "`", "`", "." ]
def _set_one_parameter_from_raw(self, set_parameter: GroupParameter, raw_value: ParamRawDataType) -> None: if any((p.get_latest() is None) for p in self.parameters.values()): self.update() calling_dict = {name: p.cache.raw_value for...
[ "def", "_set_one_parameter_from_raw", "(", "self", ",", "set_parameter", ":", "GroupParameter", ",", "raw_value", ":", "ParamRawDataType", ")", "->", "None", ":", "if", "any", "(", "(", "p", ".", "get_latest", "(", ")", "is", "None", ")", "for", "p", "in",...
Sets the raw_value of the given parameter within a group to the given raw_value by calling the ``set_cmd``.
[ "Sets", "the", "raw_value", "of", "the", "given", "parameter", "within", "a", "group", "to", "the", "given", "raw_value", "by", "calling", "the", "`", "`", "set_cmd", "`", "`", "." ]
[ "\"\"\"\n Sets the raw_value of the given parameter within a group to the given\n raw_value by calling the ``set_cmd``.\n\n Args:\n set_parameter: The parameter within the group to set.\n raw_value: The new raw_value for this parameter.\n \"\"\"", "# TODO replace ...
[ { "param": "self", "type": null }, { "param": "set_parameter", "type": "GroupParameter" }, { "param": "raw_value", "type": "ParamRawDataType" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "set_parameter", "type": "GroupParameter", "docstring": "The paramet...
335bba8c56a1825ba9c148edaa6e357d7eca9210
jakeogh/Qcodes
qcodes/instrument/group_parameter.py
[ "MIT" ]
Python
_set_from_dict
None
def _set_from_dict(self, calling_dict: Mapping[str, ParamRawDataType]) -> None: """ Use ``set_cmd`` to parse a dict that maps parameter names to parameter raw values, and actually perform setting the values. """ if self._set_cmd is None: raise RuntimeError("Calling se...
Use ``set_cmd`` to parse a dict that maps parameter names to parameter raw values, and actually perform setting the values.
Use ``set_cmd`` to parse a dict that maps parameter names to parameter raw values, and actually perform setting the values.
[ "Use", "`", "`", "set_cmd", "`", "`", "to", "parse", "a", "dict", "that", "maps", "parameter", "names", "to", "parameter", "raw", "values", "and", "actually", "perform", "setting", "the", "values", "." ]
def _set_from_dict(self, calling_dict: Mapping[str, ParamRawDataType]) -> None: if self._set_cmd is None: raise RuntimeError("Calling set but no `set_cmd` defined") command_str = self._set_cmd.format(**calling_dict) if self.instrument is None: raise RuntimeError("Trying t...
[ "def", "_set_from_dict", "(", "self", ",", "calling_dict", ":", "Mapping", "[", "str", ",", "ParamRawDataType", "]", ")", "->", "None", ":", "if", "self", ".", "_set_cmd", "is", "None", ":", "raise", "RuntimeError", "(", "\"Calling set but no `set_cmd` defined\"...
Use ``set_cmd`` to parse a dict that maps parameter names to parameter raw values, and actually perform setting the values.
[ "Use", "`", "`", "set_cmd", "`", "`", "to", "parse", "a", "dict", "that", "maps", "parameter", "names", "to", "parameter", "raw", "values", "and", "actually", "perform", "setting", "the", "values", "." ]
[ "\"\"\"\n Use ``set_cmd`` to parse a dict that maps parameter names to parameter\n raw values, and actually perform setting the values.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "calling_dict", "type": "Mapping[str, ParamRawDataType]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "calling_dict", "type": "Mapping[str, ParamRawDataType]", "docstring...
335bba8c56a1825ba9c148edaa6e357d7eca9210
jakeogh/Qcodes
qcodes/instrument/group_parameter.py
[ "MIT" ]
Python
update
None
def update(self) -> None: """ Update the values of all the parameters within the group by calling the ``get_cmd``. """ if self.instrument is None: raise RuntimeError("Trying to update GroupParameter not attached " "to any instrument.") ...
Update the values of all the parameters within the group by calling the ``get_cmd``.
Update the values of all the parameters within the group by calling the ``get_cmd``.
[ "Update", "the", "values", "of", "all", "the", "parameters", "within", "the", "group", "by", "calling", "the", "`", "`", "get_cmd", "`", "`", "." ]
def update(self) -> None: if self.instrument is None: raise RuntimeError("Trying to update GroupParameter not attached " "to any instrument.") if self._get_cmd is None: parameter_names = ', '.join( p.full_name for p in self.parameter...
[ "def", "update", "(", "self", ")", "->", "None", ":", "if", "self", ".", "instrument", "is", "None", ":", "raise", "RuntimeError", "(", "\"Trying to update GroupParameter not attached \"", "\"to any instrument.\"", ")", "if", "self", ".", "_get_cmd", "is", "None",...
Update the values of all the parameters within the group by calling the ``get_cmd``.
[ "Update", "the", "values", "of", "all", "the", "parameters", "within", "the", "group", "by", "calling", "the", "`", "`", "get_cmd", "`", "`", "." ]
[ "\"\"\"\n Update the values of all the parameters within the group by calling\n the ``get_cmd``.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
335bba8c56a1825ba9c148edaa6e357d7eca9210
jakeogh/Qcodes
qcodes/instrument/group_parameter.py
[ "MIT" ]
Python
parameters
"OrderedDict[str, GroupParameter]"
def parameters(self) -> "OrderedDict[str, GroupParameter]": """ All parameters in this group as a dict from parameter name to :class:`.Parameter` """ return self._parameters
All parameters in this group as a dict from parameter name to :class:`.Parameter`
All parameters in this group as a dict from parameter name to
[ "All", "parameters", "in", "this", "group", "as", "a", "dict", "from", "parameter", "name", "to" ]
def parameters(self) -> "OrderedDict[str, GroupParameter]": return self._parameters
[ "def", "parameters", "(", "self", ")", "->", "\"OrderedDict[str, GroupParameter]\"", ":", "return", "self", ".", "_parameters" ]
All parameters in this group as a dict from parameter name to
[ "All", "parameters", "in", "this", "group", "as", "a", "dict", "from", "parameter", "name", "to" ]
[ "\"\"\"\n All parameters in this group as a dict from parameter name to\n :class:`.Parameter`\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "class", "docstring": null, ...
8951c92d6290b258548924a5cc5e0edd701c5b22
jakeogh/Qcodes
qcodes/instrument_drivers/tektronix/DPO7200xx.py
[ "MIT" ]
Python
_get_cmd
Callable[[], str]
def _get_cmd(self, cmd_string: str) -> Callable[[], str]: """ Parameters defined in this submodule require the correct data source being selected first. """ def inner() -> str: self.root_instrument.data.source(self._identifier) return self.ask(cmd_string) ...
Parameters defined in this submodule require the correct data source being selected first.
Parameters defined in this submodule require the correct data source being selected first.
[ "Parameters", "defined", "in", "this", "submodule", "require", "the", "correct", "data", "source", "being", "selected", "first", "." ]
def _get_cmd(self, cmd_string: str) -> Callable[[], str]: def inner() -> str: self.root_instrument.data.source(self._identifier) return self.ask(cmd_string) return inner
[ "def", "_get_cmd", "(", "self", ",", "cmd_string", ":", "str", ")", "->", "Callable", "[", "[", "]", ",", "str", "]", ":", "def", "inner", "(", ")", "->", "str", ":", "self", ".", "root_instrument", ".", "data", ".", "source", "(", "self", ".", "...
Parameters defined in this submodule require the correct data source being selected first.
[ "Parameters", "defined", "in", "this", "submodule", "require", "the", "correct", "data", "source", "being", "selected", "first", "." ]
[ "\"\"\"\n Parameters defined in this submodule require the correct\n data source being selected first.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "cmd_string", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cmd_string", "type": "str", "docstring": null, "docstring_tok...
8951c92d6290b258548924a5cc5e0edd701c5b22
jakeogh/Qcodes
qcodes/instrument_drivers/tektronix/DPO7200xx.py
[ "MIT" ]
Python
wait_adjustment_time
None
def wait_adjustment_time(self) -> None: """ Wait until the minimum time after adjusting the measurement source or type has elapsed """ time_since_adjust = time.perf_counter() - self._adjustment_time if time_since_adjust < self._minimum_adjustment_time: time_re...
Wait until the minimum time after adjusting the measurement source or type has elapsed
Wait until the minimum time after adjusting the measurement source or type has elapsed
[ "Wait", "until", "the", "minimum", "time", "after", "adjusting", "the", "measurement", "source", "or", "type", "has", "elapsed" ]
def wait_adjustment_time(self) -> None: time_since_adjust = time.perf_counter() - self._adjustment_time if time_since_adjust < self._minimum_adjustment_time: time_remaining = self._minimum_adjustment_time - time_since_adjust time.sleep(time_remaining)
[ "def", "wait_adjustment_time", "(", "self", ")", "->", "None", ":", "time_since_adjust", "=", "time", ".", "perf_counter", "(", ")", "-", "self", ".", "_adjustment_time", "if", "time_since_adjust", "<", "self", ".", "_minimum_adjustment_time", ":", "time_remaining...
Wait until the minimum time after adjusting the measurement source or type has elapsed
[ "Wait", "until", "the", "minimum", "time", "after", "adjusting", "the", "measurement", "source", "or", "type", "has", "elapsed" ]
[ "\"\"\"\n Wait until the minimum time after adjusting the measurement source or\n type has elapsed\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d423890fc85acbd82279cb2753c423deed9ae143
Saevon/PersOA
app/views/search.py
[ "MIT" ]
Python
create_schema
null
def create_schema(self, flush=False): """ Creates the Schema for the index. if flush is True this removes the old index if there was one. """ from whoosh.fields import Schema from whoosh.fields import ID, KEYWORD, TEXT from shutil import rmtree schema = S...
Creates the Schema for the index. if flush is True this removes the old index if there was one.
Creates the Schema for the index. if flush is True this removes the old index if there was one.
[ "Creates", "the", "Schema", "for", "the", "index", ".", "if", "flush", "is", "True", "this", "removes", "the", "old", "index", "if", "there", "was", "one", "." ]
def create_schema(self, flush=False): from whoosh.fields import Schema from whoosh.fields import ID, KEYWORD, TEXT from shutil import rmtree schema = Schema( index_id=ID(unique=True), id=ID(stored=True), type=ID(stored=True), name=TEXT, ...
[ "def", "create_schema", "(", "self", ",", "flush", "=", "False", ")", ":", "from", "whoosh", ".", "fields", "import", "Schema", "from", "whoosh", ".", "fields", "import", "ID", ",", "KEYWORD", ",", "TEXT", "from", "shutil", "import", "rmtree", "schema", ...
Creates the Schema for the index.
[ "Creates", "the", "Schema", "for", "the", "index", "." ]
[ "\"\"\"\n Creates the Schema for the index. if flush is True this removes\n the old index if there was one.\n \"\"\"", "# Indexing", "# Identification", "# Searching", "# Remove the old index if flushing", "# Create the folder if needed", "# make the actual index" ]
[ { "param": "self", "type": null }, { "param": "flush", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "flush", "type": null, "docstring": null, "docstring_tokens": ...
d423890fc85acbd82279cb2753c423deed9ae143
Saevon/PersOA
app/views/search.py
[ "MIT" ]
Python
refresh_index
null
def refresh_index(self): """ Refreshes all the items in the index """ from itertools import chain items = chain( BasicChoice.objects.all(), LinearChoice.objects.all(), SubChoice.objects.all(), TraitGroup.objects.all(), BasicTrait.objects.all()...
Refreshes all the items in the index
Refreshes all the items in the index
[ "Refreshes", "all", "the", "items", "in", "the", "index" ]
def refresh_index(self): from itertools import chain items = chain( BasicChoice.objects.all(), LinearChoice.objects.all(), SubChoice.objects.all(), TraitGroup.objects.all(), BasicTrait.objects.all(), LinearTrait.objects.all(), ) writer = self.index.wri...
[ "def", "refresh_index", "(", "self", ")", ":", "from", "itertools", "import", "chain", "items", "=", "chain", "(", "BasicChoice", ".", "objects", ".", "all", "(", ")", ",", "LinearChoice", ".", "objects", ".", "all", "(", ")", ",", "SubChoice", ".", "o...
Refreshes all the items in the index
[ "Refreshes", "all", "the", "items", "in", "the", "index" ]
[ "\"\"\"\n Refreshes all the items in the index\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d423890fc85acbd82279cb2753c423deed9ae143
Saevon/PersOA
app/views/search.py
[ "MIT" ]
Python
search
<not_specific>
def search(self, **kwargs): """ Finds the top item matching the arguments. query(str): the text being searched for name(list): The names of the item desc(list): The data to search the defn and desc fields for type(list): the expected type of the item (clas...
Finds the top item matching the arguments. query(str): the text being searched for name(list): The names of the item desc(list): The data to search the defn and desc fields for type(list): the expected type of the item (class names)
Finds the top item matching the arguments. query(str): the text being searched for name(list): The names of the item desc(list): The data to search the defn and desc fields for type(list): the expected type of the item (class names)
[ "Finds", "the", "top", "item", "matching", "the", "arguments", ".", "query", "(", "str", ")", ":", "the", "text", "being", "searched", "for", "name", "(", "list", ")", ":", "The", "names", "of", "the", "item", "desc", "(", "list", ")", ":", "The", ...
def search(self, **kwargs): kwargs = defaultdict(unicode, **kwargs) with self.index.searcher() as searcher: query = (QueryParser('keywords', self.index.schema) .parse(unicode(kwargs.get('query', u'').lower())) ) if not kwargs['name'] is None: ...
[ "def", "search", "(", "self", ",", "**", "kwargs", ")", ":", "kwargs", "=", "defaultdict", "(", "unicode", ",", "**", "kwargs", ")", "with", "self", ".", "index", ".", "searcher", "(", ")", "as", "searcher", ":", "query", "=", "(", "QueryParser", "("...
Finds the top item matching the arguments.
[ "Finds", "the", "top", "item", "matching", "the", "arguments", "." ]
[ "\"\"\"\n Finds the top item matching the arguments.\n query(str): the text being searched for\n name(list): The names of the item\n desc(list): The data to search the defn and desc fields for\n type(list): the expected type of the item (class names)\n \"\"\...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d423890fc85acbd82279cb2753c423deed9ae143
Saevon/PersOA
app/views/search.py
[ "MIT" ]
Python
index_data
<not_specific>
def index_data(self, item): """ Converts the item into an indexable dictionary """ # =========== Choices ========== if isinstance(item, BasicChoice): data = { 'name': unicode(item.name), 'type': u'BasicChoice', 'keywords...
Converts the item into an indexable dictionary
Converts the item into an indexable dictionary
[ "Converts", "the", "item", "into", "an", "indexable", "dictionary" ]
def index_data(self, item): if isinstance(item, BasicChoice): data = { 'name': unicode(item.name), 'type': u'BasicChoice', 'keywords': u'%s choice' % (item.name), 'desc': unicode(item.desc), 'defn': unicode(item.defn), ...
[ "def", "index_data", "(", "self", ",", "item", ")", ":", "if", "isinstance", "(", "item", ",", "BasicChoice", ")", ":", "data", "=", "{", "'name'", ":", "unicode", "(", "item", ".", "name", ")", ",", "'type'", ":", "u'BasicChoice'", ",", "'keywords'", ...
Converts the item into an indexable dictionary
[ "Converts", "the", "item", "into", "an", "indexable", "dictionary" ]
[ "\"\"\"\n Converts the item into an indexable dictionary\n \"\"\"", "# =========== Choices ==========", "# =========== Traits ==========", "# =========== Traits ==========" ]
[ { "param": "self", "type": null }, { "param": "item", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "item", "type": null, "docstring": null, "docstring_tokens": [...
6ba9e8e3fede01fe12f7469d6f4402135e5029c6
Saevon/PersOA
app/models/group.py
[ "MIT" ]
Python
generate
<not_specific>
def generate(self, num=None, seed=None, include=None): """ Returns a choice for each of the groupings traits """ if num is None: num = 1 groups = [] for i in range(num): group = {} for trait in self.traits: group[trait...
Returns a choice for each of the groupings traits
Returns a choice for each of the groupings traits
[ "Returns", "a", "choice", "for", "each", "of", "the", "groupings", "traits" ]
def generate(self, num=None, seed=None, include=None): if num is None: num = 1 groups = [] for i in range(num): group = {} for trait in self.traits: group[trait.name] = [ i.details(include) for i in trait...
[ "def", "generate", "(", "self", ",", "num", "=", "None", ",", "seed", "=", "None", ",", "include", "=", "None", ")", ":", "if", "num", "is", "None", ":", "num", "=", "1", "groups", "=", "[", "]", "for", "i", "in", "range", "(", "num", ")", ":...
Returns a choice for each of the groupings traits
[ "Returns", "a", "choice", "for", "each", "of", "the", "groupings", "traits" ]
[ "\"\"\"\n Returns a choice for each of the groupings traits\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "num", "type": null }, { "param": "seed", "type": null }, { "param": "include", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num", "type": null, "docstring": null, "docstring_tokens": []...
6ba9e8e3fede01fe12f7469d6f4402135e5029c6
Saevon/PersOA
app/models/group.py
[ "MIT" ]
Python
details
<not_specific>
def details(self, include=None): """ Returns a dict with the choice's details """ details = self.data() if include is None: pass elif include['group_name']: return self.name include['group'] = False if include['trait']: ...
Returns a dict with the choice's details
Returns a dict with the choice's details
[ "Returns", "a", "dict", "with", "the", "choice", "'", "s", "details" ]
def details(self, include=None): details = self.data() if include is None: pass elif include['group_name']: return self.name include['group'] = False if include['trait']: details.update({ 'traits': [trait.details(include) for tr...
[ "def", "details", "(", "self", ",", "include", "=", "None", ")", ":", "details", "=", "self", ".", "data", "(", ")", "if", "include", "is", "None", ":", "pass", "elif", "include", "[", "'group_name'", "]", ":", "return", "self", ".", "name", "include...
Returns a dict with the choice's details
[ "Returns", "a", "dict", "with", "the", "choice", "'", "s", "details" ]
[ "\"\"\"\n Returns a dict with the choice's details\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "include", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "include", "type": null, "docstring": null, "docstring_tokens"...
6ba9e8e3fede01fe12f7469d6f4402135e5029c6
Saevon/PersOA
app/models/group.py
[ "MIT" ]
Python
data
<not_specific>
def data(self): """ Returns a dict with the basic details """ return { 'name': self.name, 'desc': self.desc, }
Returns a dict with the basic details
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
def data(self): return { 'name': self.name, 'desc': self.desc, }
[ "def", "data", "(", "self", ")", ":", "return", "{", "'name'", ":", "self", ".", "name", ",", "'desc'", ":", "self", ".", "desc", ",", "}" ]
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
[ "\"\"\"\n Returns a dict with the basic details\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aa1fd99f0f7238f38fb0818fe98926f310ab54d6
Saevon/PersOA
app/views/field.py
[ "MIT" ]
Python
choice
null
def choice(self, choice): """ If the LIMIT setting is disabled enables it Then adds choice to the possible choices for this field """ if not Field.SETTINGS_LIMIT in self._settings: self.setting(Field.SETTINGS_LIMIT) self._limit.add(choice)
If the LIMIT setting is disabled enables it Then adds choice to the possible choices for this field
If the LIMIT setting is disabled enables it Then adds choice to the possible choices for this field
[ "If", "the", "LIMIT", "setting", "is", "disabled", "enables", "it", "Then", "adds", "choice", "to", "the", "possible", "choices", "for", "this", "field" ]
def choice(self, choice): if not Field.SETTINGS_LIMIT in self._settings: self.setting(Field.SETTINGS_LIMIT) self._limit.add(choice)
[ "def", "choice", "(", "self", ",", "choice", ")", ":", "if", "not", "Field", ".", "SETTINGS_LIMIT", "in", "self", ".", "_settings", ":", "self", ".", "setting", "(", "Field", ".", "SETTINGS_LIMIT", ")", "self", ".", "_limit", ".", "add", "(", "choice",...
If the LIMIT setting is disabled enables it Then adds choice to the possible choices for this field
[ "If", "the", "LIMIT", "setting", "is", "disabled", "enables", "it", "Then", "adds", "choice", "to", "the", "possible", "choices", "for", "this", "field" ]
[ "\"\"\"\n If the LIMIT setting is disabled enables it\n Then adds choice to the possible choices for this field\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "choice", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "choice", "type": null, "docstring": null, "docstring_tokens":...
aa1fd99f0f7238f38fb0818fe98926f310ab54d6
Saevon/PersOA
app/views/field.py
[ "MIT" ]
Python
used_key
<not_specific>
def used_key(self): """ Returns the key that was used when the field last got data Note: If no data was found, then None is returned """ return self._used
Returns the key that was used when the field last got data Note: If no data was found, then None is returned
Returns the key that was used when the field last got data Note: If no data was found, then None is returned
[ "Returns", "the", "key", "that", "was", "used", "when", "the", "field", "last", "got", "data", "Note", ":", "If", "no", "data", "was", "found", "then", "None", "is", "returned" ]
def used_key(self): return self._used
[ "def", "used_key", "(", "self", ")", ":", "return", "self", ".", "_used" ]
Returns the key that was used when the field last got data Note: If no data was found, then None is returned
[ "Returns", "the", "key", "that", "was", "used", "when", "the", "field", "last", "got", "data", "Note", ":", "If", "no", "data", "was", "found", "then", "None", "is", "returned" ]
[ "\"\"\"\n Returns the key that was used when the field last got data\n Note: If no data was found, then None is returned\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
aa1fd99f0f7238f38fb0818fe98926f310ab54d6
Saevon/PersOA
app/views/field.py
[ "MIT" ]
Python
val
<not_specific>
def val(self, params): """ Calculates the value of the field from the dict params Returning the calculated value """ return self._first_valid(params)
Calculates the value of the field from the dict params Returning the calculated value
Calculates the value of the field from the dict params Returning the calculated value
[ "Calculates", "the", "value", "of", "the", "field", "from", "the", "dict", "params", "Returning", "the", "calculated", "value" ]
def val(self, params): return self._first_valid(params)
[ "def", "val", "(", "self", ",", "params", ")", ":", "return", "self", ".", "_first_valid", "(", "params", ")" ]
Calculates the value of the field from the dict params Returning the calculated value
[ "Calculates", "the", "value", "of", "the", "field", "from", "the", "dict", "params", "Returning", "the", "calculated", "value" ]
[ "\"\"\"\n Calculates the value of the field from the dict params\n Returning the calculated value\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "params", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "params", "type": null, "docstring": null, "docstring_tokens":...
aa1fd99f0f7238f38fb0818fe98926f310ab54d6
Saevon/PersOA
app/views/field.py
[ "MIT" ]
Python
_first_valid
<not_specific>
def _first_valid(self, params): """ Tries to find the first valid field in params that fits the set criteria. returns/raises the default value if none was found """ self._used = None for key in self._keys: val = params.get(key) if val is None: ...
Tries to find the first valid field in params that fits the set criteria. returns/raises the default value if none was found
Tries to find the first valid field in params that fits the set criteria. returns/raises the default value if none was found
[ "Tries", "to", "find", "the", "first", "valid", "field", "in", "params", "that", "fits", "the", "set", "criteria", ".", "returns", "/", "raises", "the", "default", "value", "if", "none", "was", "found" ]
def _first_valid(self, params): self._used = None for key in self._keys: val = params.get(key) if val is None: continue try: val = simplejson.loads(val) except simplejson.JSONDecodeError: continue ...
[ "def", "_first_valid", "(", "self", ",", "params", ")", ":", "self", ".", "_used", "=", "None", "for", "key", "in", "self", ".", "_keys", ":", "val", "=", "params", ".", "get", "(", "key", ")", "if", "val", "is", "None", ":", "continue", "try", "...
Tries to find the first valid field in params that fits the set criteria.
[ "Tries", "to", "find", "the", "first", "valid", "field", "in", "params", "that", "fits", "the", "set", "criteria", "." ]
[ "\"\"\"\n Tries to find the first valid field in params that fits the set criteria.\n returns/raises the default value if none was found\n \"\"\"", "# Make sure that only a valid type is returned", "# Check every single value for validity", "# Break out early in case we're failing as the ...
[ { "param": "self", "type": null }, { "param": "params", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "params", "type": null, "docstring": null, "docstring_tokens":...
aa1fd99f0f7238f38fb0818fe98926f310ab54d6
Saevon/PersOA
app/views/field.py
[ "MIT" ]
Python
_validate_val
<not_specific>
def _validate_val(self, val): """ Runs all the validators on the val Returns a bool success value """ for validator in self._validators: if not validator(val): return False return True
Runs all the validators on the val Returns a bool success value
Runs all the validators on the val Returns a bool success value
[ "Runs", "all", "the", "validators", "on", "the", "val", "Returns", "a", "bool", "success", "value" ]
def _validate_val(self, val): for validator in self._validators: if not validator(val): return False return True
[ "def", "_validate_val", "(", "self", ",", "val", ")", ":", "for", "validator", "in", "self", ".", "_validators", ":", "if", "not", "validator", "(", "val", ")", ":", "return", "False", "return", "True" ]
Runs all the validators on the val Returns a bool success value
[ "Runs", "all", "the", "validators", "on", "the", "val", "Returns", "a", "bool", "success", "value" ]
[ "\"\"\"\n Runs all the validators on the val\n Returns a bool success value\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "val", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "val", "type": null, "docstring": null, "docstring_tokens": []...
1b3191e819ca05f42b54dd1f2b91e69b6f04726e
Saevon/PersOA
utils/seed.py
[ "MIT" ]
Python
_new
<not_specific>
def _new(seed): """ Creates a new seed based on the given value """ return NotImplemented
Creates a new seed based on the given value
Creates a new seed based on the given value
[ "Creates", "a", "new", "seed", "based", "on", "the", "given", "value" ]
def _new(seed): return NotImplemented
[ "def", "_new", "(", "seed", ")", ":", "return", "NotImplemented" ]
Creates a new seed based on the given value
[ "Creates", "a", "new", "seed", "based", "on", "the", "given", "value" ]
[ "\"\"\"\n Creates a new seed based on the given value\n \"\"\"" ]
[ { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "seed", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1b3191e819ca05f42b54dd1f2b91e69b6f04726e
Saevon/PersOA
utils/seed.py
[ "MIT" ]
Python
_randint
<not_specific>
def _randint(seed): """ Creates a new seed using random.randint """ return randint(Seed.INT_MIN, Seed.INT_MAX)
Creates a new seed using random.randint
Creates a new seed using random.randint
[ "Creates", "a", "new", "seed", "using", "random", ".", "randint" ]
def _randint(seed): return randint(Seed.INT_MIN, Seed.INT_MAX)
[ "def", "_randint", "(", "seed", ")", ":", "return", "randint", "(", "Seed", ".", "INT_MIN", ",", "Seed", ".", "INT_MAX", ")" ]
Creates a new seed using random.randint
[ "Creates", "a", "new", "seed", "using", "random", ".", "randint" ]
[ "\"\"\"\n Creates a new seed using random.randint\n \"\"\"" ]
[ { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "seed", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0bb407e11ab8468073d1415b22140cd224de4494
Saevon/PersOA
utils/decorators.py
[ "MIT" ]
Python
cascade
<not_specific>
def cascade(func): """ class method decorator, always returns the object that called the method """ @wraps(func) def wrapper(self, *args, **kwargs): func(self, *args, **kwargs) return self return wrapper
class method decorator, always returns the object that called the method
class method decorator, always returns the object that called the method
[ "class", "method", "decorator", "always", "returns", "the", "object", "that", "called", "the", "method" ]
def cascade(func): @wraps(func) def wrapper(self, *args, **kwargs): func(self, *args, **kwargs) return self return wrapper
[ "def", "cascade", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "func", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", "return", "self", "return", ...
class method decorator, always returns the object that called the method
[ "class", "method", "decorator", "always", "returns", "the", "object", "that", "called", "the", "method" ]
[ "\"\"\"\n class method decorator, always returns the\n object that called the method\n \"\"\"" ]
[ { "param": "func", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "func", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0bb407e11ab8468073d1415b22140cd224de4494
Saevon/PersOA
utils/decorators.py
[ "MIT" ]
Python
seeded
<not_specific>
def seeded(pos): """ Decorator: Looks for the positional pos(int) or keyword name(str) argument and if the argument is a list calls the function once for each item This changes the function to always return void """ def decorator(func): @wraps(func) def wrapper(*args, **kwar...
Decorator: Looks for the positional pos(int) or keyword name(str) argument and if the argument is a list calls the function once for each item This changes the function to always return void
Looks for the positional pos(int) or keyword name(str) argument and if the argument is a list calls the function once for each item This changes the function to always return void
[ "Looks", "for", "the", "positional", "pos", "(", "int", ")", "or", "keyword", "name", "(", "str", ")", "argument", "and", "if", "the", "argument", "is", "a", "list", "calls", "the", "function", "once", "for", "each", "item", "This", "changes", "the", "...
def seeded(pos): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): valid = lambda val: ( val if isinstance(val, Seed) else ( Seed(val) if isinstance(val, int) else Seed() ) )...
[ "def", "seeded", "(", "pos", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "valid", "=", "lambda", "val", ":", "(", "val", "if", "isinstance...
Decorator: Looks for the positional pos(int) or keyword name(str) argument and if the argument is a list calls the function once for each item
[ "Decorator", ":", "Looks", "for", "the", "positional", "pos", "(", "int", ")", "or", "keyword", "name", "(", "str", ")", "argument", "and", "if", "the", "argument", "is", "a", "list", "calls", "the", "function", "once", "for", "each", "item" ]
[ "\"\"\"\n Decorator:\n Looks for the positional pos(int) or keyword name(str) argument and if\n the argument is a list calls the function once for each item\n\n This changes the function to always return void\n \"\"\"" ]
[ { "param": "pos", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pos", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0bb407e11ab8468073d1415b22140cd224de4494
Saevon/PersOA
utils/decorators.py
[ "MIT" ]
Python
allow_list
<not_specific>
def allow_list(pos, name=None): """ Decorator: Looks for the positional pos(int) or keyword name(str) argument and if the argument is a list calls the function once for each item This changes the function to always return void """ def decorator(func): @wraps(func) def wrappe...
Decorator: Looks for the positional pos(int) or keyword name(str) argument and if the argument is a list calls the function once for each item This changes the function to always return void
Looks for the positional pos(int) or keyword name(str) argument and if the argument is a list calls the function once for each item This changes the function to always return void
[ "Looks", "for", "the", "positional", "pos", "(", "int", ")", "or", "keyword", "name", "(", "str", ")", "argument", "and", "if", "the", "argument", "is", "a", "list", "calls", "the", "function", "once", "for", "each", "item", "This", "changes", "the", "...
def allow_list(pos, name=None): def decorator(func): @wraps(func) def wrapper(*args, **kwargs): if len(args) > pos: args = list(args) source = args key = pos elif name is not None and name in kwargs: source = kwa...
[ "def", "allow_list", "(", "pos", ",", "name", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "if", "len", "(", "args", ")", ">...
Decorator: Looks for the positional pos(int) or keyword name(str) argument and if the argument is a list calls the function once for each item
[ "Decorator", ":", "Looks", "for", "the", "positional", "pos", "(", "int", ")", "or", "keyword", "name", "(", "str", ")", "argument", "and", "if", "the", "argument", "is", "a", "list", "calls", "the", "function", "once", "for", "each", "item" ]
[ "\"\"\"\n Decorator:\n Looks for the positional pos(int) or keyword name(str) argument and if\n the argument is a list calls the function once for each item\n\n This changes the function to always return void\n \"\"\"", "# args is normally an immutable tuple", "# The argument wasn't passed in .: ...
[ { "param": "pos", "type": null }, { "param": "name", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pos", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": null, "docstring": null, "docstring_tokens": []...
74ef1846090b7439680a1b6f0a8a278f03ab12b3
Saevon/PersOA
app/models/trait.py
[ "MIT" ]
Python
details
<not_specific>
def details(self, include=None): """ Returns a dict with the trait's details """ details = self.data() if include is None: return details elif include['trait_name']: return self.name include['trait'] = False if include['choice']: ...
Returns a dict with the trait's details
Returns a dict with the trait's details
[ "Returns", "a", "dict", "with", "the", "trait", "'", "s", "details" ]
def details(self, include=None): details = self.data() if include is None: return details elif include['trait_name']: return self.name include['trait'] = False if include['choice']: details.update({ 'choices': [choice.details(in...
[ "def", "details", "(", "self", ",", "include", "=", "None", ")", ":", "details", "=", "self", ".", "data", "(", ")", "if", "include", "is", "None", ":", "return", "details", "elif", "include", "[", "'trait_name'", "]", ":", "return", "self", ".", "na...
Returns a dict with the trait's details
[ "Returns", "a", "dict", "with", "the", "trait", "'", "s", "details" ]
[ "\"\"\"\n Returns a dict with the trait's details\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "include", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "include", "type": null, "docstring": null, "docstring_tokens"...
74ef1846090b7439680a1b6f0a8a278f03ab12b3
Saevon/PersOA
app/models/trait.py
[ "MIT" ]
Python
data
<not_specific>
def data(self): """ Returns a dict with the basic details """ return { 'type': None, 'name': self.name, 'desc': self.desc, 'defn': self.defn, }
Returns a dict with the basic details
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
def data(self): return { 'type': None, 'name': self.name, 'desc': self.desc, 'defn': self.defn, }
[ "def", "data", "(", "self", ")", ":", "return", "{", "'type'", ":", "None", ",", "'name'", ":", "self", ".", "name", ",", "'desc'", ":", "self", ".", "desc", ",", "'defn'", ":", "self", ".", "defn", ",", "}" ]
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
[ "\"\"\"\n Returns a dict with the basic details\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
74ef1846090b7439680a1b6f0a8a278f03ab12b3
Saevon/PersOA
app/models/trait.py
[ "MIT" ]
Python
generate
<not_specific>
def generate(self, num=None, seed=None): """ Returns num choices from this trait using the given seed """ return NotImplemented
Returns num choices from this trait using the given seed
Returns num choices from this trait using the given seed
[ "Returns", "num", "choices", "from", "this", "trait", "using", "the", "given", "seed" ]
def generate(self, num=None, seed=None): return NotImplemented
[ "def", "generate", "(", "self", ",", "num", "=", "None", ",", "seed", "=", "None", ")", ":", "return", "NotImplemented" ]
Returns num choices from this trait using the given seed
[ "Returns", "num", "choices", "from", "this", "trait", "using", "the", "given", "seed" ]
[ "\"\"\"\n Returns num choices from this trait using the given seed\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "num", "type": null }, { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num", "type": null, "docstring": null, "docstring_tokens": []...
74ef1846090b7439680a1b6f0a8a278f03ab12b3
Saevon/PersOA
app/models/trait.py
[ "MIT" ]
Python
data
<not_specific>
def data(self): """ Returns a dict with the basic details """ details = super(BasicTrait, self).data() details.update({ 'type': 'basic', 'default_num': self.default_num }) return details
Returns a dict with the basic details
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
def data(self): details = super(BasicTrait, self).data() details.update({ 'type': 'basic', 'default_num': self.default_num }) return details
[ "def", "data", "(", "self", ")", ":", "details", "=", "super", "(", "BasicTrait", ",", "self", ")", ".", "data", "(", ")", "details", ".", "update", "(", "{", "'type'", ":", "'basic'", ",", "'default_num'", ":", "self", ".", "default_num", "}", ")", ...
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
[ "\"\"\"\n Returns a dict with the basic details\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
74ef1846090b7439680a1b6f0a8a278f03ab12b3
Saevon/PersOA
app/models/trait.py
[ "MIT" ]
Python
generate
<not_specific>
def generate(self, num=None, seed=None): """ Returns num choices from this trait using the given seed """ if num is None: num = self.default_num length = len(self.choices.all()) choices = [] for i in range(num): num = seed() % length ...
Returns num choices from this trait using the given seed
Returns num choices from this trait using the given seed
[ "Returns", "num", "choices", "from", "this", "trait", "using", "the", "given", "seed" ]
def generate(self, num=None, seed=None): if num is None: num = self.default_num length = len(self.choices.all()) choices = [] for i in range(num): num = seed() % length choice = self.choices.all()[num] choices.append(choice.generate(seed)) ...
[ "def", "generate", "(", "self", ",", "num", "=", "None", ",", "seed", "=", "None", ")", ":", "if", "num", "is", "None", ":", "num", "=", "self", ".", "default_num", "length", "=", "len", "(", "self", ".", "choices", ".", "all", "(", ")", ")", "...
Returns num choices from this trait using the given seed
[ "Returns", "num", "choices", "from", "this", "trait", "using", "the", "given", "seed" ]
[ "\"\"\"\n Returns num choices from this trait using the given seed\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "num", "type": null }, { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num", "type": null, "docstring": null, "docstring_tokens": []...
74ef1846090b7439680a1b6f0a8a278f03ab12b3
Saevon/PersOA
app/models/trait.py
[ "MIT" ]
Python
data
<not_specific>
def data(self): """ Returns a dict with the basic details """ details = super(LinearTrait, self).data() details.update({ 'type': 'scale', 'neg': self.neg_name, 'pos': self.pos_name, }) return details
Returns a dict with the basic details
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
def data(self): details = super(LinearTrait, self).data() details.update({ 'type': 'scale', 'neg': self.neg_name, 'pos': self.pos_name, }) return details
[ "def", "data", "(", "self", ")", ":", "details", "=", "super", "(", "LinearTrait", ",", "self", ")", ".", "data", "(", ")", "details", ".", "update", "(", "{", "'type'", ":", "'scale'", ",", "'neg'", ":", "self", ".", "neg_name", ",", "'pos'", ":",...
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
[ "\"\"\"\n Returns a dict with the basic details\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
74ef1846090b7439680a1b6f0a8a278f03ab12b3
Saevon/PersOA
app/models/trait.py
[ "MIT" ]
Python
generate
<not_specific>
def generate(self, num=None, seed=None): """ Returns num choices from this trait using the given seed """ if num is None: num = 1 length = len(self.choices.all()) choices = [] for i in range(num): num = seed() % length choice ...
Returns num choices from this trait using the given seed
Returns num choices from this trait using the given seed
[ "Returns", "num", "choices", "from", "this", "trait", "using", "the", "given", "seed" ]
def generate(self, num=None, seed=None): if num is None: num = 1 length = len(self.choices.all()) choices = [] for i in range(num): num = seed() % length choice = self.choices.all()[num] choices.append(choice.generate(seed)) return ...
[ "def", "generate", "(", "self", ",", "num", "=", "None", ",", "seed", "=", "None", ")", ":", "if", "num", "is", "None", ":", "num", "=", "1", "length", "=", "len", "(", "self", ".", "choices", ".", "all", "(", ")", ")", "choices", "=", "[", "...
Returns num choices from this trait using the given seed
[ "Returns", "num", "choices", "from", "this", "trait", "using", "the", "given", "seed" ]
[ "\"\"\"\n Returns num choices from this trait using the given seed\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "num", "type": null }, { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num", "type": null, "docstring": null, "docstring_tokens": []...
06e80fff8cbd8ef72b374ddcec626e2f99a7a067
Saevon/PersOA
app/models/choice.py
[ "MIT" ]
Python
details
<not_specific>
def details(self, include=None): """ Returns a dict with the choice's details Note: For this to work the sub-class needs to have a trait property """ details = self.data() if include is None: return details elif include['choice_name']: ...
Returns a dict with the choice's details Note: For this to work the sub-class needs to have a trait property
Returns a dict with the choice's details Note: For this to work the sub-class needs to have a trait property
[ "Returns", "a", "dict", "with", "the", "choice", "'", "s", "details", "Note", ":", "For", "this", "to", "work", "the", "sub", "-", "class", "needs", "to", "have", "a", "trait", "property" ]
def details(self, include=None): details = self.data() if include is None: return details elif include['choice_name']: return self.name include['choice'] = False if include['trait']: details['trait'] = self.trait.details(include) return...
[ "def", "details", "(", "self", ",", "include", "=", "None", ")", ":", "details", "=", "self", ".", "data", "(", ")", "if", "include", "is", "None", ":", "return", "details", "elif", "include", "[", "'choice_name'", "]", ":", "return", "self", ".", "n...
Returns a dict with the choice's details Note: For this to work the sub-class needs to have a trait property
[ "Returns", "a", "dict", "with", "the", "choice", "'", "s", "details", "Note", ":", "For", "this", "to", "work", "the", "sub", "-", "class", "needs", "to", "have", "a", "trait", "property" ]
[ "\"\"\"\n Returns a dict with the choice's details\n Note: For this to work the sub-class needs to have a trait property\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "include", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "include", "type": null, "docstring": null, "docstring_tokens"...
06e80fff8cbd8ef72b374ddcec626e2f99a7a067
Saevon/PersOA
app/models/choice.py
[ "MIT" ]
Python
data
<not_specific>
def data(self): """ Returns a dict with the basic details """ return { 'name': self.name, 'desc': self.desc, 'defn': self.defn, }
Returns a dict with the basic details
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
def data(self): return { 'name': self.name, 'desc': self.desc, 'defn': self.defn, }
[ "def", "data", "(", "self", ")", ":", "return", "{", "'name'", ":", "self", ".", "name", ",", "'desc'", ":", "self", ".", "desc", ",", "'defn'", ":", "self", ".", "defn", ",", "}" ]
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
[ "\"\"\"\n Returns a dict with the basic details\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
06e80fff8cbd8ef72b374ddcec626e2f99a7a067
Saevon/PersOA
app/models/choice.py
[ "MIT" ]
Python
generate
<not_specific>
def generate(self, seed=None): """ Returns a choice or a sub_choice """ if len(self.sub_choices.all()): num = seed() % len(self.sub_choices.all()) return self.sub_choices.all()[num] return self
Returns a choice or a sub_choice
Returns a choice or a sub_choice
[ "Returns", "a", "choice", "or", "a", "sub_choice" ]
def generate(self, seed=None): if len(self.sub_choices.all()): num = seed() % len(self.sub_choices.all()) return self.sub_choices.all()[num] return self
[ "def", "generate", "(", "self", ",", "seed", "=", "None", ")", ":", "if", "len", "(", "self", ".", "sub_choices", ".", "all", "(", ")", ")", ":", "num", "=", "seed", "(", ")", "%", "len", "(", "self", ".", "sub_choices", ".", "all", "(", ")", ...
Returns a choice or a sub_choice
[ "Returns", "a", "choice", "or", "a", "sub_choice" ]
[ "\"\"\"\n Returns a choice or a sub_choice\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "seed", "type": null, "docstring": null, "docstring_tokens": [...
06e80fff8cbd8ef72b374ddcec626e2f99a7a067
Saevon/PersOA
app/models/choice.py
[ "MIT" ]
Python
details
<not_specific>
def details(self, include=None): """ Returns data that is shown if this was generated """ details = self.data() if include is None: pass elif include['choice_name']: return '%(choice)s :: %(name)s' % { 'choice': self.choice.name, ...
Returns data that is shown if this was generated
Returns data that is shown if this was generated
[ "Returns", "data", "that", "is", "shown", "if", "this", "was", "generated" ]
def details(self, include=None): details = self.data() if include is None: pass elif include['choice_name']: return '%(choice)s :: %(name)s' % { 'choice': self.choice.name, 'name': self.name, } return details
[ "def", "details", "(", "self", ",", "include", "=", "None", ")", ":", "details", "=", "self", ".", "data", "(", ")", "if", "include", "is", "None", ":", "pass", "elif", "include", "[", "'choice_name'", "]", ":", "return", "'%(choice)s :: %(name)s'", "%",...
Returns data that is shown if this was generated
[ "Returns", "data", "that", "is", "shown", "if", "this", "was", "generated" ]
[ "\"\"\"\n Returns data that is shown if this was generated\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "include", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "include", "type": null, "docstring": null, "docstring_tokens"...
06e80fff8cbd8ef72b374ddcec626e2f99a7a067
Saevon/PersOA
app/models/choice.py
[ "MIT" ]
Python
data
<not_specific>
def data(self): """ Returns a dict with the basic details """ return { 'name': '%(choice)s :: %(name)s' % { 'choice': self.choice.name, 'name': self.name, }, 'defn': self.defn, }
Returns a dict with the basic details
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
def data(self): return { 'name': '%(choice)s :: %(name)s' % { 'choice': self.choice.name, 'name': self.name, }, 'defn': self.defn, }
[ "def", "data", "(", "self", ")", ":", "return", "{", "'name'", ":", "'%(choice)s :: %(name)s'", "%", "{", "'choice'", ":", "self", ".", "choice", ".", "name", ",", "'name'", ":", "self", ".", "name", ",", "}", ",", "'defn'", ":", "self", ".", "defn",...
Returns a dict with the basic details
[ "Returns", "a", "dict", "with", "the", "basic", "details" ]
[ "\"\"\"\n Returns a dict with the basic details\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0eb9368b0fbd40ef9204da4fc718f76deb180276
Saevon/PersOA
app/views/whitelist.py
[ "MIT" ]
Python
add
null
def add(self, field): """ Adds a list of fields to the whitelist Used to add constant field groups """ key = field.get_name() if key in self._whitelist: raise KeyError self._whitelist[key] = field
Adds a list of fields to the whitelist Used to add constant field groups
Adds a list of fields to the whitelist Used to add constant field groups
[ "Adds", "a", "list", "of", "fields", "to", "the", "whitelist", "Used", "to", "add", "constant", "field", "groups" ]
def add(self, field): key = field.get_name() if key in self._whitelist: raise KeyError self._whitelist[key] = field
[ "def", "add", "(", "self", ",", "field", ")", ":", "key", "=", "field", ".", "get_name", "(", ")", "if", "key", "in", "self", ".", "_whitelist", ":", "raise", "KeyError", "self", ".", "_whitelist", "[", "key", "]", "=", "field" ]
Adds a list of fields to the whitelist Used to add constant field groups
[ "Adds", "a", "list", "of", "fields", "to", "the", "whitelist", "Used", "to", "add", "constant", "field", "groups" ]
[ "\"\"\"\n Adds a list of fields to the whitelist\n Used to add constant field groups\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "field", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "field", "type": null, "docstring": null, "docstring_tokens": ...
0eb9368b0fbd40ef9204da4fc718f76deb180276
Saevon/PersOA
app/views/whitelist.py
[ "MIT" ]
Python
remove
null
def remove(self, field): """ Removes a field from the whitelist Useful if you add groups of fields """ key = field.get_name() # Could raise a KeyEror self._whitelist.pop(key) self._includes.pop(key) self._include_names.pop(key)
Removes a field from the whitelist Useful if you add groups of fields
Removes a field from the whitelist Useful if you add groups of fields
[ "Removes", "a", "field", "from", "the", "whitelist", "Useful", "if", "you", "add", "groups", "of", "fields" ]
def remove(self, field): key = field.get_name() self._whitelist.pop(key) self._includes.pop(key) self._include_names.pop(key)
[ "def", "remove", "(", "self", ",", "field", ")", ":", "key", "=", "field", ".", "get_name", "(", ")", "self", ".", "_whitelist", ".", "pop", "(", "key", ")", "self", ".", "_includes", ".", "pop", "(", "key", ")", "self", ".", "_include_names", ".",...
Removes a field from the whitelist Useful if you add groups of fields
[ "Removes", "a", "field", "from", "the", "whitelist", "Useful", "if", "you", "add", "groups", "of", "fields" ]
[ "\"\"\"\n Removes a field from the whitelist\n Useful if you add groups of fields\n \"\"\"", "# Could raise a KeyEror" ]
[ { "param": "self", "type": null }, { "param": "field", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "field", "type": null, "docstring": null, "docstring_tokens": ...
0eb9368b0fbd40ef9204da4fc718f76deb180276
Saevon/PersOA
app/views/whitelist.py
[ "MIT" ]
Python
error
null
def error(self, err): """ Adds a new error to its list """ self._errors.append(err)
Adds a new error to its list
Adds a new error to its list
[ "Adds", "a", "new", "error", "to", "its", "list" ]
def error(self, err): self._errors.append(err)
[ "def", "error", "(", "self", ",", "err", ")", ":", "self", ".", "_errors", ".", "append", "(", "err", ")" ]
Adds a new error to its list
[ "Adds", "a", "new", "error", "to", "its", "list" ]
[ "\"\"\"\n Adds a new error to its list\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "err", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "err", "type": null, "docstring": null, "docstring_tokens": []...
0eb9368b0fbd40ef9204da4fc718f76deb180276
Saevon/PersOA
app/views/whitelist.py
[ "MIT" ]
Python
leftover
null
def leftover(self, Err): """ Adds any unused params to errors if type Err """ for key in self._left: self.error(Err(key))
Adds any unused params to errors if type Err
Adds any unused params to errors if type Err
[ "Adds", "any", "unused", "params", "to", "errors", "if", "type", "Err" ]
def leftover(self, Err): for key in self._left: self.error(Err(key))
[ "def", "leftover", "(", "self", ",", "Err", ")", ":", "for", "key", "in", "self", ".", "_left", ":", "self", ".", "error", "(", "Err", "(", "key", ")", ")" ]
Adds any unused params to errors if type Err
[ "Adds", "any", "unused", "params", "to", "errors", "if", "type", "Err" ]
[ "\"\"\"\n Adds any unused params to errors if type Err\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "Err", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "Err", "type": null, "docstring": null, "docstring_tokens": []...
0eb9368b0fbd40ef9204da4fc718f76deb180276
Saevon/PersOA
app/views/whitelist.py
[ "MIT" ]
Python
clear
null
def clear(self): """ clears any errors that may have occured """ self._errors = [] self._left = []
clears any errors that may have occured
clears any errors that may have occured
[ "clears", "any", "errors", "that", "may", "have", "occured" ]
def clear(self): self._errors = [] self._left = []
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_errors", "=", "[", "]", "self", ".", "_left", "=", "[", "]" ]
clears any errors that may have occured
[ "clears", "any", "errors", "that", "may", "have", "occured" ]
[ "\"\"\"\n clears any errors that may have occured\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0eb9368b0fbd40ef9204da4fc718f76deb180276
Saevon/PersOA
app/views/whitelist.py
[ "MIT" ]
Python
process
<not_specific>
def process(self, params): """ Reads params(dict) and returns a whitelisted dict. """ self._final = { Whitelist.INCLUDE_NAME: self._include_names.copy() } self._fields = set(self._whitelist.keys()) self._fields.remove(Whitelist.INCLUDE_NAME) #...
Reads params(dict) and returns a whitelisted dict.
Reads params(dict) and returns a whitelisted dict.
[ "Reads", "params", "(", "dict", ")", "and", "returns", "a", "whitelisted", "dict", "." ]
def process(self, params): self._final = { Whitelist.INCLUDE_NAME: self._include_names.copy() } self._fields = set(self._whitelist.keys()) self._fields.remove(Whitelist.INCLUDE_NAME) self._left = params.keys() try: includes = self._whitelist[Whitel...
[ "def", "process", "(", "self", ",", "params", ")", ":", "self", ".", "_final", "=", "{", "Whitelist", ".", "INCLUDE_NAME", ":", "self", ".", "_include_names", ".", "copy", "(", ")", "}", "self", ".", "_fields", "=", "set", "(", "self", ".", "_whiteli...
Reads params(dict) and returns a whitelisted dict.
[ "Reads", "params", "(", "dict", ")", "and", "returns", "a", "whitelisted", "dict", "." ]
[ "\"\"\"\n Reads params(dict) and returns a whitelisted dict.\n \"\"\"", "# Get the list of all keys, to subtract those that get used", "# Find what is included", "# TODO: Really... the best I can think of is a staircase?", "# Get the other fields" ]
[ { "param": "self", "type": null }, { "param": "params", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "params", "type": null, "docstring": null, "docstring_tokens":...
76e52d0463116dd0a8958e86ca32736d1fba2a2d
Saevon/PersOA
app/views/sanitize.py
[ "MIT" ]
Python
json_return
<not_specific>
def json_return(func): """ Wraps the returned object in a HttpResponse after a json dump, returning that instead """ @wraps(func) def wrapper(*args, **kwargs): data = func(*args, **kwargs) response = HttpResponse(content_type='application/json') simplejson.dump(data, res...
Wraps the returned object in a HttpResponse after a json dump, returning that instead
Wraps the returned object in a HttpResponse after a json dump, returning that instead
[ "Wraps", "the", "returned", "object", "in", "a", "HttpResponse", "after", "a", "json", "dump", "returning", "that", "instead" ]
def json_return(func): @wraps(func) def wrapper(*args, **kwargs): data = func(*args, **kwargs) response = HttpResponse(content_type='application/json') simplejson.dump(data, response) return response return wrapper
[ "def", "json_return", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "data", "=", "func", "(", "*", "args", ",", "**", "kwargs", ")", "response", "=", "HttpResponse", "(", ...
Wraps the returned object in a HttpResponse after a json dump, returning that instead
[ "Wraps", "the", "returned", "object", "in", "a", "HttpResponse", "after", "a", "json", "dump", "returning", "that", "instead" ]
[ "\"\"\"\n Wraps the returned object in a HttpResponse after a json dump,\n returning that instead\n \"\"\"" ]
[ { "param": "func", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "func", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
76e52d0463116dd0a8958e86ca32736d1fba2a2d
Saevon/PersOA
app/views/sanitize.py
[ "MIT" ]
Python
error
null
def error(self, errors): """ Adds a new error to show to the user """ self.problem = False if isinstance(errors, list): for err in errors: self.__error(err) else: self.__error(errors) if self.problem: raise Per...
Adds a new error to show to the user
Adds a new error to show to the user
[ "Adds", "a", "new", "error", "to", "show", "to", "the", "user" ]
def error(self, errors): self.problem = False if isinstance(errors, list): for err in errors: self.__error(err) else: self.__error(errors) if self.problem: raise PersOAEarlyFinish
[ "def", "error", "(", "self", ",", "errors", ")", ":", "self", ".", "problem", "=", "False", "if", "isinstance", "(", "errors", ",", "list", ")", ":", "for", "err", "in", "errors", ":", "self", ".", "__error", "(", "err", ")", "else", ":", "self", ...
Adds a new error to show to the user
[ "Adds", "a", "new", "error", "to", "show", "to", "the", "user" ]
[ "\"\"\"\n Adds a new error to show to the user\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "errors", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "errors", "type": null, "docstring": null, "docstring_tokens":...
76e52d0463116dd0a8958e86ca32736d1fba2a2d
Saevon/PersOA
app/views/sanitize.py
[ "MIT" ]
Python
output
null
def output(self, out): """ Sets the output to show the user """ self._out['output'] = out
Sets the output to show the user
Sets the output to show the user
[ "Sets", "the", "output", "to", "show", "the", "user" ]
def output(self, out): self._out['output'] = out
[ "def", "output", "(", "self", ",", "out", ")", ":", "self", ".", "_out", "[", "'output'", "]", "=", "out" ]
Sets the output to show the user
[ "Sets", "the", "output", "to", "show", "the", "user" ]
[ "\"\"\"\n Sets the output to show the user\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "out", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out", "type": null, "docstring": null, "docstring_tokens": []...
76e52d0463116dd0a8958e86ca32736d1fba2a2d
Saevon/PersOA
app/views/sanitize.py
[ "MIT" ]
Python
persoa_output
<not_specific>
def persoa_output(func): """ Passes in a new PersOAOutput to the function every call and catches any problem with the input """ @wraps(func) def wrapper(*args, **kwargs): out = PersOAOutput() kwargs['output'] = out try: func(*args, **kwargs) except PersOAE...
Passes in a new PersOAOutput to the function every call and catches any problem with the input
Passes in a new PersOAOutput to the function every call and catches any problem with the input
[ "Passes", "in", "a", "new", "PersOAOutput", "to", "the", "function", "every", "call", "and", "catches", "any", "problem", "with", "the", "input" ]
def persoa_output(func): @wraps(func) def wrapper(*args, **kwargs): out = PersOAOutput() kwargs['output'] = out try: func(*args, **kwargs) except PersOAEarlyFinish: pass return out.sanitize() return wrapper
[ "def", "persoa_output", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "kwargs", ")", ":", "out", "=", "PersOAOutput", "(", ")", "kwargs", "[", "'output'", "]", "=", "out", "try", ":", "func", ...
Passes in a new PersOAOutput to the function every call and catches any problem with the input
[ "Passes", "in", "a", "new", "PersOAOutput", "to", "the", "function", "every", "call", "and", "catches", "any", "problem", "with", "the", "input" ]
[ "\"\"\"\n Passes in a new PersOAOutput to the function every call and catches any problem with the input\n \"\"\"" ]
[ { "param": "func", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "func", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
299ca1bf95b78223191ef50d86c468c356b8fb6e
opentargets/library-beam
modules/NLP.py
[ "Apache-2.0" ]
Python
digest
<not_specific>
def digest(self, text): normalized = self.normalizer.normalize(text) parsed = TextBlob(normalized, np_extractor=self.np_ex) counted_noun_phrases = parsed.noun_phrases abbreviations = self.abbreviations_finder.digest(parsed) '''make sure defined acronym are used as noun phrases ''...
make sure defined acronym are used as noun phrases
make sure defined acronym are used as noun phrases
[ "make", "sure", "defined", "acronym", "are", "used", "as", "noun", "phrases" ]
def digest(self, text): normalized = self.normalizer.normalize(text) parsed = TextBlob(normalized, np_extractor=self.np_ex) counted_noun_phrases = parsed.noun_phrases abbreviations = self.abbreviations_finder.digest(parsed) for abbr in abbreviations: if abbr['long'].l...
[ "def", "digest", "(", "self", ",", "text", ")", ":", "normalized", "=", "self", ".", "normalizer", ".", "normalize", "(", "text", ")", "parsed", "=", "TextBlob", "(", "normalized", ",", "np_extractor", "=", "self", ".", "np_ex", ")", "counted_noun_phrases"...
make sure defined acronym are used as noun phrases
[ "make", "sure", "defined", "acronym", "are", "used", "as", "noun", "phrases" ]
[ "'''make sure defined acronym are used as noun phrases '''", "'''improved singularisation still needs refinement'''", "# singular_counted_noun_phrases = []", "# for np in counted_noun_phrases:", "# if not (np.endswith('sis') or np.endswith('ess')):", "# singular_counted_noun_phrases.append(sin...
[ { "param": "self", "type": null }, { "param": "text", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [...
299ca1bf95b78223191ef50d86c468c356b8fb6e
opentargets/library-beam
modules/NLP.py
[ "Apache-2.0" ]
Python
traverse_obj_children
null
def traverse_obj_children(self, tok, verb_path): ''' iterate over all the children and the conjuncts to return objects within the same chain of verbs :param tok: :param verb_path: :return: ''' for i in tok.children: # print i, verb_path, get_verb_path_...
iterate over all the children and the conjuncts to return objects within the same chain of verbs :param tok: :param verb_path: :return:
iterate over all the children and the conjuncts to return objects within the same chain of verbs
[ "iterate", "over", "all", "the", "children", "and", "the", "conjuncts", "to", "return", "objects", "within", "the", "same", "chain", "of", "verbs" ]
def traverse_obj_children(self, tok, verb_path): for i in tok.children: if i.dep_ in OBJECTS and (self.get_verb_path_from_ancestors(i) == verb_path): yield i else: self.traverse_obj_children(i, verb_path) for i in tok.conjuncts: if i.de...
[ "def", "traverse_obj_children", "(", "self", ",", "tok", ",", "verb_path", ")", ":", "for", "i", "in", "tok", ".", "children", ":", "if", "i", ".", "dep_", "in", "OBJECTS", "and", "(", "self", ".", "get_verb_path_from_ancestors", "(", "i", ")", "==", "...
iterate over all the children and the conjuncts to return objects within the same chain of verbs
[ "iterate", "over", "all", "the", "children", "and", "the", "conjuncts", "to", "return", "objects", "within", "the", "same", "chain", "of", "verbs" ]
[ "'''\n iterate over all the children and the conjuncts to return objects within the same chain of verbs\n :param tok:\n :param verb_path:\n :return:\n '''", "# print i, verb_path, get_verb_path_from_ancestors(i), get_verb_path_from_ancestors(i) ==verb_path", "# print i, verb_p...
[ { "param": "self", "type": null }, { "param": "tok", "type": null }, { "param": "verb_path", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
299ca1bf95b78223191ef50d86c468c356b8fb6e
opentargets/library-beam
modules/NLP.py
[ "Apache-2.0" ]
Python
collapse_noun_phrases_by_punctation
null
def collapse_noun_phrases_by_punctation(self): ''' this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences :param sentence: :return: ''' prev_span = '' open_brackets = u'( { [ <'.split() closed_brackets = u') }...
this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences :param sentence: :return:
this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences
[ "this", "collapse", "needs", "tobe", "used", "on", "a", "single", "sentence", "otherwise", "it", "will", "ocncatenate", "different", "sentences" ]
def collapse_noun_phrases_by_punctation(self): prev_span = '' open_brackets = u'( { [ <'.split() closed_brackets = u') } ] >'.split() for token in self.sentence: try: if token.text in open_brackets and token.whitespace_ == u'': next_token =...
[ "def", "collapse_noun_phrases_by_punctation", "(", "self", ")", ":", "prev_span", "=", "''", "open_brackets", "=", "u'( { [ <'", ".", "split", "(", ")", "closed_brackets", "=", "u') } ] >'", ".", "split", "(", ")", "for", "token", "in", "self", ".", "sentence"...
this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences
[ "this", "collapse", "needs", "tobe", "used", "on", "a", "single", "sentence", "otherwise", "it", "will", "ocncatenate", "different", "sentences" ]
[ "'''\n this collapse needs tobe used on a single sentence, otherwise it will ocncatenate different sentences\n :param sentence:\n :return:\n '''", "# prev_span = span.text", "# prev_span = span.text", "# skip end of sentence" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
8ba2ad2987e18e1be9491b7a71ab4b19bd62f246
opentargets/library-beam
main.py
[ "Apache-2.0" ]
Python
start_bundle
null
def start_bundle(self): """Called before a bundle of elements is processed on a worker. Elements to be processed are split into bundles and distributed to workers. Before a worker calls process() on the first element of its bundle, it calls this method. """ if not hasatt...
Called before a bundle of elements is processed on a worker. Elements to be processed are split into bundles and distributed to workers. Before a worker calls process() on the first element of its bundle, it calls this method.
Called before a bundle of elements is processed on a worker. Elements to be processed are split into bundles and distributed to workers. Before a worker calls process() on the first element of its bundle, it calls this method.
[ "Called", "before", "a", "bundle", "of", "elements", "is", "processed", "on", "a", "worker", ".", "Elements", "to", "be", "processed", "are", "split", "into", "bundles", "and", "distributed", "to", "workers", ".", "Before", "a", "worker", "calls", "process",...
def start_bundle(self): if not hasattr(self, 'tagger'): self.init_tagger()
[ "def", "start_bundle", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'tagger'", ")", ":", "self", ".", "init_tagger", "(", ")" ]
Called before a bundle of elements is processed on a worker.
[ "Called", "before", "a", "bundle", "of", "elements", "is", "processed", "on", "a", "worker", "." ]
[ "\"\"\"Called before a bundle of elements is processed on a worker.\n\n Elements to be processed are split into bundles and distributed\n to workers. Before a worker calls process() on the first element\n of its bundle, it calls this method.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8ba2ad2987e18e1be9491b7a71ab4b19bd62f246
opentargets/library-beam
main.py
[ "Apache-2.0" ]
Python
start_bundle
null
def start_bundle(self): """Called before a bundle of elements is processed on a worker. Elements to be processed are split into bundles and distributed to workers. Before a worker calls process() on the first element of its bundle, it calls this method. """ if not getatt...
Called before a bundle of elements is processed on a worker. Elements to be processed are split into bundles and distributed to workers. Before a worker calls process() on the first element of its bundle, it calls this method.
Called before a bundle of elements is processed on a worker. Elements to be processed are split into bundles and distributed to workers. Before a worker calls process() on the first element of its bundle, it calls this method.
[ "Called", "before", "a", "bundle", "of", "elements", "is", "processed", "on", "a", "worker", ".", "Elements", "to", "be", "processed", "are", "split", "into", "bundles", "and", "distributed", "to", "workers", ".", "Before", "a", "worker", "calls", "process",...
def start_bundle(self): if not getattr(self, 'nlp', None): self.init_models() else: logging.debug('NLP MODEL already initialized')
[ "def", "start_bundle", "(", "self", ")", ":", "if", "not", "getattr", "(", "self", ",", "'nlp'", ",", "None", ")", ":", "self", ".", "init_models", "(", ")", "else", ":", "logging", ".", "debug", "(", "'NLP MODEL already initialized'", ")" ]
Called before a bundle of elements is processed on a worker.
[ "Called", "before", "a", "bundle", "of", "elements", "is", "processed", "on", "a", "worker", "." ]
[ "\"\"\"Called before a bundle of elements is processed on a worker.\n\n Elements to be processed are split into bundles and distributed\n to workers. Before a worker calls process() on the first element\n of its bundle, it calls this method.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8ba2ad2987e18e1be9491b7a71ab4b19bd62f246
opentargets/library-beam
main.py
[ "Apache-2.0" ]
Python
run
null
def run(argv=None): """Main entry point; defines and runs the tfidf pipeline.""" parser = argparse.ArgumentParser() parser.add_argument('--input_baseline', required=False, help='baseline URIs to process.') parser.add_argument('--input_updates', ...
Main entry point; defines and runs the tfidf pipeline.
Main entry point; defines and runs the tfidf pipeline.
[ "Main", "entry", "point", ";", "defines", "and", "runs", "the", "tfidf", "pipeline", "." ]
def run(argv=None): parser = argparse.ArgumentParser() parser.add_argument('--input_baseline', required=False, help='baseline URIs to process.') parser.add_argument('--input_updates', required=False, help='update...
[ "def", "run", "(", "argv", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--input_baseline'", ",", "required", "=", "False", ",", "help", "=", "'baseline URIs to process.'", ")", "pars...
Main entry point; defines and runs the tfidf pipeline.
[ "Main", "entry", "point", ";", "defines", "and", "runs", "the", "tfidf", "pipeline", "." ]
[ "\"\"\"Main entry point; defines and runs the tfidf pipeline.\"\"\"", "# bq_table_schema = parse_bq_json_schema(json.load(open('schemas/medline.papers.json')))", "# We use the save_main_session option because one or more DoFn's in this", "# workflow rely on global context (e.g., a module imported at module le...
[ { "param": "argv", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "argv", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
15fe273b5dfdea711ba4d4933673322c2b7577b2
dcavar/dcavar.github.io
IntroCModelingLA/Code/ngramchar.py
[ "Apache-2.0" ]
Python
sort_by_value
<not_specific>
def sort_by_value(d): """ Returns the keys of dictionary d sorted by their values """ items=d.items() backitems=[ [v[1],v[0]] for v in items] backitems.sort() backitems.reverse() return [ backitems[i][1] for i in range(0,len(backitems))]
Returns the keys of dictionary d sorted by their values
Returns the keys of dictionary d sorted by their values
[ "Returns", "the", "keys", "of", "dictionary", "d", "sorted", "by", "their", "values" ]
def sort_by_value(d): items=d.items() backitems=[ [v[1],v[0]] for v in items] backitems.sort() backitems.reverse() return [ backitems[i][1] for i in range(0,len(backitems))]
[ "def", "sort_by_value", "(", "d", ")", ":", "items", "=", "d", ".", "items", "(", ")", "backitems", "=", "[", "[", "v", "[", "1", "]", ",", "v", "[", "0", "]", "]", "for", "v", "in", "items", "]", "backitems", ".", "sort", "(", ")", "backitem...
Returns the keys of dictionary d sorted by their values
[ "Returns", "the", "keys", "of", "dictionary", "d", "sorted", "by", "their", "values" ]
[ "\"\"\" Returns the keys of dictionary d sorted by their values \"\"\"" ]
[ { "param": "d", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "d", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
93cbcad8dcdd74c07e4f38e510f3ddc260686c74
dcavar/dcavar.github.io
pycl/Code/chi2.py
[ "Apache-2.0" ]
Python
isSignificant
<not_specific>
def isSignificant(self, sample, expectation, level): """Returns the significance of the difference between two samples.""" val = self.getSignificance(self.getChi2Value(sample, expectation), self.getDF(sample)) if val <= level: return True return False
Returns the significance of the difference between two samples.
Returns the significance of the difference between two samples.
[ "Returns", "the", "significance", "of", "the", "difference", "between", "two", "samples", "." ]
def isSignificant(self, sample, expectation, level): val = self.getSignificance(self.getChi2Value(sample, expectation), self.getDF(sample)) if val <= level: return True return False
[ "def", "isSignificant", "(", "self", ",", "sample", ",", "expectation", ",", "level", ")", ":", "val", "=", "self", ".", "getSignificance", "(", "self", ".", "getChi2Value", "(", "sample", ",", "expectation", ")", ",", "self", ".", "getDF", "(", "sample"...
Returns the significance of the difference between two samples.
[ "Returns", "the", "significance", "of", "the", "difference", "between", "two", "samples", "." ]
[ "\"\"\"Returns the significance of the difference between two samples.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "sample", "type": null }, { "param": "expectation", "type": null }, { "param": "level", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sample", "type": null, "docstring": null, "docstring_tokens":...
f8371fccd186137bdfe4ee418ea55baa20eb9b2e
dcavar/dcavar.github.io
LID/resources/lidtrainer.py
[ "Apache-2.0" ]
Python
eliminateFrequences
null
def eliminateFrequences(self, num): """Eliminates all bigrams with a frequency <= num""" for x in self.trigrams.keys(): if self.trigrams[x] <= num: value = self.trigrams[x] del self.trigrams[x] self.num -= value
Eliminates all bigrams with a frequency <= num
Eliminates all bigrams with a frequency <= num
[ "Eliminates", "all", "bigrams", "with", "a", "frequency", "<", "=", "num" ]
def eliminateFrequences(self, num): for x in self.trigrams.keys(): if self.trigrams[x] <= num: value = self.trigrams[x] del self.trigrams[x] self.num -= value
[ "def", "eliminateFrequences", "(", "self", ",", "num", ")", ":", "for", "x", "in", "self", ".", "trigrams", ".", "keys", "(", ")", ":", "if", "self", ".", "trigrams", "[", "x", "]", "<=", "num", ":", "value", "=", "self", ".", "trigrams", "[", "x...
Eliminates all bigrams with a frequency <= num
[ "Eliminates", "all", "bigrams", "with", "a", "frequency", "<", "=", "num" ]
[ "\"\"\"Eliminates all bigrams with a frequency <= num\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "num", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "num", "type": null, "docstring": null, "docstring_tokens": []...
f8371fccd186137bdfe4ee418ea55baa20eb9b2e
dcavar/dcavar.github.io
LID/resources/lidtrainer.py
[ "Apache-2.0" ]
Python
cleanTextSC
<not_specific>
def cleanTextSC(self, text): """Eliminates punctuation symbols from the submitted text.""" for i in punctuation: if i in text: text = replace(text, i, " ") return text
Eliminates punctuation symbols from the submitted text.
Eliminates punctuation symbols from the submitted text.
[ "Eliminates", "punctuation", "symbols", "from", "the", "submitted", "text", "." ]
def cleanTextSC(self, text): for i in punctuation: if i in text: text = replace(text, i, " ") return text
[ "def", "cleanTextSC", "(", "self", ",", "text", ")", ":", "for", "i", "in", "punctuation", ":", "if", "i", "in", "text", ":", "text", "=", "replace", "(", "text", ",", "i", ",", "\" \"", ")", "return", "text" ]
Eliminates punctuation symbols from the submitted text.
[ "Eliminates", "punctuation", "symbols", "from", "the", "submitted", "text", "." ]
[ "\"\"\"Eliminates punctuation symbols from the submitted text.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "text", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [...
f8371fccd186137bdfe4ee418ea55baa20eb9b2e
dcavar/dcavar.github.io
LID/resources/lidtrainer.py
[ "Apache-2.0" ]
Python
cleanPBIG
null
def cleanPBIG(self): """Eliminate tri-grams that contain punctuation marks.""" for i in self.trigrams.keys(): for a in punctuation: if a in i: value = self.trigrams[i] del self.trigrams[i] self.num -= value break
Eliminate tri-grams that contain punctuation marks.
Eliminate tri-grams that contain punctuation marks.
[ "Eliminate", "tri", "-", "grams", "that", "contain", "punctuation", "marks", "." ]
def cleanPBIG(self): for i in self.trigrams.keys(): for a in punctuation: if a in i: value = self.trigrams[i] del self.trigrams[i] self.num -= value break
[ "def", "cleanPBIG", "(", "self", ")", ":", "for", "i", "in", "self", ".", "trigrams", ".", "keys", "(", ")", ":", "for", "a", "in", "punctuation", ":", "if", "a", "in", "i", ":", "value", "=", "self", ".", "trigrams", "[", "i", "]", "del", "sel...
Eliminate tri-grams that contain punctuation marks.
[ "Eliminate", "tri", "-", "grams", "that", "contain", "punctuation", "marks", "." ]
[ "\"\"\"Eliminate tri-grams that contain punctuation marks.\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9478a6f7cb9b0dfc1e2e67d930cf53472cde264e
dcavar/dcavar.github.io
pycl/Code/freq2w32.py
[ "Apache-2.0" ]
Python
countWords
<not_specific>
def countWords(words, filename): """Counts words in file and returns dictionary.""" try: file = codecs.open(filename, "r", "utf8") tokens = [ string.strip(string.lower(i)) for i in file.read().split() ] for i in tokens: words[i] = words.get(i, 0) + 1 file.close() except IOError: print "Cannot read from ...
Counts words in file and returns dictionary.
Counts words in file and returns dictionary.
[ "Counts", "words", "in", "file", "and", "returns", "dictionary", "." ]
def countWords(words, filename): try: file = codecs.open(filename, "r", "utf8") tokens = [ string.strip(string.lower(i)) for i in file.read().split() ] for i in tokens: words[i] = words.get(i, 0) + 1 file.close() except IOError: print "Cannot read from file:", filename return words
[ "def", "countWords", "(", "words", ",", "filename", ")", ":", "try", ":", "file", "=", "codecs", ".", "open", "(", "filename", ",", "\"r\"", ",", "\"utf8\"", ")", "tokens", "=", "[", "string", ".", "strip", "(", "string", ".", "lower", "(", "i", ")...
Counts words in file and returns dictionary.
[ "Counts", "words", "in", "file", "and", "returns", "dictionary", "." ]
[ "\"\"\"Counts words in file and returns dictionary.\"\"\"" ]
[ { "param": "words", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "words", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_token...
0ad0b8edf7a683b465e0cf4e397e64dccf6daba1
dcavar/dcavar.github.io
pycl/Code/KMeans.py
[ "Apache-2.0" ]
Python
EuclideanDistance
<not_specific>
def EuclideanDistance(v1, v2): """Returns the Euclidean distance between two vectors.""" distance = 0.0 for m in range(len(v1)): distance += math.pow(float(v1[m]-v2[m]), 2) return math.sqrt(distance)
Returns the Euclidean distance between two vectors.
Returns the Euclidean distance between two vectors.
[ "Returns", "the", "Euclidean", "distance", "between", "two", "vectors", "." ]
def EuclideanDistance(v1, v2): distance = 0.0 for m in range(len(v1)): distance += math.pow(float(v1[m]-v2[m]), 2) return math.sqrt(distance)
[ "def", "EuclideanDistance", "(", "v1", ",", "v2", ")", ":", "distance", "=", "0.0", "for", "m", "in", "range", "(", "len", "(", "v1", ")", ")", ":", "distance", "+=", "math", ".", "pow", "(", "float", "(", "v1", "[", "m", "]", "-", "v2", "[", ...
Returns the Euclidean distance between two vectors.
[ "Returns", "the", "Euclidean", "distance", "between", "two", "vectors", "." ]
[ "\"\"\"Returns the Euclidean distance between two vectors.\"\"\"" ]
[ { "param": "v1", "type": null }, { "param": "v2", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "v1", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "v2", "type": null, "docstring": null, "docstring_tokens": [], ...
0ad0b8edf7a683b465e0cf4e397e64dccf6daba1
dcavar/dcavar.github.io
pycl/Code/KMeans.py
[ "Apache-2.0" ]
Python
findMostDistant
<not_specific>
def findMostDistant(vectorspace, k): """Find the most distant k vectors.""" distances = [ ] for x in range(len(vectorspace)): dv = [ ] for y in range(x + 1, len(vectorspace)): dv.append(EuclideanDistance(vectorspace[x], vectorspace[y])) distances.append(dv) dv = [ ] for x in distances: dv += x dv.sort...
Find the most distant k vectors.
Find the most distant k vectors.
[ "Find", "the", "most", "distant", "k", "vectors", "." ]
def findMostDistant(vectorspace, k): distances = [ ] for x in range(len(vectorspace)): dv = [ ] for y in range(x + 1, len(vectorspace)): dv.append(EuclideanDistance(vectorspace[x], vectorspace[y])) distances.append(dv) dv = [ ] for x in distances: dv += x dv.sort() vectors = [ ] for x in range(len(dis...
[ "def", "findMostDistant", "(", "vectorspace", ",", "k", ")", ":", "distances", "=", "[", "]", "for", "x", "in", "range", "(", "len", "(", "vectorspace", ")", ")", ":", "dv", "=", "[", "]", "for", "y", "in", "range", "(", "x", "+", "1", ",", "le...
Find the most distant k vectors.
[ "Find", "the", "most", "distant", "k", "vectors", "." ]
[ "\"\"\"Find the most distant k vectors.\"\"\"" ]
[ { "param": "vectorspace", "type": null }, { "param": "k", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "vectorspace", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "k", "type": null, "docstring": null, "docstring_tokens...
bf2ae5f30f831600f1803abb3e3cf0668bebd40e
dcavar/dcavar.github.io
pycl/Code/MIRE.py
[ "Apache-2.0" ]
Python
MI
<not_specific>
def MI(bigram, bigramprob, tokens, tokencount): """Returns the mutual information for bigrams. MI = P(XY|X) log2 ( P(XY) / P(X) P(Y) ) P(XY|X) = num of bigrams XY over num bigrams with X left """ if tokens.has_key(bigram[0]): px = float(tokens[bigram[0]])/float(tokencount) else: px = 0.0 if tokens.has_key(...
Returns the mutual information for bigrams. MI = P(XY|X) log2 ( P(XY) / P(X) P(Y) ) P(XY|X) = num of bigrams XY over num bigrams with X left
Returns the mutual information for bigrams.
[ "Returns", "the", "mutual", "information", "for", "bigrams", "." ]
def MI(bigram, bigramprob, tokens, tokencount): if tokens.has_key(bigram[0]): px = float(tokens[bigram[0]])/float(tokencount) else: px = 0.0 if tokens.has_key(bigram[1]): py = float(tokens[bigram[1]])/float(tokencount) else: py = 0.0 if py == 0.0 or px == 0.0: return 0.0 return bigramprob * math.log(big...
[ "def", "MI", "(", "bigram", ",", "bigramprob", ",", "tokens", ",", "tokencount", ")", ":", "if", "tokens", ".", "has_key", "(", "bigram", "[", "0", "]", ")", ":", "px", "=", "float", "(", "tokens", "[", "bigram", "[", "0", "]", "]", ")", "/", "...
Returns the mutual information for bigrams.
[ "Returns", "the", "mutual", "information", "for", "bigrams", "." ]
[ "\"\"\"Returns the mutual information for bigrams.\n\t\tMI = P(XY|X) log2 ( P(XY) / P(X) P(Y) )\n\t\tP(XY|X) = num of bigrams XY over num bigrams with X left\n\t\"\"\"" ]
[ { "param": "bigram", "type": null }, { "param": "bigramprob", "type": null }, { "param": "tokens", "type": null }, { "param": "tokencount", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "bigram", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "bigramprob", "type": null, "docstring": null, "docstring_to...
4c7d077bd5eabb0b0834737bdd949566d94591fc
dcavar/dcavar.github.io
pycl/Code/BUAParser.py
[ "Apache-2.0" ]
Python
parse
null
def parse(input, grammar, rootsymbol): """Simple non-recursive bottom up parser.""" agenda = [] while True: print "Input: %s" % (input,) if input == rootsymbol: print "Success!" break else: for i in range(1, len(input) + 1): # window for j in range(len(input) - i + 1): # movement for lhs ...
Simple non-recursive bottom up parser.
Simple non-recursive bottom up parser.
[ "Simple", "non", "-", "recursive", "bottom", "up", "parser", "." ]
def parse(input, grammar, rootsymbol): agenda = [] while True: print "Input: %s" % (input,) if input == rootsymbol: print "Success!" break else: for i in range(1, len(input) + 1): for j in range(len(input) - i + 1): for lhs in grammar.RHS.get(tuple(input[j:i + j]), []): newhyp = in...
[ "def", "parse", "(", "input", ",", "grammar", ",", "rootsymbol", ")", ":", "agenda", "=", "[", "]", "while", "True", ":", "print", "\"Input: %s\"", "%", "(", "input", ",", ")", "if", "input", "==", "rootsymbol", ":", "print", "\"Success!\"", "break", "...
Simple non-recursive bottom up parser.
[ "Simple", "non", "-", "recursive", "bottom", "up", "parser", "." ]
[ "\"\"\"Simple non-recursive bottom up parser.\"\"\"", "# window", "# movement" ]
[ { "param": "input", "type": null }, { "param": "grammar", "type": null }, { "param": "rootsymbol", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "grammar", "type": null, "docstring": null, "docstring_tokens...
b34160c4d171a287690c36ed936d5fe6cbdfa73e
dcavar/dcavar.github.io
pycl/Code/freq5.py
[ "Apache-2.0" ]
Python
countWords
<not_specific>
def countWords(words, filename): """Counts words in file and returns dictionary.""" count = words.get(countername, 0) try: file = codecs.open(filename, "r", "utf8") tokens = [string.lower(i) for i in re.findall(ur"[A-Za-zčČćĆšŠžŽđĐ]+",file.read())] for i in tokens: words[i] = words.get(i, 0) + 1 count +=...
Counts words in file and returns dictionary.
Counts words in file and returns dictionary.
[ "Counts", "words", "in", "file", "and", "returns", "dictionary", "." ]
def countWords(words, filename): count = words.get(countername, 0) try: file = codecs.open(filename, "r", "utf8") tokens = [string.lower(i) for i in re.findall(ur"[A-Za-zčČćĆšŠžŽđĐ]+",file.read())] for i in tokens: words[i] = words.get(i, 0) + 1 count += 1 file.close() except IOError: print "Cannot r...
[ "def", "countWords", "(", "words", ",", "filename", ")", ":", "count", "=", "words", ".", "get", "(", "countername", ",", "0", ")", "try", ":", "file", "=", "codecs", ".", "open", "(", "filename", ",", "\"r\"", ",", "\"utf8\"", ")", "tokens", "=", ...
Counts words in file and returns dictionary.
[ "Counts", "words", "in", "file", "and", "returns", "dictionary", "." ]
[ "\"\"\"Counts words in file and returns dictionary.\"\"\"" ]
[ { "param": "words", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "words", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_token...
eb1a6c1e39b62eed726a4fb162168dbdd6d461fd
dcavar/dcavar.github.io
pycl/Code/freq.py
[ "Apache-2.0" ]
Python
countWords
<not_specific>
def countWords(words, filename): """Counts words in file and returns dictionary.""" try: file = open(filename, "r") tokens = [ string.strip(i.lower()) for i in file.read().split() ] for i in tokens: words[i] = words.get(i, 0) + 1 file.close() except IOError: print "Cannot read from file:", filename ret...
Counts words in file and returns dictionary.
Counts words in file and returns dictionary.
[ "Counts", "words", "in", "file", "and", "returns", "dictionary", "." ]
def countWords(words, filename): try: file = open(filename, "r") tokens = [ string.strip(i.lower()) for i in file.read().split() ] for i in tokens: words[i] = words.get(i, 0) + 1 file.close() except IOError: print "Cannot read from file:", filename return words
[ "def", "countWords", "(", "words", ",", "filename", ")", ":", "try", ":", "file", "=", "open", "(", "filename", ",", "\"r\"", ")", "tokens", "=", "[", "string", ".", "strip", "(", "i", ".", "lower", "(", ")", ")", "for", "i", "in", "file", ".", ...
Counts words in file and returns dictionary.
[ "Counts", "words", "in", "file", "and", "returns", "dictionary", "." ]
[ "\"\"\"Counts words in file and returns dictionary.\"\"\"" ]
[ { "param": "words", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "words", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_token...
e5b7dd3fdf809535b28b89e0d0c836dbe4b8b25b
dcavar/dcavar.github.io
FSAPy/download/files/FSA.py
[ "Apache-2.0" ]
Python
delta
<not_specific>
def delta(self, input): """Perform a transition and execute action.""" si = (self.state, input) newstate = None emission = None if self.states.has_key(si): newstate, action, emission = self.states[si] if self.dbg != None: self.dbg.write('State: %s / Input: %s /' 'Next State: %s / Action: %s\n'...
Perform a transition and execute action.
Perform a transition and execute action.
[ "Perform", "a", "transition", "and", "execute", "action", "." ]
def delta(self, input): si = (self.state, input) newstate = None emission = None if self.states.has_key(si): newstate, action, emission = self.states[si] if self.dbg != None: self.dbg.write('State: %s / Input: %s /' 'Next State: %s / Action: %s\n' % (self.state, input, newstate, action, emission...
[ "def", "delta", "(", "self", ",", "input", ")", ":", "si", "=", "(", "self", ".", "state", ",", "input", ")", "newstate", "=", "None", "emission", "=", "None", "if", "self", ".", "states", ".", "has_key", "(", "si", ")", ":", "newstate", ",", "ac...
Perform a transition and execute action.
[ "Perform", "a", "transition", "and", "execute", "action", "." ]
[ "\"\"\"Perform a transition and execute action.\"\"\"", "#if action:", "#\tapply(action, (self.state, input, index))" ]
[ { "param": "self", "type": null }, { "param": "input", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input", "type": null, "docstring": null, "docstring_tokens": ...
1e31f069f77112dcff3b540e18e4f848b75efd44
dcavar/dcavar.github.io
pycl/Code/LID/lid.py
[ "Apache-2.0" ]
Python
checkText
<not_specific>
def checkText(self, text): """Check which language a text is.""" self.createTrigrams(text) # create trigrams of submitted text self.calcProb() # calculate probabilities result = [] # storage for the matches with the models for x in range(len(self.languages)): result.append(0) # f...
Check which language a text is.
Check which language a text is.
[ "Check", "which", "language", "a", "text", "is", "." ]
def checkText(self, text): self.createTrigrams(text) self.calcProb() result = [] for x in range(len(self.languages)): result.append(0) for x in self.trigrams.keys(): for i in range(len(self.models)): mymodel = self.models[i] if mymodel.has_key(x): value = mymodel[...
[ "def", "checkText", "(", "self", ",", "text", ")", ":", "self", ".", "createTrigrams", "(", "text", ")", "self", ".", "calcProb", "(", ")", "result", "=", "[", "]", "for", "x", "in", "range", "(", "len", "(", "self", ".", "languages", ")", ")", "...
Check which language a text is.
[ "Check", "which", "language", "a", "text", "is", "." ]
[ "\"\"\"Check which language a text is.\"\"\"", "# create trigrams of submitted text", "# calculate probabilities", "# storage for the matches with the models", "# for all keys in trigrams", "# for 0 to number language models", "# get the current model", "# if the model contains the key, get the deviat...
[ { "param": "self", "type": null }, { "param": "text", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [...
1e31f069f77112dcff3b540e18e4f848b75efd44
dcavar/dcavar.github.io
pycl/Code/LID/lid.py
[ "Apache-2.0" ]
Python
createTrigrams
null
def createTrigrams(self, text): """Creates tri-grams from characters.""" self.num = 0 # storage for the number of trigrams self.trigrams = {} # dictionary storage for trigrams text = re.sub(r"\n", " ", text) # replace newlines in text text = self.cleanTextSC(text) # clean tri...
Creates tri-grams from characters.
Creates tri-grams from characters.
[ "Creates", "tri", "-", "grams", "from", "characters", "." ]
def createTrigrams(self, text): self.num = 0 self.trigrams = {} text = re.sub(r"\n", " ", text) text = self.cleanTextSC(text) text = re.sub(r"\s+", " ", text) self.characters = len(text) for i in range(len(text) - 2): self.num += 1 self.trigrams[text[i:i+3...
[ "def", "createTrigrams", "(", "self", ",", "text", ")", ":", "self", ".", "num", "=", "0", "self", ".", "trigrams", "=", "{", "}", "text", "=", "re", ".", "sub", "(", "r\"\\n\"", ",", "\" \"", ",", "text", ")", "text", "=", "self", ".", "cleanTex...
Creates tri-grams from characters.
[ "Creates", "tri", "-", "grams", "from", "characters", "." ]
[ "\"\"\"Creates tri-grams from characters.\"\"\"", "# storage for the number of trigrams", "# dictionary storage for trigrams", "# replace newlines in text", "# clean trigrams with punctuation marks", "# replace multiple spaces/tabs ", "# get number of characters", "# go thru list up to one but last wo...
[ { "param": "self", "type": null }, { "param": "text", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [...
ce1d158e55259ccee775d0b32ad8e277a289436a
dcavar/dcavar.github.io
pycl/Code/ngram.py
[ "Apache-2.0" ]
Python
addNgram
null
def addNgram(self, ngram): """Adds an ngram to the collection.""" if len(ngram) == self.ngrams["__n__"]: self.ngrams[ngram] = self.ngrams.get(ngram, 0) + 1 self.ngrams["__count__"] += 1 self.__changed = True # else: # raise some exception
Adds an ngram to the collection.
Adds an ngram to the collection.
[ "Adds", "an", "ngram", "to", "the", "collection", "." ]
def addNgram(self, ngram): if len(ngram) == self.ngrams["__n__"]: self.ngrams[ngram] = self.ngrams.get(ngram, 0) + 1 self.ngrams["__count__"] += 1 self.__changed = True
[ "def", "addNgram", "(", "self", ",", "ngram", ")", ":", "if", "len", "(", "ngram", ")", "==", "self", ".", "ngrams", "[", "\"__n__\"", "]", ":", "self", ".", "ngrams", "[", "ngram", "]", "=", "self", ".", "ngrams", ".", "get", "(", "ngram", ",", ...
Adds an ngram to the collection.
[ "Adds", "an", "ngram", "to", "the", "collection", "." ]
[ "\"\"\"Adds an ngram to the collection.\"\"\"", "# else:", "# raise some exception" ]
[ { "param": "self", "type": null }, { "param": "ngram", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ngram", "type": null, "docstring": null, "docstring_tokens": ...
ce1d158e55259ccee775d0b32ad8e277a289436a
dcavar/dcavar.github.io
pycl/Code/ngram.py
[ "Apache-2.0" ]
Python
removeNgram
null
def removeNgram(self, ngram): """Removes one occurrence of an ngram from the collection by decreasing its counter. If the counter equals 0 after decreasing, the ngram is removed from the collection. """ if self.ngrams.has_key(ngram): if self.ngrams[ngram] > 1: self.ngrams[ngram] -= 1 else: ...
Removes one occurrence of an ngram from the collection by decreasing its counter. If the counter equals 0 after decreasing, the ngram is removed from the collection.
Removes one occurrence of an ngram from the collection by decreasing its counter. If the counter equals 0 after decreasing, the ngram is removed from the collection.
[ "Removes", "one", "occurrence", "of", "an", "ngram", "from", "the", "collection", "by", "decreasing", "its", "counter", ".", "If", "the", "counter", "equals", "0", "after", "decreasing", "the", "ngram", "is", "removed", "from", "the", "collection", "." ]
def removeNgram(self, ngram): if self.ngrams.has_key(ngram): if self.ngrams[ngram] > 1: self.ngrams[ngram] -= 1 else: del self.ngrams[ngram] self.ngrams["__count__"] -= 1 self.__changed = True
[ "def", "removeNgram", "(", "self", ",", "ngram", ")", ":", "if", "self", ".", "ngrams", ".", "has_key", "(", "ngram", ")", ":", "if", "self", ".", "ngrams", "[", "ngram", "]", ">", "1", ":", "self", ".", "ngrams", "[", "ngram", "]", "-=", "1", ...
Removes one occurrence of an ngram from the collection by decreasing its counter.
[ "Removes", "one", "occurrence", "of", "an", "ngram", "from", "the", "collection", "by", "decreasing", "its", "counter", "." ]
[ "\"\"\"Removes one occurrence of an ngram from the collection by decreasing\n\t\t its counter. If the counter equals 0 after decreasing, the ngram is\n\t\t removed from the collection.\n\t\t\"\"\"", "# else", "# raise an error" ]
[ { "param": "self", "type": null }, { "param": "ngram", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ngram", "type": null, "docstring": null, "docstring_tokens": ...
ce1d158e55259ccee775d0b32ad8e277a289436a
dcavar/dcavar.github.io
pycl/Code/ngram.py
[ "Apache-2.0" ]
Python
frequencyProfile
<not_specific>
def frequencyProfile(self, increasing = True): """Returns the frequency profile of the ngram items. If increasing is set to True, the returned frequency profile will be increasing, if it is set to False, the returned frequency profile is decreasing. """ e = self.ngrams.copy() del e["__count__"] ...
Returns the frequency profile of the ngram items. If increasing is set to True, the returned frequency profile will be increasing, if it is set to False, the returned frequency profile is decreasing.
Returns the frequency profile of the ngram items. If increasing is set to True, the returned frequency profile will be increasing, if it is set to False, the returned frequency profile is decreasing.
[ "Returns", "the", "frequency", "profile", "of", "the", "ngram", "items", ".", "If", "increasing", "is", "set", "to", "True", "the", "returned", "frequency", "profile", "will", "be", "increasing", "if", "it", "is", "set", "to", "False", "the", "returned", "...
def frequencyProfile(self, increasing = True): e = self.ngrams.copy() del e["__count__"] del e["__n__"] if increasing == True: return sorted(e.items(), key=itemgetter(1)) items = e.items() items.sort(key = itemgetter(1), reverse=True) return items
[ "def", "frequencyProfile", "(", "self", ",", "increasing", "=", "True", ")", ":", "e", "=", "self", ".", "ngrams", ".", "copy", "(", ")", "del", "e", "[", "\"__count__\"", "]", "del", "e", "[", "\"__n__\"", "]", "if", "increasing", "==", "True", ":",...
Returns the frequency profile of the ngram items.
[ "Returns", "the", "frequency", "profile", "of", "the", "ngram", "items", "." ]
[ "\"\"\"Returns the frequency profile of the ngram items. If increasing is\n\t\t set to True, the returned frequency profile will be increasing,\n\t\t if it is set to False, the returned frequency profile is\n\t\t decreasing.\n\t\t\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "increasing", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "increasing", "type": null, "docstring": null, "docstring_toke...
ce1d158e55259ccee775d0b32ad8e277a289436a
dcavar/dcavar.github.io
pycl/Code/ngram.py
[ "Apache-2.0" ]
Python
relativeFrequencyProfile
<not_specific>
def relativeFrequencyProfile(self, increasing = True): """Returns the relative frequency profile of the ngram items. If increasing is set to True, the returned profile will be increasing, if it is set to False, it is decreasing. """ if changed == True: self.__ngramrel = self.ngrams.copy() del self...
Returns the relative frequency profile of the ngram items. If increasing is set to True, the returned profile will be increasing, if it is set to False, it is decreasing.
Returns the relative frequency profile of the ngram items. If increasing is set to True, the returned profile will be increasing, if it is set to False, it is decreasing.
[ "Returns", "the", "relative", "frequency", "profile", "of", "the", "ngram", "items", ".", "If", "increasing", "is", "set", "to", "True", "the", "returned", "profile", "will", "be", "increasing", "if", "it", "is", "set", "to", "False", "it", "is", "decreasi...
def relativeFrequencyProfile(self, increasing = True): if changed == True: self.__ngramrel = self.ngrams.copy() del self.__ngramrel["__count__"] del self.__ngramrel["__n__"] for i in self.__ngramrel.keys(): self.__ngramrel[i] = self.getNgramRelativeFrequency(i) self.__changed = False return self....
[ "def", "relativeFrequencyProfile", "(", "self", ",", "increasing", "=", "True", ")", ":", "if", "changed", "==", "True", ":", "self", ".", "__ngramrel", "=", "self", ".", "ngrams", ".", "copy", "(", ")", "del", "self", ".", "__ngramrel", "[", "\"__count_...
Returns the relative frequency profile of the ngram items.
[ "Returns", "the", "relative", "frequency", "profile", "of", "the", "ngram", "items", "." ]
[ "\"\"\"Returns the relative frequency profile of the ngram items. If increasing\n\t\t is set to True, the returned profile will be increasing, if it is set to\n\t\t False, it is decreasing.\n\t\t\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "increasing", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "increasing", "type": null, "docstring": null, "docstring_toke...
ce1d158e55259ccee775d0b32ad8e277a289436a
dcavar/dcavar.github.io
pycl/Code/ngram.py
[ "Apache-2.0" ]
Python
serialize
null
def serialize(self, filename = "ngrams"): """Dump the ngram model to a file.""" try: if filename == "ngrams": filename = filename + str(self.ngrams["__n__"]) + ".p" pickle.dump(self.ngrams, open(filename, "w")) self.__changed = True except Exception, e: print "Exception %s" % e
Dump the ngram model to a file.
Dump the ngram model to a file.
[ "Dump", "the", "ngram", "model", "to", "a", "file", "." ]
def serialize(self, filename = "ngrams"): try: if filename == "ngrams": filename = filename + str(self.ngrams["__n__"]) + ".p" pickle.dump(self.ngrams, open(filename, "w")) self.__changed = True except Exception, e: print "Exception %s" % e
[ "def", "serialize", "(", "self", ",", "filename", "=", "\"ngrams\"", ")", ":", "try", ":", "if", "filename", "==", "\"ngrams\"", ":", "filename", "=", "filename", "+", "str", "(", "self", ".", "ngrams", "[", "\"__n__\"", "]", ")", "+", "\".p\"", "pickl...
Dump the ngram model to a file.
[ "Dump", "the", "ngram", "model", "to", "a", "file", "." ]
[ "\"\"\"Dump the ngram model to a file.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens...
ce1d158e55259ccee775d0b32ad8e277a289436a
dcavar/dcavar.github.io
pycl/Code/ngram.py
[ "Apache-2.0" ]
Python
deSerialize
null
def deSerialize(self, filename = "ngrams"): """Read ngram model from filename.""" try: if filename == "ngrams": filename = filename + str(self.ngrams["__n__"]) + ".p" if os.path.exists(filename): self.ngrams = pickle.load(open(filename)) self.__changed = True except Exception, e: print "Excep...
Read ngram model from filename.
Read ngram model from filename.
[ "Read", "ngram", "model", "from", "filename", "." ]
def deSerialize(self, filename = "ngrams"): try: if filename == "ngrams": filename = filename + str(self.ngrams["__n__"]) + ".p" if os.path.exists(filename): self.ngrams = pickle.load(open(filename)) self.__changed = True except Exception, e: print "Exception %s" % e e = self.ngrams.copy() ...
[ "def", "deSerialize", "(", "self", ",", "filename", "=", "\"ngrams\"", ")", ":", "try", ":", "if", "filename", "==", "\"ngrams\"", ":", "filename", "=", "filename", "+", "str", "(", "self", ".", "ngrams", "[", "\"__n__\"", "]", ")", "+", "\".p\"", "if"...
Read ngram model from filename.
[ "Read", "ngram", "model", "from", "filename", "." ]
[ "\"\"\"Read ngram model from filename.\"\"\"", "# sparcify ngram dictionary for speed increase" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens...
8b59c2c36829081b655ca3c525febc1518a50ee2
dcavar/dcavar.github.io
FSAPy/download/files/Wlist2RE.py
[ "Apache-2.0" ]
Python
makeFSA
<not_specific>
def makeFSA(wlist): """Returns a non-deterministic minimal automaton incrementally generated from a word list.""" # store all the states and as value tuples of production and goal state # key: state # value: [ (to-state, emission-symbol), ... ] states = { 0:None, 1:[] } countstates = 1 # this ...
Returns a non-deterministic minimal automaton incrementally generated from a word list.
Returns a non-deterministic minimal automaton incrementally generated from a word list.
[ "Returns", "a", "non", "-", "deterministic", "minimal", "automaton", "incrementally", "generated", "from", "a", "word", "list", "." ]
def makeFSA(wlist): states = { 0:None, 1:[] } countstates = 1 finalstates = [ 0 ] suffixes = {} for i in wlist: suffixes[i] = 1 agenda = [ (1, suffixes.keys(), tuple() ) ] suffixes = {} statesuffixes = {} while True: if len(agenda) == 0: break ...
[ "def", "makeFSA", "(", "wlist", ")", ":", "states", "=", "{", "0", ":", "None", ",", "1", ":", "[", "]", "}", "countstates", "=", "1", "finalstates", "=", "[", "0", "]", "suffixes", "=", "{", "}", "for", "i", "in", "wlist", ":", "suffixes", "["...
Returns a non-deterministic minimal automaton incrementally generated from a word list.
[ "Returns", "a", "non", "-", "deterministic", "minimal", "automaton", "incrementally", "generated", "from", "a", "word", "list", "." ]
[ "\"\"\"Returns a non-deterministic minimal automaton incrementally generated from a word list.\"\"\"", "# store all the states and as value tuples of production and goal state", "# key: state", "# value: [ (to-state, emission-symbol), ... ]", "# this number is the currently highest numbered state", "# lis...
[ { "param": "wlist", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "wlist", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8b59c2c36829081b655ca3c525febc1518a50ee2
dcavar/dcavar.github.io
FSAPy/download/files/Wlist2RE.py
[ "Apache-2.0" ]
Python
makeDOT
<not_specific>
def makeDOT(myFSA): """Return DOT representation for graphviz.""" buffer = "digraph fsa {\nrankdir=LR;\nnode [shape=doublecircle];\n" for i in myFSA.getFinalStates(): buffer = u" ".join((buffer, str(i))) buffer += u";\nnode [shape = circle];\n" for i in myFSA.states.keys(): val = my...
Return DOT representation for graphviz.
Return DOT representation for graphviz.
[ "Return", "DOT", "representation", "for", "graphviz", "." ]
def makeDOT(myFSA): buffer = "digraph fsa {\nrankdir=LR;\nnode [shape=doublecircle];\n" for i in myFSA.getFinalStates(): buffer = u" ".join((buffer, str(i))) buffer += u";\nnode [shape = circle];\n" for i in myFSA.states.keys(): val = myFSA.states[i] buffer = u" ".join( (buffer, ...
[ "def", "makeDOT", "(", "myFSA", ")", ":", "buffer", "=", "\"digraph fsa {\\nrankdir=LR;\\nnode [shape=doublecircle];\\n\"", "for", "i", "in", "myFSA", ".", "getFinalStates", "(", ")", ":", "buffer", "=", "u\" \"", ".", "join", "(", "(", "buffer", ",", "str", "...
Return DOT representation for graphviz.
[ "Return", "DOT", "representation", "for", "graphviz", "." ]
[ "\"\"\"Return DOT representation for graphviz.\"\"\"" ]
[ { "param": "myFSA", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "myFSA", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8b59c2c36829081b655ca3c525febc1518a50ee2
dcavar/dcavar.github.io
FSAPy/download/files/Wlist2RE.py
[ "Apache-2.0" ]
Python
loadWlist
<not_specific>
def loadWlist(fname): """Return a list of words from a text file (in UTF-8 encoding). The word list is genereted by whitespace tokenization, i.e. it could be a floating text, a list of words line by line, word by word, etc. Duplicate words are removed.""" try: fp = codecs.open(fna...
Return a list of words from a text file (in UTF-8 encoding). The word list is genereted by whitespace tokenization, i.e. it could be a floating text, a list of words line by line, word by word, etc. Duplicate words are removed.
Return a list of words from a text file (in UTF-8 encoding). The word list is genereted by whitespace tokenization, i.e. it could be a floating text, a list of words line by line, word by word, etc. Duplicate words are removed.
[ "Return", "a", "list", "of", "words", "from", "a", "text", "file", "(", "in", "UTF", "-", "8", "encoding", ")", ".", "The", "word", "list", "is", "genereted", "by", "whitespace", "tokenization", "i", ".", "e", ".", "it", "could", "be", "a", "floating...
def loadWlist(fname): try: fp = codecs.open(fname, "r", "utf-8") tmp = fp.read() fp.close() words = tmp.split() except ValueError: fp.close() words = list(set(words)) words.sort() return tuple(words)
[ "def", "loadWlist", "(", "fname", ")", ":", "try", ":", "fp", "=", "codecs", ".", "open", "(", "fname", ",", "\"r\"", ",", "\"utf-8\"", ")", "tmp", "=", "fp", ".", "read", "(", ")", "fp", ".", "close", "(", ")", "words", "=", "tmp", ".", "split...
Return a list of words from a text file (in UTF-8 encoding).
[ "Return", "a", "list", "of", "words", "from", "a", "text", "file", "(", "in", "UTF", "-", "8", "encoding", ")", "." ]
[ "\"\"\"Return a list of words from a text file (in UTF-8 encoding).\n The word list is genereted by whitespace tokenization, i.e.\n it could be a floating text, a list of words line by line,\n word by word, etc. Duplicate words are removed.\"\"\"" ]
[ { "param": "fname", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fname", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b270598b0b3b4cc9e1404d8f7a1458e9aacad3c8
dcavar/dcavar.github.io
pycl/Code/VectorSpace.py
[ "Apache-2.0" ]
Python
makeVectorSpace
<not_specific>
def makeVectorSpace(): """Generate the vector space from dictionary data.""" global words, wordlist, documents, docnames, eliminated wordlist = words.keys() docnames = documents.keys() # eliminate words that appear in all documents for x in wordlist: if len(words.get(x, [])) == len(docnames): eliminated.ap...
Generate the vector space from dictionary data.
Generate the vector space from dictionary data.
[ "Generate", "the", "vector", "space", "from", "dictionary", "data", "." ]
def makeVectorSpace(): global words, wordlist, documents, docnames, eliminated wordlist = words.keys() docnames = documents.keys() for x in wordlist: if len(words.get(x, [])) == len(docnames): eliminated.append(x) del words[x] wordlist = words.keys() vectorspace = [] for x in docnames: vector = len(wor...
[ "def", "makeVectorSpace", "(", ")", ":", "global", "words", ",", "wordlist", ",", "documents", ",", "docnames", ",", "eliminated", "wordlist", "=", "words", ".", "keys", "(", ")", "docnames", "=", "documents", ".", "keys", "(", ")", "for", "x", "in", "...
Generate the vector space from dictionary data.
[ "Generate", "the", "vector", "space", "from", "dictionary", "data", "." ]
[ "\"\"\"Generate the vector space from dictionary data.\"\"\"", "# eliminate words that appear in all documents", "# create vectors", "# append vector with relative frequencies", "#i = float(vsum(vector))", "#vectorspace.append(tuple([ float(a)/i for a in vector ]))", "# convert vectorspace to tuple" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
b270598b0b3b4cc9e1404d8f7a1458e9aacad3c8
dcavar/dcavar.github.io
pycl/Code/VectorSpace.py
[ "Apache-2.0" ]
Python
collectWords
null
def collectWords(document): """Collect all words from document into dictionary data structures.""" global documents, words file = open(document) tokens = [string.lower(i) for i in re.findall(r"[A-Za-z]+'?[A-Za-z]?", file.read())] file.close() # get wordlist wordlist = {} for i in tokens: if i not in functi...
Collect all words from document into dictionary data structures.
Collect all words from document into dictionary data structures.
[ "Collect", "all", "words", "from", "document", "into", "dictionary", "data", "structures", "." ]
def collectWords(document): global documents, words file = open(document) tokens = [string.lower(i) for i in re.findall(r"[A-Za-z]+'?[A-Za-z]?", file.read())] file.close() wordlist = {} for i in tokens: if i not in functionWordsEN: wordlist[i] = wordlist.get(i, 0) + 1 value = words.get(i, []) i...
[ "def", "collectWords", "(", "document", ")", ":", "global", "documents", ",", "words", "file", "=", "open", "(", "document", ")", "tokens", "=", "[", "string", ".", "lower", "(", "i", ")", "for", "i", "in", "re", ".", "findall", "(", "r\"[A-Za-z]+'?[A-...
Collect all words from document into dictionary data structures.
[ "Collect", "all", "words", "from", "document", "into", "dictionary", "data", "structures", "." ]
[ "\"\"\"Collect all words from document into dictionary data structures.\"\"\"", "# get wordlist", "# store document specific dictionary" ]
[ { "param": "document", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "document", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b486d7ffc3e836ec2d4c6cf1875913f42134a69b
dcavar/dcavar.github.io
MIREParse/fileshare/files/MIParser-stable.py
[ "Apache-2.0" ]
Python
addToHash
null
def addToHash(self, entry, table): """Does the grunt work of adding an entry to the hash tables.""" if table.has_key(entry): table[entry] += 1 else: table[entry] = 1
Does the grunt work of adding an entry to the hash tables.
Does the grunt work of adding an entry to the hash tables.
[ "Does", "the", "grunt", "work", "of", "adding", "an", "entry", "to", "the", "hash", "tables", "." ]
def addToHash(self, entry, table): if table.has_key(entry): table[entry] += 1 else: table[entry] = 1
[ "def", "addToHash", "(", "self", ",", "entry", ",", "table", ")", ":", "if", "table", ".", "has_key", "(", "entry", ")", ":", "table", "[", "entry", "]", "+=", "1", "else", ":", "table", "[", "entry", "]", "=", "1" ]
Does the grunt work of adding an entry to the hash tables.
[ "Does", "the", "grunt", "work", "of", "adding", "an", "entry", "to", "the", "hash", "tables", "." ]
[ "\"\"\"Does the grunt work of adding an entry to the hash tables.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "entry", "type": null }, { "param": "table", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "entry", "type": null, "docstring": null, "docstring_tokens": ...
b486d7ffc3e836ec2d4c6cf1875913f42134a69b
dcavar/dcavar.github.io
MIREParse/fileshare/files/MIParser-stable.py
[ "Apache-2.0" ]
Python
addUDHash
null
def addUDHash(self, entry): """Adds to the left and right hash tables.""" # create the token-token left table if self.myData.totoLeft.has_key(entry[0]): if entry[2] in self.myData.totoLeft[entry[0]]: self.myData.totoLeft[entry[0]][0] += 1 else: self.myData.totoLeft[entry[0]][0] += 1 self.myData....
Adds to the left and right hash tables.
Adds to the left and right hash tables.
[ "Adds", "to", "the", "left", "and", "right", "hash", "tables", "." ]
def addUDHash(self, entry): if self.myData.totoLeft.has_key(entry[0]): if entry[2] in self.myData.totoLeft[entry[0]]: self.myData.totoLeft[entry[0]][0] += 1 else: self.myData.totoLeft[entry[0]][0] += 1 self.myData.totoLeft[entry[0]][1].append(entry[2]) else: self.myData.totoLeft[entry[0]] = [ 1...
[ "def", "addUDHash", "(", "self", ",", "entry", ")", ":", "if", "self", ".", "myData", ".", "totoLeft", ".", "has_key", "(", "entry", "[", "0", "]", ")", ":", "if", "entry", "[", "2", "]", "in", "self", ".", "myData", ".", "totoLeft", "[", "entry"...
Adds to the left and right hash tables.
[ "Adds", "to", "the", "left", "and", "right", "hash", "tables", "." ]
[ "\"\"\"Adds to the left and right hash tables.\"\"\"", "# create the token-token left table", "# create the token-type left table", "# create the type-token left table", "# create the type-type left table", "# create the token-token right table", "# create the token-type right table", "# create the ty...
[ { "param": "self", "type": null }, { "param": "entry", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "entry", "type": null, "docstring": null, "docstring_tokens": ...
b486d7ffc3e836ec2d4c6cf1875913f42134a69b
dcavar/dcavar.github.io
MIREParse/fileshare/files/MIParser-stable.py
[ "Apache-2.0" ]
Python
addBigrams
null
def addBigrams(self, words): """Creates a list of bigrams in an utterance. A bigram here is a list of two words (that include the tagging information). These bigrams are then added to the bigram hash tables.""" self.myData.counts["wordCnt"] += len(words) bigramList = [] for i in range(len(words)-1): b...
Creates a list of bigrams in an utterance. A bigram here is a list of two words (that include the tagging information). These bigrams are then added to the bigram hash tables.
Creates a list of bigrams in an utterance. A bigram here is a list of two words (that include the tagging information). These bigrams are then added to the bigram hash tables.
[ "Creates", "a", "list", "of", "bigrams", "in", "an", "utterance", ".", "A", "bigram", "here", "is", "a", "list", "of", "two", "words", "(", "that", "include", "the", "tagging", "information", ")", ".", "These", "bigrams", "are", "then", "added", "to", ...
def addBigrams(self, words): self.myData.counts["wordCnt"] += len(words) bigramList = [] for i in range(len(words)-1): bigram = [words[i], words[i+1]] bigramList.append(bigram) self.myData.counts["bigramCnt"] += len(bigramList) for b in bigramList: brownsplit=compiled.match(b[0]); word1=[brownspli...
[ "def", "addBigrams", "(", "self", ",", "words", ")", ":", "self", ".", "myData", ".", "counts", "[", "\"wordCnt\"", "]", "+=", "len", "(", "words", ")", "bigramList", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "words", ")", "-", "...
Creates a list of bigrams in an utterance.
[ "Creates", "a", "list", "of", "bigrams", "in", "an", "utterance", "." ]
[ "\"\"\"Creates a list of bigrams in an utterance. A bigram here is a list of\n\t\t\ttwo words (that include the tagging information). These bigrams are \n\t\t\tthen added to the bigram hash tables.\"\"\"", "# add the bigram to the tables", "#word1 = string.split(b[0], TAGSEP)", "#word2 = string.split(b[1], TA...
[ { "param": "self", "type": null }, { "param": "words", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "words", "type": null, "docstring": null, "docstring_tokens": ...