repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/session_entity_types_client.py
SessionEntityTypesClient.update_session_entity_type
def update_session_entity_type( self, session_entity_type, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Updates the specified session entity ty...
python
def update_session_entity_type( self, session_entity_type, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Updates the specified session entity ty...
[ "def", "update_session_entity_type", "(", "self", ",", "session_entity_type", ",", "update_mask", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", ...
Updates the specified session entity type. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.SessionEntityTypesClient() >>> >>> # TODO: Initialize ``session_entity_type``: >>> session_entity_type = {} >>> ...
[ "Updates", "the", "specified", "session", "entity", "type", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/session_entity_types_client.py#L417-L482
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/session_entity_types_client.py
SessionEntityTypesClient.delete_session_entity_type
def delete_session_entity_type( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Deletes the specified session entity type. Example: >>> import ...
python
def delete_session_entity_type( self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Deletes the specified session entity type. Example: >>> import ...
[ "def", "delete_session_entity_type", "(", "self", ",", "name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ","...
Deletes the specified session entity type. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.SessionEntityTypesClient() >>> >>> name = client.session_entity_type_path('[PROJECT]', '[SESSION]', '[ENTITY_TYPE]') >>> ...
[ "Deletes", "the", "specified", "session", "entity", "type", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/session_entity_types_client.py#L484-L537
train
googleapis/dialogflow-python-client-v2
samples/knowledge_base_management.py
list_knowledge_bases
def list_knowledge_bases(project_id): """Lists the Knowledge bases belonging to a project. Args: project_id: The GCP project linked with the agent.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.KnowledgeBasesClient() project_path = client.project_path(project_id) print...
python
def list_knowledge_bases(project_id): """Lists the Knowledge bases belonging to a project. Args: project_id: The GCP project linked with the agent.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.KnowledgeBasesClient() project_path = client.project_path(project_id) print...
[ "def", "list_knowledge_bases", "(", "project_id", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "client", "=", "dialogflow", ".", "KnowledgeBasesClient", "(", ")", "project_path", "=", "client", ".", "project_path", "(", "project_id", ")", "print", ...
Lists the Knowledge bases belonging to a project. Args: project_id: The GCP project linked with the agent.
[ "Lists", "the", "Knowledge", "bases", "belonging", "to", "a", "project", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/knowledge_base_management.py#L35-L47
train
googleapis/dialogflow-python-client-v2
samples/knowledge_base_management.py
create_knowledge_base
def create_knowledge_base(project_id, display_name): """Creates a Knowledge base. Args: project_id: The GCP project linked with the agent. display_name: The display name of the Knowledge base.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.KnowledgeBasesClient() proj...
python
def create_knowledge_base(project_id, display_name): """Creates a Knowledge base. Args: project_id: The GCP project linked with the agent. display_name: The display name of the Knowledge base.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.KnowledgeBasesClient() proj...
[ "def", "create_knowledge_base", "(", "project_id", ",", "display_name", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "client", "=", "dialogflow", ".", "KnowledgeBasesClient", "(", ")", "project_path", "=", "client", ".", "project_path", "(", "projec...
Creates a Knowledge base. Args: project_id: The GCP project linked with the agent. display_name: The display name of the Knowledge base.
[ "Creates", "a", "Knowledge", "base", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/knowledge_base_management.py#L52-L69
train
googleapis/dialogflow-python-client-v2
samples/knowledge_base_management.py
get_knowledge_base
def get_knowledge_base(project_id, knowledge_base_id): """Gets a specific Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.KnowledgeBasesClient() knowl...
python
def get_knowledge_base(project_id, knowledge_base_id): """Gets a specific Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.KnowledgeBasesClient() knowl...
[ "def", "get_knowledge_base", "(", "project_id", ",", "knowledge_base_id", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "client", "=", "dialogflow", ".", "KnowledgeBasesClient", "(", ")", "knowledge_base_path", "=", "client", ".", "knowledge_base_path", ...
Gets a specific Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.
[ "Gets", "a", "specific", "Knowledge", "base", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/knowledge_base_management.py#L74-L89
train
googleapis/dialogflow-python-client-v2
samples/knowledge_base_management.py
delete_knowledge_base
def delete_knowledge_base(project_id, knowledge_base_id): """Deletes a specific Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.KnowledgeBasesClient() ...
python
def delete_knowledge_base(project_id, knowledge_base_id): """Deletes a specific Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.KnowledgeBasesClient() ...
[ "def", "delete_knowledge_base", "(", "project_id", ",", "knowledge_base_id", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "client", "=", "dialogflow", ".", "KnowledgeBasesClient", "(", ")", "knowledge_base_path", "=", "client", ".", "knowledge_base_path...
Deletes a specific Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.
[ "Deletes", "a", "specific", "Knowledge", "base", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/knowledge_base_management.py#L94-L107
train
googleapis/dialogflow-python-client-v2
samples/detect_intent_with_texttospeech_response.py
detect_intent_with_texttospeech_response
def detect_intent_with_texttospeech_response(project_id, session_id, texts, language_code): """Returns the result of detect intent with texts as inputs and includes the response in an audio format. Using the same `session_id` between requests allows continuation...
python
def detect_intent_with_texttospeech_response(project_id, session_id, texts, language_code): """Returns the result of detect intent with texts as inputs and includes the response in an audio format. Using the same `session_id` between requests allows continuation...
[ "def", "detect_intent_with_texttospeech_response", "(", "project_id", ",", "session_id", ",", "texts", ",", "language_code", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "session_client", "=", "dialogflow", ".", "SessionsClient", "(", ")", "session_path...
Returns the result of detect intent with texts as inputs and includes the response in an audio format. Using the same `session_id` between requests allows continuation of the conversaion.
[ "Returns", "the", "result", "of", "detect", "intent", "with", "texts", "as", "inputs", "and", "includes", "the", "response", "in", "an", "audio", "format", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/detect_intent_with_texttospeech_response.py#L30-L68
train
googleapis/dialogflow-python-client-v2
samples/detect_intent_with_model_selection.py
detect_intent_with_model_selection
def detect_intent_with_model_selection(project_id, session_id, audio_file_path, language_code): """Returns the result of detect intent with model selection on an audio file as input Using the same `session_id` between requests allows continuation of the conversaio...
python
def detect_intent_with_model_selection(project_id, session_id, audio_file_path, language_code): """Returns the result of detect intent with model selection on an audio file as input Using the same `session_id` between requests allows continuation of the conversaio...
[ "def", "detect_intent_with_model_selection", "(", "project_id", ",", "session_id", ",", "audio_file_path", ",", "language_code", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "session_client", "=", "dialogflow", ".", "SessionsClient", "(", ")", "# Note: ...
Returns the result of detect intent with model selection on an audio file as input Using the same `session_id` between requests allows continuation of the conversaion.
[ "Returns", "the", "result", "of", "detect", "intent", "with", "model", "selection", "on", "an", "audio", "file", "as", "input" ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/detect_intent_with_model_selection.py#L30-L70
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/knowledge_bases_client.py
KnowledgeBasesClient.knowledge_base_path
def knowledge_base_path(cls, project, knowledge_base): """Return a fully-qualified knowledge_base string.""" return google.api_core.path_template.expand( 'projects/{project}/knowledgeBases/{knowledge_base}', project=project, knowledge_base=knowledge_base, )
python
def knowledge_base_path(cls, project, knowledge_base): """Return a fully-qualified knowledge_base string.""" return google.api_core.path_template.expand( 'projects/{project}/knowledgeBases/{knowledge_base}', project=project, knowledge_base=knowledge_base, )
[ "def", "knowledge_base_path", "(", "cls", ",", "project", ",", "knowledge_base", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/knowledgeBases/{knowledge_base}'", ",", "project", "=", "project", ",", "kn...
Return a fully-qualified knowledge_base string.
[ "Return", "a", "fully", "-", "qualified", "knowledge_base", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/knowledge_bases_client.py#L97-L103
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/knowledge_bases_client.py
KnowledgeBasesClient.get_knowledge_base
def get_knowledge_base(self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves the specified knowledge base. ...
python
def get_knowledge_base(self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves the specified knowledge base. ...
[ "def", "get_knowledge_base", "(", "self", ",", "name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "met...
Retrieves the specified knowledge base. Example: >>> import dialogflow_v2beta1 >>> >>> client = dialogflow_v2beta1.KnowledgeBasesClient() >>> >>> name = client.knowledge_base_path('[PROJECT]', '[KNOWLEDGE_BASE]') >>> >>> respon...
[ "Retrieves", "the", "specified", "knowledge", "base", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/knowledge_bases_client.py#L283-L336
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/knowledge_bases_client.py
KnowledgeBasesClient.create_knowledge_base
def create_knowledge_base(self, parent, knowledge_base, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): ...
python
def create_knowledge_base(self, parent, knowledge_base, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): ...
[ "def", "create_knowledge_base", "(", "self", ",", "parent", ",", "knowledge_base", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ...
Creates a knowledge base. Example: >>> import dialogflow_v2beta1 >>> >>> client = dialogflow_v2beta1.KnowledgeBasesClient() >>> >>> parent = client.project_path('[PROJECT]') >>> >>> # TODO: Initialize ``knowledge_base``: ...
[ "Creates", "a", "knowledge", "base", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/knowledge_bases_client.py#L338-L401
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/session_entity_types_client.py
SessionEntityTypesClient.environment_session_path
def environment_session_path(cls, project, environment, user, session): """Return a fully-qualified environment_session string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}', project=project, ...
python
def environment_session_path(cls, project, environment, user, session): """Return a fully-qualified environment_session string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/environments/{environment}/users/{user}/sessions/{session}', project=project, ...
[ "def", "environment_session_path", "(", "cls", ",", "project", ",", "environment", ",", "user", ",", "session", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/agent/environments/{environment}/users/{user}/se...
Return a fully-qualified environment_session string.
[ "Return", "a", "fully", "-", "qualified", "environment_session", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/session_entity_types_client.py#L109-L117
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/session_entity_types_client.py
SessionEntityTypesClient.environment_session_entity_type_path
def environment_session_entity_type_path(cls, project, environment, user, session, entity_type): """Return a fully-qualified environment_session_entity_type string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/environm...
python
def environment_session_entity_type_path(cls, project, environment, user, session, entity_type): """Return a fully-qualified environment_session_entity_type string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/environm...
[ "def", "environment_session_entity_type_path", "(", "cls", ",", "project", ",", "environment", ",", "user", ",", "session", ",", "entity_type", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/agent/enviro...
Return a fully-qualified environment_session_entity_type string.
[ "Return", "a", "fully", "-", "qualified", "environment_session_entity_type", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/session_entity_types_client.py#L130-L140
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/documents_client.py
DocumentsClient.document_path
def document_path(cls, project, knowledge_base, document): """Return a fully-qualified document string.""" return google.api_core.path_template.expand( 'projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}', project=project, knowledge_base=knowledge...
python
def document_path(cls, project, knowledge_base, document): """Return a fully-qualified document string.""" return google.api_core.path_template.expand( 'projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}', project=project, knowledge_base=knowledge...
[ "def", "document_path", "(", "cls", ",", "project", ",", "knowledge_base", ",", "document", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/knowledgeBases/{knowledge_base}/documents/{document}'", ",", "projec...
Return a fully-qualified document string.
[ "Return", "a", "fully", "-", "qualified", "document", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/documents_client.py#L90-L97
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/documents_client.py
DocumentsClient.list_documents
def list_documents(self, parent, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Returns the list of all ...
python
def list_documents(self, parent, page_size=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Returns the list of all ...
[ "def", "list_documents", "(", "self", ",", "parent", ",", "page_size", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "metho...
Returns the list of all documents of the knowledge base. Example: >>> import dialogflow_v2beta1 >>> >>> client = dialogflow_v2beta1.DocumentsClient() >>> >>> parent = client.knowledge_base_path('[PROJECT]', '[KNOWLEDGE_BASE]') >>> ...
[ "Returns", "the", "list", "of", "all", "documents", "of", "the", "knowledge", "base", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/documents_client.py#L187-L274
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/documents_client.py
DocumentsClient.delete_document
def delete_document(self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Deletes the specified document. Operation <response...
python
def delete_document(self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Deletes the specified document. Operation <response...
[ "def", "delete_document", "(", "self", ",", "name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "metada...
Deletes the specified document. Operation <response: ``google.protobuf.Empty``, metadata: [KnowledgeOperationMetadata][google.cloud.dialogflow.v2beta1.KnowledgeOperationMetadata]> Example: >>> import dialogflow_v2beta1 >>> >>> client = dialogflow_v2beta1.Doc...
[ "Deletes", "the", "specified", "document", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/documents_client.py#L413-L484
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/contexts_client.py
ContextsClient.context_path
def context_path(cls, project, session, context): """Return a fully-qualified context string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/sessions/{session}/contexts/{context}', project=project, session=session, context=contex...
python
def context_path(cls, project, session, context): """Return a fully-qualified context string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/sessions/{session}/contexts/{context}', project=project, session=session, context=contex...
[ "def", "context_path", "(", "cls", ",", "project", ",", "session", ",", "context", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/agent/sessions/{session}/contexts/{context}'", ",", "project", "=", "proj...
Return a fully-qualified context string.
[ "Return", "a", "fully", "-", "qualified", "context", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/contexts_client.py#L104-L111
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/contexts_client.py
ContextsClient.get_context
def get_context(self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves the specified context. Example: >>> import dialog...
python
def get_context(self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves the specified context. Example: >>> import dialog...
[ "def", "get_context", "(", "self", ",", "name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "metadata",...
Retrieves the specified context. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.ContextsClient() >>> >>> name = client.context_path('[PROJECT]', '[SESSION]', '[CONTEXT]') >>> >>> response = client.get_context(...
[ "Retrieves", "the", "specified", "context", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/contexts_client.py#L290-L341
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/contexts_client.py
ContextsClient.update_context
def update_context(self, context, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Updates the specified...
python
def update_context(self, context, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Updates the specified...
[ "def", "update_context", "(", "self", ",", "context", ",", "update_mask", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "me...
Updates the specified context. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.ContextsClient() >>> >>> # TODO: Initialize ``context``: >>> context = {} >>> >>> response = client.update_context(cont...
[ "Updates", "the", "specified", "context", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/contexts_client.py#L407-L468
train
googleapis/dialogflow-python-client-v2
samples/session_entity_type_management.py
create_session_entity_type
def create_session_entity_type(project_id, session_id, entity_values, entity_type_display_name, entity_override_mode): """Create a session entity type with the given display name.""" import dialogflow_v2 as dialogflow session_entity_types_client = dialogflow.SessionEntityTypes...
python
def create_session_entity_type(project_id, session_id, entity_values, entity_type_display_name, entity_override_mode): """Create a session entity type with the given display name.""" import dialogflow_v2 as dialogflow session_entity_types_client = dialogflow.SessionEntityTypes...
[ "def", "create_session_entity_type", "(", "project_id", ",", "session_id", ",", "entity_values", ",", "entity_type_display_name", ",", "entity_override_mode", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "session_entity_types_client", "=", "dialogflow", ".", "...
Create a session entity type with the given display name.
[ "Create", "a", "session", "entity", "type", "with", "the", "given", "display", "name", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/session_entity_type_management.py#L54-L78
train
googleapis/dialogflow-python-client-v2
samples/session_entity_type_management.py
delete_session_entity_type
def delete_session_entity_type(project_id, session_id, entity_type_display_name): """Delete session entity type with the given entity type display name.""" import dialogflow_v2 as dialogflow session_entity_types_client = dialogflow.SessionEntityTypesClient() session_entit...
python
def delete_session_entity_type(project_id, session_id, entity_type_display_name): """Delete session entity type with the given entity type display name.""" import dialogflow_v2 as dialogflow session_entity_types_client = dialogflow.SessionEntityTypesClient() session_entit...
[ "def", "delete_session_entity_type", "(", "project_id", ",", "session_id", ",", "entity_type_display_name", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "session_entity_types_client", "=", "dialogflow", ".", "SessionEntityTypesClient", "(", ")", "session_entity_...
Delete session entity type with the given entity type display name.
[ "Delete", "session", "entity", "type", "with", "the", "given", "entity", "type", "display", "name", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/session_entity_type_management.py#L83-L94
train
googleapis/dialogflow-python-client-v2
samples/entity_type_management.py
create_entity_type
def create_entity_type(project_id, display_name, kind): """Create an entity type with the given display name.""" import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() parent = entity_types_client.project_agent_path(project_id) entity_type = dialogflow.types.EntityT...
python
def create_entity_type(project_id, display_name, kind): """Create an entity type with the given display name.""" import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() parent = entity_types_client.project_agent_path(project_id) entity_type = dialogflow.types.EntityT...
[ "def", "create_entity_type", "(", "project_id", ",", "display_name", ",", "kind", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "entity_types_client", "=", "dialogflow", ".", "EntityTypesClient", "(", ")", "parent", "=", "entity_types_client", ".", "proje...
Create an entity type with the given display name.
[ "Create", "an", "entity", "type", "with", "the", "given", "display", "name", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/entity_type_management.py#L45-L56
train
googleapis/dialogflow-python-client-v2
samples/entity_type_management.py
delete_entity_type
def delete_entity_type(project_id, entity_type_id): """Delete entity type with the given entity type name.""" import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() entity_type_path = entity_types_client.entity_type_path( project_id, entity_type_id) entity_...
python
def delete_entity_type(project_id, entity_type_id): """Delete entity type with the given entity type name.""" import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() entity_type_path = entity_types_client.entity_type_path( project_id, entity_type_id) entity_...
[ "def", "delete_entity_type", "(", "project_id", ",", "entity_type_id", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "entity_types_client", "=", "dialogflow", ".", "EntityTypesClient", "(", ")", "entity_type_path", "=", "entity_types_client", ".", "entity_typ...
Delete entity type with the given entity type name.
[ "Delete", "entity", "type", "with", "the", "given", "entity", "type", "name", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/entity_type_management.py#L61-L69
train
googleapis/dialogflow-python-client-v2
samples/detect_intent_texts.py
detect_intent_texts
def detect_intent_texts(project_id, session_id, texts, language_code): """Returns the result of detect intent with texts as inputs. Using the same `session_id` between requests allows continuation of the conversation.""" import dialogflow_v2 as dialogflow session_client = dialogflow.SessionsClient...
python
def detect_intent_texts(project_id, session_id, texts, language_code): """Returns the result of detect intent with texts as inputs. Using the same `session_id` between requests allows continuation of the conversation.""" import dialogflow_v2 as dialogflow session_client = dialogflow.SessionsClient...
[ "def", "detect_intent_texts", "(", "project_id", ",", "session_id", ",", "texts", ",", "language_code", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "session_client", "=", "dialogflow", ".", "SessionsClient", "(", ")", "session", "=", "session_client", ...
Returns the result of detect intent with texts as inputs. Using the same `session_id` between requests allows continuation of the conversation.
[ "Returns", "the", "result", "of", "detect", "intent", "with", "texts", "as", "inputs", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/detect_intent_texts.py#L34-L61
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/entity_types_client.py
EntityTypesClient.entity_type_path
def entity_type_path(cls, project, entity_type): """Return a fully-qualified entity_type string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/entityTypes/{entity_type}', project=project, entity_type=entity_type, )
python
def entity_type_path(cls, project, entity_type): """Return a fully-qualified entity_type string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/entityTypes/{entity_type}', project=project, entity_type=entity_type, )
[ "def", "entity_type_path", "(", "cls", ",", "project", ",", "entity_type", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/agent/entityTypes/{entity_type}'", ",", "project", "=", "project", ",", "entity_t...
Return a fully-qualified entity_type string.
[ "Return", "a", "fully", "-", "qualified", "entity_type", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/entity_types_client.py#L118-L124
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/entity_types_client.py
EntityTypesClient.get_entity_type
def get_entity_type(self, name, language_code=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves the sp...
python
def get_entity_type(self, name, language_code=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves the sp...
[ "def", "get_entity_type", "(", "self", ",", "name", ",", "language_code", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "me...
Retrieves the specified entity type. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.EntityTypesClient() >>> >>> name = client.entity_type_path('[PROJECT]', '[ENTITY_TYPE]') >>> >>> response = client.get_entity...
[ "Retrieves", "the", "specified", "entity", "type", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/entity_types_client.py#L311-L372
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/entity_types_client.py
EntityTypesClient.create_entity_type
def create_entity_type(self, parent, entity_type, language_code=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
python
def create_entity_type(self, parent, entity_type, language_code=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
[ "def", "create_entity_type", "(", "self", ",", "parent", ",", "entity_type", ",", "language_code", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", "....
Creates an entity type in the specified agent. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.EntityTypesClient() >>> >>> parent = client.project_agent_path('[PROJECT]') >>> >>> # TODO: Initialize ``entity_typ...
[ "Creates", "an", "entity", "type", "in", "the", "specified", "agent", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/entity_types_client.py#L374-L444
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/entity_types_client.py
EntityTypesClient.update_entity_type
def update_entity_type(self, entity_type, language_code=None, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
python
def update_entity_type(self, entity_type, language_code=None, update_mask=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
[ "def", "update_entity_type", "(", "self", ",", "entity_type", ",", "language_code", "=", "None", ",", "update_mask", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", "...
Updates the specified entity type. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.EntityTypesClient() >>> >>> # TODO: Initialize ``entity_type``: >>> entity_type = {} >>> >>> response = client.upda...
[ "Updates", "the", "specified", "entity", "type", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/entity_types_client.py#L446-L516
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/entity_types_client.py
EntityTypesClient.batch_delete_entities
def batch_delete_entities(self, parent, entity_values, language_code=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT,...
python
def batch_delete_entities(self, parent, entity_values, language_code=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT,...
[ "def", "batch_delete_entities", "(", "self", ",", "parent", ",", "entity_values", ",", "language_code", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core",...
Deletes entities in the specified entity type. Operation <response: ``google.protobuf.Empty``, metadata: [google.protobuf.Struct][google.protobuf.Struct]> Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.EntityTypesClient() >>> ...
[ "Deletes", "entities", "in", "the", "specified", "entity", "type", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/entity_types_client.py#L945-L1033
train
googleapis/dialogflow-python-client-v2
samples/detect_intent_knowledge.py
detect_intent_knowledge
def detect_intent_knowledge(project_id, session_id, language_code, knowledge_base_id, texts): """Returns the result of detect intent with querying Knowledge Connector. Args: project_id: The GCP project linked with the agent you are going to query. session_id: Id of the sessi...
python
def detect_intent_knowledge(project_id, session_id, language_code, knowledge_base_id, texts): """Returns the result of detect intent with querying Knowledge Connector. Args: project_id: The GCP project linked with the agent you are going to query. session_id: Id of the sessi...
[ "def", "detect_intent_knowledge", "(", "project_id", ",", "session_id", ",", "language_code", ",", "knowledge_base_id", ",", "texts", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "session_client", "=", "dialogflow", ".", "SessionsClient", "(", ")", ...
Returns the result of detect intent with querying Knowledge Connector. Args: project_id: The GCP project linked with the agent you are going to query. session_id: Id of the session, using the same `session_id` between requests allows continuation of the conversation. language_code: Langua...
[ "Returns", "the", "result", "of", "detect", "intent", "with", "querying", "Knowledge", "Connector", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/detect_intent_knowledge.py#L31-L78
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/intents_client.py
IntentsClient.intent_path
def intent_path(cls, project, intent): """Return a fully-qualified intent string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/intents/{intent}', project=project, intent=intent, )
python
def intent_path(cls, project, intent): """Return a fully-qualified intent string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/intents/{intent}', project=project, intent=intent, )
[ "def", "intent_path", "(", "cls", ",", "project", ",", "intent", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/agent/intents/{intent}'", ",", "project", "=", "project", ",", "intent", "=", "intent",...
Return a fully-qualified intent string.
[ "Return", "a", "fully", "-", "qualified", "intent", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L125-L131
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/intents_client.py
IntentsClient.agent_path
def agent_path(cls, project, agent): """Return a fully-qualified agent string.""" return google.api_core.path_template.expand( 'projects/{project}/agents/{agent}', project=project, agent=agent, )
python
def agent_path(cls, project, agent): """Return a fully-qualified agent string.""" return google.api_core.path_template.expand( 'projects/{project}/agents/{agent}', project=project, agent=agent, )
[ "def", "agent_path", "(", "cls", ",", "project", ",", "agent", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/agents/{agent}'", ",", "project", "=", "project", ",", "agent", "=", "agent", ",", ")...
Return a fully-qualified agent string.
[ "Return", "a", "fully", "-", "qualified", "agent", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L134-L140
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/intents_client.py
IntentsClient.get_intent
def get_intent(self, name, language_code=None, intent_view=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves...
python
def get_intent(self, name, language_code=None, intent_view=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves...
[ "def", "get_intent", "(", "self", ",", "name", ",", "language_code", "=", "None", ",", "intent_view", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core...
Retrieves the specified intent. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.IntentsClient() >>> >>> name = client.intent_path('[PROJECT]', '[INTENT]') >>> >>> response = client.get_intent(name) Arg...
[ "Retrieves", "the", "specified", "intent", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L328-L391
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/intents_client.py
IntentsClient.create_intent
def create_intent(self, parent, intent, language_code=None, intent_view=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
python
def create_intent(self, parent, intent, language_code=None, intent_view=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
[ "def", "create_intent", "(", "self", ",", "parent", ",", "intent", ",", "language_code", "=", "None", ",", "intent_view", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "goo...
Creates an intent in the specified agent. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.IntentsClient() >>> >>> parent = client.project_agent_path('[PROJECT]') >>> >>> # TODO: Initialize ``intent``: ...
[ "Creates", "an", "intent", "in", "the", "specified", "agent", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L393-L465
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/intents_client.py
IntentsClient.update_intent
def update_intent(self, intent, language_code, update_mask=None, intent_view=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
python
def update_intent(self, intent, language_code, update_mask=None, intent_view=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, ...
[ "def", "update_intent", "(", "self", ",", "intent", ",", "language_code", ",", "update_mask", "=", "None", ",", "intent_view", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", ...
Updates the specified intent. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.IntentsClient() >>> >>> # TODO: Initialize ``intent``: >>> intent = {} >>> >>> # TODO: Initialize ``language_code``: ...
[ "Updates", "the", "specified", "intent", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L467-L542
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/intents_client.py
IntentsClient.delete_intent
def delete_intent(self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Deletes the specified intent. Example: >>> import...
python
def delete_intent(self, name, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Deletes the specified intent. Example: >>> import...
[ "def", "delete_intent", "(", "self", ",", "name", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "metadata...
Deletes the specified intent. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.IntentsClient() >>> >>> name = client.intent_path('[PROJECT]', '[INTENT]') >>> >>> client.delete_intent(name) Args: ...
[ "Deletes", "the", "specified", "intent", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L544-L593
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/intents_client.py
IntentsClient.batch_delete_intents
def batch_delete_intents(self, parent, intents, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ ...
python
def batch_delete_intents(self, parent, intents, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ ...
[ "def", "batch_delete_intents", "(", "self", ",", "parent", ",", "intents", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", ...
Deletes intents in the specified agent. Operation <response: ``google.protobuf.Empty``> Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.IntentsClient() >>> >>> parent = client.project_agent_path('[PROJECT]') >>> ...
[ "Deletes", "intents", "in", "the", "specified", "agent", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/intents_client.py#L704-L785
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/contexts_client.py
ContextsClient.environment_context_path
def environment_context_path(cls, project, environment, user, session, context): """Return a fully-qualified environment_context string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/environments/{environment}/users/{user}/sessions...
python
def environment_context_path(cls, project, environment, user, session, context): """Return a fully-qualified environment_context string.""" return google.api_core.path_template.expand( 'projects/{project}/agent/environments/{environment}/users/{user}/sessions...
[ "def", "environment_context_path", "(", "cls", ",", "project", ",", "environment", ",", "user", ",", "session", ",", "context", ")", ":", "return", "google", ".", "api_core", ".", "path_template", ".", "expand", "(", "'projects/{project}/agent/environments/{environm...
Return a fully-qualified environment_context string.
[ "Return", "a", "fully", "-", "qualified", "environment_context", "string", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/contexts_client.py#L125-L135
train
googleapis/dialogflow-python-client-v2
samples/detect_intent_with_sentiment_analysis.py
detect_intent_with_sentiment_analysis
def detect_intent_with_sentiment_analysis(project_id, session_id, texts, language_code): """Returns the result of detect intent with texts as inputs and analyzes the sentiment of the query text. Using the same `session_id` between requests allows continuation o...
python
def detect_intent_with_sentiment_analysis(project_id, session_id, texts, language_code): """Returns the result of detect intent with texts as inputs and analyzes the sentiment of the query text. Using the same `session_id` between requests allows continuation o...
[ "def", "detect_intent_with_sentiment_analysis", "(", "project_id", ",", "session_id", ",", "texts", ",", "language_code", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "session_client", "=", "dialogflow", ".", "SessionsClient", "(", ")", "session_path", ...
Returns the result of detect intent with texts as inputs and analyzes the sentiment of the query text. Using the same `session_id` between requests allows continuation of the conversaion.
[ "Returns", "the", "result", "of", "detect", "intent", "with", "texts", "as", "inputs", "and", "analyzes", "the", "sentiment", "of", "the", "query", "text", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/detect_intent_with_sentiment_analysis.py#L31-L75
train
googleapis/dialogflow-python-client-v2
dialogflow_v2beta1/gapic/sessions_client.py
SessionsClient.detect_intent
def detect_intent(self, session, query_input, query_params=None, output_audio_config=None, input_audio=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=go...
python
def detect_intent(self, session, query_input, query_params=None, output_audio_config=None, input_audio=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=go...
[ "def", "detect_intent", "(", "self", ",", "session", ",", "query_input", ",", "query_params", "=", "None", ",", "output_audio_config", "=", "None", ",", "input_audio", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method",...
Processes a natural language query and returns structured, actionable data as a result. This method is not idempotent, because it may cause contexts and session entity types to be updated, which in turn might affect results of future queries. Example: >>> import dialogflow_v...
[ "Processes", "a", "natural", "language", "query", "and", "returns", "structured", "actionable", "data", "as", "a", "result", ".", "This", "method", "is", "not", "idempotent", "because", "it", "may", "cause", "contexts", "and", "session", "entity", "types", "to...
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2beta1/gapic/sessions_client.py#L201-L299
train
googleapis/dialogflow-python-client-v2
samples/detect_intent_stream.py
detect_intent_stream
def detect_intent_stream(project_id, session_id, audio_file_path, language_code): """Returns the result of detect intent with streaming audio as input. Using the same `session_id` between requests allows continuation of the conversaion.""" import dialogflow_v2 as dialogflow ...
python
def detect_intent_stream(project_id, session_id, audio_file_path, language_code): """Returns the result of detect intent with streaming audio as input. Using the same `session_id` between requests allows continuation of the conversaion.""" import dialogflow_v2 as dialogflow ...
[ "def", "detect_intent_stream", "(", "project_id", ",", "session_id", ",", "audio_file_path", ",", "language_code", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "session_client", "=", "dialogflow", ".", "SessionsClient", "(", ")", "# Note: hard coding audio_e...
Returns the result of detect intent with streaming audio as input. Using the same `session_id` between requests allows continuation of the conversaion.
[ "Returns", "the", "result", "of", "detect", "intent", "with", "streaming", "audio", "as", "input", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/detect_intent_stream.py#L33-L90
train
googleapis/dialogflow-python-client-v2
samples/intent_management.py
create_intent
def create_intent(project_id, display_name, training_phrases_parts, message_texts): """Create an intent of the given intent type.""" import dialogflow_v2 as dialogflow intents_client = dialogflow.IntentsClient() parent = intents_client.project_agent_path(project_id) training_phras...
python
def create_intent(project_id, display_name, training_phrases_parts, message_texts): """Create an intent of the given intent type.""" import dialogflow_v2 as dialogflow intents_client = dialogflow.IntentsClient() parent = intents_client.project_agent_path(project_id) training_phras...
[ "def", "create_intent", "(", "project_id", ",", "display_name", ",", "training_phrases_parts", ",", "message_texts", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "intents_client", "=", "dialogflow", ".", "IntentsClient", "(", ")", "parent", "=", "intents...
Create an intent of the given intent type.
[ "Create", "an", "intent", "of", "the", "given", "intent", "type", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/intent_management.py#L63-L88
train
googleapis/dialogflow-python-client-v2
samples/intent_management.py
delete_intent
def delete_intent(project_id, intent_id): """Delete intent with the given intent type and intent value.""" import dialogflow_v2 as dialogflow intents_client = dialogflow.IntentsClient() intent_path = intents_client.intent_path(project_id, intent_id) intents_client.delete_intent(intent_path)
python
def delete_intent(project_id, intent_id): """Delete intent with the given intent type and intent value.""" import dialogflow_v2 as dialogflow intents_client = dialogflow.IntentsClient() intent_path = intents_client.intent_path(project_id, intent_id) intents_client.delete_intent(intent_path)
[ "def", "delete_intent", "(", "project_id", ",", "intent_id", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "intents_client", "=", "dialogflow", ".", "IntentsClient", "(", ")", "intent_path", "=", "intents_client", ".", "intent_path", "(", "project_id", ...
Delete intent with the given intent type and intent value.
[ "Delete", "intent", "with", "the", "given", "intent", "type", "and", "intent", "value", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/intent_management.py#L93-L100
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/agents_client.py
AgentsClient.get_agent
def get_agent(self, parent, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves the specified agent. Example: >>> import dialogflow_v2 ...
python
def get_agent(self, parent, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Retrieves the specified agent. Example: >>> import dialogflow_v2 ...
[ "def", "get_agent", "(", "self", ",", "parent", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "metadata",...
Retrieves the specified agent. Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.AgentsClient() >>> >>> parent = client.project_path('[PROJECT]') >>> >>> response = client.get_agent(parent) Args: ...
[ "Retrieves", "the", "specified", "agent", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/agents_client.py#L197-L248
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/agents_client.py
AgentsClient.train_agent
def train_agent(self, parent, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Trains the specified agent. Operation <response: ``google.protobuf.Em...
python
def train_agent(self, parent, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Trains the specified agent. Operation <response: ``google.protobuf.Em...
[ "def", "train_agent", "(", "self", ",", "parent", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "metadata...
Trains the specified agent. Operation <response: ``google.protobuf.Empty``, metadata: [google.protobuf.Struct][google.protobuf.Struct]> Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.AgentsClient() >>> >>> parent = c...
[ "Trains", "the", "specified", "agent", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/agents_client.py#L345-L414
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/agents_client.py
AgentsClient.export_agent
def export_agent(self, parent, agent_uri=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Exports the specified agent to a ZIP...
python
def export_agent(self, parent, agent_uri=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ Exports the specified agent to a ZIP...
[ "def", "export_agent", "(", "self", ",", "parent", ",", "agent_uri", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method"...
Exports the specified agent to a ZIP file. Operation <response: ``ExportAgentResponse``, metadata: [google.protobuf.Struct][google.protobuf.Struct]> Example: >>> import dialogflow_v2 >>> >>> client = dialogflow_v2.AgentsClient() >>> >...
[ "Exports", "the", "specified", "agent", "to", "a", "ZIP", "file", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/agents_client.py#L416-L493
train
googleapis/dialogflow-python-client-v2
dialogflow_v2/gapic/agents_client.py
AgentsClient.import_agent
def import_agent(self, parent, agent_uri=None, agent_content=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ ...
python
def import_agent(self, parent, agent_uri=None, agent_content=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ ...
[ "def", "import_agent", "(", "self", ",", "parent", ",", "agent_uri", "=", "None", ",", "agent_content", "=", "None", ",", "retry", "=", "google", ".", "api_core", ".", "gapic_v1", ".", "method", ".", "DEFAULT", ",", "timeout", "=", "google", ".", "api_co...
Imports the specified agent from a ZIP file. Uploads new intents and entity types without deleting the existing ones. Intents and entity types with the same name are replaced with the new versions from ImportAgentRequest. Operation <response: ``google.protobuf.Empty``, metadata...
[ "Imports", "the", "specified", "agent", "from", "a", "ZIP", "file", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/dialogflow_v2/gapic/agents_client.py#L495-L600
train
googleapis/dialogflow-python-client-v2
samples/document_management.py
list_documents
def list_documents(project_id, knowledge_base_id): """Lists the Documents belonging to a Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.DocumentsClient()...
python
def list_documents(project_id, knowledge_base_id): """Lists the Documents belonging to a Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.""" import dialogflow_v2beta1 as dialogflow client = dialogflow.DocumentsClient()...
[ "def", "list_documents", "(", "project_id", ",", "knowledge_base_id", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "client", "=", "dialogflow", ".", "DocumentsClient", "(", ")", "knowledge_base_path", "=", "client", ".", "knowledge_base_path", "(", ...
Lists the Documents belonging to a Knowledge base. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base.
[ "Lists", "the", "Documents", "belonging", "to", "a", "Knowledge", "base", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/document_management.py#L43-L62
train
googleapis/dialogflow-python-client-v2
samples/document_management.py
create_document
def create_document(project_id, knowledge_base_id, display_name, mime_type, knowledge_type, content_uri): """Creates a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. display_name: The display name of th...
python
def create_document(project_id, knowledge_base_id, display_name, mime_type, knowledge_type, content_uri): """Creates a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. display_name: The display name of th...
[ "def", "create_document", "(", "project_id", ",", "knowledge_base_id", ",", "display_name", ",", "mime_type", ",", "knowledge_type", ",", "content_uri", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "client", "=", "dialogflow", ".", "DocumentsClient", ...
Creates a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. display_name: The display name of the Document. mime_type: The mime_type of the Document. e.g. text/csv, text/html, text/plain, text/pdf etc. ...
[ "Creates", "a", "Document", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/document_management.py#L67-L103
train
googleapis/dialogflow-python-client-v2
samples/document_management.py
get_document
def get_document(project_id, knowledge_base_id, document_id): """Gets a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. document_id: Id of the Document.""" import dialogflow_v2beta1 as dialogflow client = dialogflow...
python
def get_document(project_id, knowledge_base_id, document_id): """Gets a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. document_id: Id of the Document.""" import dialogflow_v2beta1 as dialogflow client = dialogflow...
[ "def", "get_document", "(", "project_id", ",", "knowledge_base_id", ",", "document_id", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "client", "=", "dialogflow", ".", "DocumentsClient", "(", ")", "document_path", "=", "client", ".", "document_path",...
Gets a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. document_id: Id of the Document.
[ "Gets", "a", "Document", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/document_management.py#L108-L128
train
googleapis/dialogflow-python-client-v2
samples/document_management.py
delete_document
def delete_document(project_id, knowledge_base_id, document_id): """Deletes a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. document_id: Id of the Document.""" import dialogflow_v2beta1 as dialogflow client = dial...
python
def delete_document(project_id, knowledge_base_id, document_id): """Deletes a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. document_id: Id of the Document.""" import dialogflow_v2beta1 as dialogflow client = dial...
[ "def", "delete_document", "(", "project_id", ",", "knowledge_base_id", ",", "document_id", ")", ":", "import", "dialogflow_v2beta1", "as", "dialogflow", "client", "=", "dialogflow", ".", "DocumentsClient", "(", ")", "document_path", "=", "client", ".", "document_pat...
Deletes a Document. Args: project_id: The GCP project linked with the agent. knowledge_base_id: Id of the Knowledge base. document_id: Id of the Document.
[ "Deletes", "a", "Document", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/document_management.py#L133-L148
train
googleapis/dialogflow-python-client-v2
samples/entity_management.py
create_entity
def create_entity(project_id, entity_type_id, entity_value, synonyms): """Create an entity of the given entity type.""" import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() # Note: synonyms must be exactly [entity_value] if the # entity_type's kind is KIND_LIST ...
python
def create_entity(project_id, entity_type_id, entity_value, synonyms): """Create an entity of the given entity type.""" import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() # Note: synonyms must be exactly [entity_value] if the # entity_type's kind is KIND_LIST ...
[ "def", "create_entity", "(", "project_id", ",", "entity_type_id", ",", "entity_value", ",", "synonyms", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "entity_types_client", "=", "dialogflow", ".", "EntityTypesClient", "(", ")", "# Note: synonyms must be exact...
Create an entity of the given entity type.
[ "Create", "an", "entity", "of", "the", "given", "entity", "type", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/entity_management.py#L49-L68
train
googleapis/dialogflow-python-client-v2
samples/entity_management.py
delete_entity
def delete_entity(project_id, entity_type_id, entity_value): """Delete entity with the given entity type and entity value.""" import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() entity_type_path = entity_types_client.entity_type_path( project_id, entity_type_...
python
def delete_entity(project_id, entity_type_id, entity_value): """Delete entity with the given entity type and entity value.""" import dialogflow_v2 as dialogflow entity_types_client = dialogflow.EntityTypesClient() entity_type_path = entity_types_client.entity_type_path( project_id, entity_type_...
[ "def", "delete_entity", "(", "project_id", ",", "entity_type_id", ",", "entity_value", ")", ":", "import", "dialogflow_v2", "as", "dialogflow", "entity_types_client", "=", "dialogflow", ".", "EntityTypesClient", "(", ")", "entity_type_path", "=", "entity_types_client", ...
Delete entity with the given entity type and entity value.
[ "Delete", "entity", "with", "the", "given", "entity", "type", "and", "entity", "value", "." ]
8c9c8709222efe427b76c9c8fcc04a0c4a0760b5
https://github.com/googleapis/dialogflow-python-client-v2/blob/8c9c8709222efe427b76c9c8fcc04a0c4a0760b5/samples/entity_management.py#L73-L82
train
lucasb-eyer/pydensecrf
pydensecrf/utils.py
softmax_to_unary
def softmax_to_unary(sm, GT_PROB=1): """Deprecated, use `unary_from_softmax` instead.""" warning("pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.") scale = None if GT_PROB == 1 else GT_PROB return unary_from_softmax(sm, scale, clip=None)
python
def softmax_to_unary(sm, GT_PROB=1): """Deprecated, use `unary_from_softmax` instead.""" warning("pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.") scale = None if GT_PROB == 1 else GT_PROB return unary_from_softmax(sm, scale, clip=None)
[ "def", "softmax_to_unary", "(", "sm", ",", "GT_PROB", "=", "1", ")", ":", "warning", "(", "\"pydensecrf.softmax_to_unary is deprecated, use unary_from_softmax instead.\"", ")", "scale", "=", "None", "if", "GT_PROB", "==", "1", "else", "GT_PROB", "return", "unary_from_...
Deprecated, use `unary_from_softmax` instead.
[ "Deprecated", "use", "unary_from_softmax", "instead", "." ]
4d5343c398d75d7ebae34f51a47769084ba3a613
https://github.com/lucasb-eyer/pydensecrf/blob/4d5343c398d75d7ebae34f51a47769084ba3a613/pydensecrf/utils.py#L82-L86
train
lucasb-eyer/pydensecrf
pydensecrf/utils.py
create_pairwise_gaussian
def create_pairwise_gaussian(sdims, shape): """ Util function that create pairwise gaussian potentials. This works for all image dimensions. For the 2D case does the same as `DenseCRF2D.addPairwiseGaussian`. Parameters ---------- sdims: list or tuple The scaling factors per dimensio...
python
def create_pairwise_gaussian(sdims, shape): """ Util function that create pairwise gaussian potentials. This works for all image dimensions. For the 2D case does the same as `DenseCRF2D.addPairwiseGaussian`. Parameters ---------- sdims: list or tuple The scaling factors per dimensio...
[ "def", "create_pairwise_gaussian", "(", "sdims", ",", "shape", ")", ":", "# create mesh", "hcord_range", "=", "[", "range", "(", "s", ")", "for", "s", "in", "shape", "]", "mesh", "=", "np", ".", "array", "(", "np", ".", "meshgrid", "(", "*", "hcord_ran...
Util function that create pairwise gaussian potentials. This works for all image dimensions. For the 2D case does the same as `DenseCRF2D.addPairwiseGaussian`. Parameters ---------- sdims: list or tuple The scaling factors per dimension. This is referred to `sxy` in `DenseCRF2D.addP...
[ "Util", "function", "that", "create", "pairwise", "gaussian", "potentials", ".", "This", "works", "for", "all", "image", "dimensions", ".", "For", "the", "2D", "case", "does", "the", "same", "as", "DenseCRF2D", ".", "addPairwiseGaussian", "." ]
4d5343c398d75d7ebae34f51a47769084ba3a613
https://github.com/lucasb-eyer/pydensecrf/blob/4d5343c398d75d7ebae34f51a47769084ba3a613/pydensecrf/utils.py#L89-L111
train
lucasb-eyer/pydensecrf
pydensecrf/utils.py
create_pairwise_bilateral
def create_pairwise_bilateral(sdims, schan, img, chdim=-1): """ Util function that create pairwise bilateral potentials. This works for all image dimensions. For the 2D case does the same as `DenseCRF2D.addPairwiseBilateral`. Parameters ---------- sdims: list or tuple The scaling fa...
python
def create_pairwise_bilateral(sdims, schan, img, chdim=-1): """ Util function that create pairwise bilateral potentials. This works for all image dimensions. For the 2D case does the same as `DenseCRF2D.addPairwiseBilateral`. Parameters ---------- sdims: list or tuple The scaling fa...
[ "def", "create_pairwise_bilateral", "(", "sdims", ",", "schan", ",", "img", ",", "chdim", "=", "-", "1", ")", ":", "# Put channel dim in right position", "if", "chdim", "==", "-", "1", ":", "# We don't have a channel, add a new axis", "im_feat", "=", "img", "[", ...
Util function that create pairwise bilateral potentials. This works for all image dimensions. For the 2D case does the same as `DenseCRF2D.addPairwiseBilateral`. Parameters ---------- sdims: list or tuple The scaling factors per dimension. This is referred to `sxy` in `DenseCRF2D.ad...
[ "Util", "function", "that", "create", "pairwise", "bilateral", "potentials", ".", "This", "works", "for", "all", "image", "dimensions", ".", "For", "the", "2D", "case", "does", "the", "same", "as", "DenseCRF2D", ".", "addPairwiseBilateral", "." ]
4d5343c398d75d7ebae34f51a47769084ba3a613
https://github.com/lucasb-eyer/pydensecrf/blob/4d5343c398d75d7ebae34f51a47769084ba3a613/pydensecrf/utils.py#L114-L162
train
deanmalmgren/textract
textract/parsers/odt_parser.py
Parser.to_string
def to_string(self): """ Converts the document to a string. """ buff = u"" for child in self.content.iter(): if child.tag in [self.qn('text:p'), self.qn('text:h')]: buff += self.text_to_string(child) + "\n" # remove last newline char if buff: ...
python
def to_string(self): """ Converts the document to a string. """ buff = u"" for child in self.content.iter(): if child.tag in [self.qn('text:p'), self.qn('text:h')]: buff += self.text_to_string(child) + "\n" # remove last newline char if buff: ...
[ "def", "to_string", "(", "self", ")", ":", "buff", "=", "u\"\"", "for", "child", "in", "self", ".", "content", ".", "iter", "(", ")", ":", "if", "child", ".", "tag", "in", "[", "self", ".", "qn", "(", "'text:p'", ")", ",", "self", ".", "qn", "(...
Converts the document to a string.
[ "Converts", "the", "document", "to", "a", "string", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/odt_parser.py#L19-L28
train
deanmalmgren/textract
textract/parsers/odt_parser.py
Parser.qn
def qn(self, namespace): """Connect tag prefix to longer namespace""" nsmap = { 'text': 'urn:oasis:names:tc:opendocument:xmlns:text:1.0', } spl = namespace.split(':') return '{{{}}}{}'.format(nsmap[spl[0]], spl[1])
python
def qn(self, namespace): """Connect tag prefix to longer namespace""" nsmap = { 'text': 'urn:oasis:names:tc:opendocument:xmlns:text:1.0', } spl = namespace.split(':') return '{{{}}}{}'.format(nsmap[spl[0]], spl[1])
[ "def", "qn", "(", "self", ",", "namespace", ")", ":", "nsmap", "=", "{", "'text'", ":", "'urn:oasis:names:tc:opendocument:xmlns:text:1.0'", ",", "}", "spl", "=", "namespace", ".", "split", "(", "':'", ")", "return", "'{{{}}}{}'", ".", "format", "(", "nsmap",...
Connect tag prefix to longer namespace
[ "Connect", "tag", "prefix", "to", "longer", "namespace" ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/odt_parser.py#L51-L57
train
deanmalmgren/textract
textract/cli.py
get_parser
def get_parser(): """Initialize the parser for the command line interface and bind the autocompletion functionality""" # initialize the parser parser = argparse.ArgumentParser( description=( 'Command line tool for extracting text from any document. ' ) % locals(), ) ...
python
def get_parser(): """Initialize the parser for the command line interface and bind the autocompletion functionality""" # initialize the parser parser = argparse.ArgumentParser( description=( 'Command line tool for extracting text from any document. ' ) % locals(), ) ...
[ "def", "get_parser", "(", ")", ":", "# initialize the parser", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "(", "'Command line tool for extracting text from any document. '", ")", "%", "locals", "(", ")", ",", ")", "# define the command li...
Initialize the parser for the command line interface and bind the autocompletion functionality
[ "Initialize", "the", "parser", "for", "the", "command", "line", "interface", "and", "bind", "the", "autocompletion", "functionality" ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/cli.py#L45-L93
train
deanmalmgren/textract
textract/cli.py
_get_available_encodings
def _get_available_encodings(): """Get a list of the available encodings to make it easy to tab-complete the command line interface. Inspiration from http://stackoverflow.com/a/3824405/564709 """ available_encodings = set(encodings.aliases.aliases.values()) paths = [os.path.dirname(encodings.__...
python
def _get_available_encodings(): """Get a list of the available encodings to make it easy to tab-complete the command line interface. Inspiration from http://stackoverflow.com/a/3824405/564709 """ available_encodings = set(encodings.aliases.aliases.values()) paths = [os.path.dirname(encodings.__...
[ "def", "_get_available_encodings", "(", ")", ":", "available_encodings", "=", "set", "(", "encodings", ".", "aliases", ".", "aliases", ".", "values", "(", ")", ")", "paths", "=", "[", "os", ".", "path", ".", "dirname", "(", "encodings", ".", "__file__", ...
Get a list of the available encodings to make it easy to tab-complete the command line interface. Inspiration from http://stackoverflow.com/a/3824405/564709
[ "Get", "a", "list", "of", "the", "available", "encodings", "to", "make", "it", "easy", "to", "tab", "-", "complete", "the", "command", "line", "interface", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/cli.py#L96-L108
train
deanmalmgren/textract
textract/parsers/pdf_parser.py
Parser.extract_pdftotext
def extract_pdftotext(self, filename, **kwargs): """Extract text from pdfs using the pdftotext command line utility.""" if 'layout' in kwargs: args = ['pdftotext', '-layout', filename, '-'] else: args = ['pdftotext', filename, '-'] stdout, _ = self.run(args) ...
python
def extract_pdftotext(self, filename, **kwargs): """Extract text from pdfs using the pdftotext command line utility.""" if 'layout' in kwargs: args = ['pdftotext', '-layout', filename, '-'] else: args = ['pdftotext', filename, '-'] stdout, _ = self.run(args) ...
[ "def", "extract_pdftotext", "(", "self", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "if", "'layout'", "in", "kwargs", ":", "args", "=", "[", "'pdftotext'", ",", "'-layout'", ",", "filename", ",", "'-'", "]", "else", ":", "args", "=", "[", "'...
Extract text from pdfs using the pdftotext command line utility.
[ "Extract", "text", "from", "pdfs", "using", "the", "pdftotext", "command", "line", "utility", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/pdf_parser.py#L37-L44
train
deanmalmgren/textract
textract/parsers/pdf_parser.py
Parser.extract_pdfminer
def extract_pdfminer(self, filename, **kwargs): """Extract text from pdfs using pdfminer.""" stdout, _ = self.run(['pdf2txt.py', filename]) return stdout
python
def extract_pdfminer(self, filename, **kwargs): """Extract text from pdfs using pdfminer.""" stdout, _ = self.run(['pdf2txt.py', filename]) return stdout
[ "def", "extract_pdfminer", "(", "self", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "stdout", ",", "_", "=", "self", ".", "run", "(", "[", "'pdf2txt.py'", ",", "filename", "]", ")", "return", "stdout" ]
Extract text from pdfs using pdfminer.
[ "Extract", "text", "from", "pdfs", "using", "pdfminer", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/pdf_parser.py#L46-L49
train
deanmalmgren/textract
textract/parsers/audio.py
Parser.convert_to_wav
def convert_to_wav(self, filename): """ Uses sox cmdline tool, to convert audio file to .wav Note: for testing, use - http://www.text2speech.org/, with American Male 2 for best results """ temp_filename = '{0}.wav'.format(self.temp_filename()) self.run(['...
python
def convert_to_wav(self, filename): """ Uses sox cmdline tool, to convert audio file to .wav Note: for testing, use - http://www.text2speech.org/, with American Male 2 for best results """ temp_filename = '{0}.wav'.format(self.temp_filename()) self.run(['...
[ "def", "convert_to_wav", "(", "self", ",", "filename", ")", ":", "temp_filename", "=", "'{0}.wav'", ".", "format", "(", "self", ".", "temp_filename", "(", ")", ")", "self", ".", "run", "(", "[", "'sox'", ",", "'-G'", ",", "'-c'", ",", "'1'", ",", "fi...
Uses sox cmdline tool, to convert audio file to .wav Note: for testing, use - http://www.text2speech.org/, with American Male 2 for best results
[ "Uses", "sox", "cmdline", "tool", "to", "convert", "audio", "file", "to", ".", "wav" ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/audio.py#L56-L66
train
deanmalmgren/textract
textract/parsers/html_parser.py
Parser._visible
def _visible(self, element): """Used to filter text elements that have invisible text on the page. """ if element.name in self._disallowed_names: return False elif re.match(u'<!--.*-->', six.text_type(element.extract())): return False return True
python
def _visible(self, element): """Used to filter text elements that have invisible text on the page. """ if element.name in self._disallowed_names: return False elif re.match(u'<!--.*-->', six.text_type(element.extract())): return False return True
[ "def", "_visible", "(", "self", ",", "element", ")", ":", "if", "element", ".", "name", "in", "self", ".", "_disallowed_names", ":", "return", "False", "elif", "re", ".", "match", "(", "u'<!--.*-->'", ",", "six", ".", "text_type", "(", "element", ".", ...
Used to filter text elements that have invisible text on the page.
[ "Used", "to", "filter", "text", "elements", "that", "have", "invisible", "text", "on", "the", "page", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/html_parser.py#L27-L34
train
deanmalmgren/textract
textract/parsers/html_parser.py
Parser._find_any_text
def _find_any_text(self, tag): """Looks for any possible text within given tag. """ text = '' if tag is not None: text = six.text_type(tag) text = re.sub(r'(<[^>]+>)', '', text) text = re.sub(r'\s', ' ', text) text = text.strip() re...
python
def _find_any_text(self, tag): """Looks for any possible text within given tag. """ text = '' if tag is not None: text = six.text_type(tag) text = re.sub(r'(<[^>]+>)', '', text) text = re.sub(r'\s', ' ', text) text = text.strip() re...
[ "def", "_find_any_text", "(", "self", ",", "tag", ")", ":", "text", "=", "''", "if", "tag", "is", "not", "None", ":", "text", "=", "six", ".", "text_type", "(", "tag", ")", "text", "=", "re", ".", "sub", "(", "r'(<[^>]+>)'", ",", "''", ",", "text...
Looks for any possible text within given tag.
[ "Looks", "for", "any", "possible", "text", "within", "given", "tag", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/html_parser.py#L44-L53
train
deanmalmgren/textract
textract/parsers/html_parser.py
Parser._join_inlines
def _join_inlines(self, soup): """Unwraps inline elements defined in self._inline_tags. """ elements = soup.find_all(True) for elem in elements: if self._inline(elem): elem.unwrap() return soup
python
def _join_inlines(self, soup): """Unwraps inline elements defined in self._inline_tags. """ elements = soup.find_all(True) for elem in elements: if self._inline(elem): elem.unwrap() return soup
[ "def", "_join_inlines", "(", "self", ",", "soup", ")", ":", "elements", "=", "soup", ".", "find_all", "(", "True", ")", "for", "elem", "in", "elements", ":", "if", "self", ".", "_inline", "(", "elem", ")", ":", "elem", ".", "unwrap", "(", ")", "ret...
Unwraps inline elements defined in self._inline_tags.
[ "Unwraps", "inline", "elements", "defined", "in", "self", ".", "_inline_tags", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/html_parser.py#L118-L125
train
deanmalmgren/textract
textract/parsers/utils.py
ShellParser.temp_filename
def temp_filename(self): """Return a unique tempfile name. """ # TODO: it would be nice to get this to behave more like a # context so we can make sure these temporary files are # removed, regardless of whether an error occurs or the # program is terminated. handl...
python
def temp_filename(self): """Return a unique tempfile name. """ # TODO: it would be nice to get this to behave more like a # context so we can make sure these temporary files are # removed, regardless of whether an error occurs or the # program is terminated. handl...
[ "def", "temp_filename", "(", "self", ")", ":", "# TODO: it would be nice to get this to behave more like a", "# context so we can make sure these temporary files are", "# removed, regardless of whether an error occurs or the", "# program is terminated.", "handle", ",", "filename", "=", "...
Return a unique tempfile name.
[ "Return", "a", "unique", "tempfile", "name", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/utils.py#L106-L115
train
deanmalmgren/textract
textract/parsers/__init__.py
process
def process(filename, encoding=DEFAULT_ENCODING, extension=None, **kwargs): """This is the core function used for extracting text. It routes the ``filename`` to the appropriate parser and returns the extracted text as a byte-string encoded with ``encoding``. """ # make sure the filename exists ...
python
def process(filename, encoding=DEFAULT_ENCODING, extension=None, **kwargs): """This is the core function used for extracting text. It routes the ``filename`` to the appropriate parser and returns the extracted text as a byte-string encoded with ``encoding``. """ # make sure the filename exists ...
[ "def", "process", "(", "filename", ",", "encoding", "=", "DEFAULT_ENCODING", ",", "extension", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# make sure the filename exists", "if", "not", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "rai...
This is the core function used for extracting text. It routes the ``filename`` to the appropriate parser and returns the extracted text as a byte-string encoded with ``encoding``.
[ "This", "is", "the", "core", "function", "used", "for", "extracting", "text", ".", "It", "routes", "the", "filename", "to", "the", "appropriate", "parser", "and", "returns", "the", "extracted", "text", "as", "a", "byte", "-", "string", "encoded", "with", "...
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/__init__.py#L31-L77
train
deanmalmgren/textract
textract/parsers/__init__.py
_get_available_extensions
def _get_available_extensions(): """Get a list of available file extensions to make it easy for tab-completion and exception handling. """ extensions = [] # from filenames parsers_dir = os.path.join(os.path.dirname(__file__)) glob_filename = os.path.join(parsers_dir, "*" + _FILENAME_SUFFIX ...
python
def _get_available_extensions(): """Get a list of available file extensions to make it easy for tab-completion and exception handling. """ extensions = [] # from filenames parsers_dir = os.path.join(os.path.dirname(__file__)) glob_filename = os.path.join(parsers_dir, "*" + _FILENAME_SUFFIX ...
[ "def", "_get_available_extensions", "(", ")", ":", "extensions", "=", "[", "]", "# from filenames", "parsers_dir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "glob_filename", "=", "os", ".", "p...
Get a list of available file extensions to make it easy for tab-completion and exception handling.
[ "Get", "a", "list", "of", "available", "file", "extensions", "to", "make", "it", "easy", "for", "tab", "-", "completion", "and", "exception", "handling", "." ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/textract/parsers/__init__.py#L80-L102
train
deanmalmgren/textract
setup.py
parse_requirements
def parse_requirements(requirements_filename): """read in the dependencies from the requirements files """ dependencies, dependency_links = [], [] requirements_dir = os.path.dirname(requirements_filename) with open(requirements_filename, 'r') as stream: for line in stream: line =...
python
def parse_requirements(requirements_filename): """read in the dependencies from the requirements files """ dependencies, dependency_links = [], [] requirements_dir = os.path.dirname(requirements_filename) with open(requirements_filename, 'r') as stream: for line in stream: line =...
[ "def", "parse_requirements", "(", "requirements_filename", ")", ":", "dependencies", ",", "dependency_links", "=", "[", "]", ",", "[", "]", "requirements_dir", "=", "os", ".", "path", ".", "dirname", "(", "requirements_filename", ")", "with", "open", "(", "req...
read in the dependencies from the requirements files
[ "read", "in", "the", "dependencies", "from", "the", "requirements", "files" ]
117ea191d93d80321e4bf01f23cc1ac54d69a075
https://github.com/deanmalmgren/textract/blob/117ea191d93d80321e4bf01f23cc1ac54d69a075/setup.py#L18-L37
train
lyst/lightfm
lightfm/data.py
Dataset.build_interactions
def build_interactions(self, data): """ Build an interaction matrix. Two matrices will be returned: a (num_users, num_items) COO matrix with interactions, and a (num_users, num_items) matrix with the corresponding interaction weights. Parameters ---------- ...
python
def build_interactions(self, data): """ Build an interaction matrix. Two matrices will be returned: a (num_users, num_items) COO matrix with interactions, and a (num_users, num_items) matrix with the corresponding interaction weights. Parameters ---------- ...
[ "def", "build_interactions", "(", "self", ",", "data", ")", ":", "interactions", "=", "_IncrementalCOOMatrix", "(", "self", ".", "interactions_shape", "(", ")", ",", "np", ".", "int32", ")", "weights", "=", "_IncrementalCOOMatrix", "(", "self", ".", "interacti...
Build an interaction matrix. Two matrices will be returned: a (num_users, num_items) COO matrix with interactions, and a (num_users, num_items) matrix with the corresponding interaction weights. Parameters ---------- data: iterable of (user_id, item_id) or (user_id, it...
[ "Build", "an", "interaction", "matrix", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/data.py#L292-L326
train
lyst/lightfm
lightfm/data.py
Dataset.mapping
def mapping(self): """ Return the constructed mappings. Invert these to map internal indices to external ids. Returns ------- (user id map, user feature map, item id map, item id map): tuple of dictionaries """ return ( self._user_id_mappin...
python
def mapping(self): """ Return the constructed mappings. Invert these to map internal indices to external ids. Returns ------- (user id map, user feature map, item id map, item id map): tuple of dictionaries """ return ( self._user_id_mappin...
[ "def", "mapping", "(", "self", ")", ":", "return", "(", "self", ".", "_user_id_mapping", ",", "self", ".", "_user_feature_mapping", ",", "self", ".", "_item_id_mapping", ",", "self", ".", "_item_feature_mapping", ",", ")" ]
Return the constructed mappings. Invert these to map internal indices to external ids. Returns ------- (user id map, user feature map, item id map, item id map): tuple of dictionaries
[ "Return", "the", "constructed", "mappings", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/data.py#L428-L445
train
lyst/lightfm
examples/movielens/data.py
_get_movielens_path
def _get_movielens_path(): """ Get path to the movielens dataset file. """ return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'movielens.zip')
python
def _get_movielens_path(): """ Get path to the movielens dataset file. """ return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'movielens.zip')
[ "def", "_get_movielens_path", "(", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "'movielens.zip'", ")" ]
Get path to the movielens dataset file.
[ "Get", "path", "to", "the", "movielens", "dataset", "file", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/examples/movielens/data.py#L12-L18
train
lyst/lightfm
examples/movielens/data.py
_download_movielens
def _download_movielens(dest_path): """ Download the dataset. """ url = 'http://files.grouplens.org/datasets/movielens/ml-100k.zip' req = requests.get(url, stream=True) with open(dest_path, 'wb') as fd: for chunk in req.iter_content(): fd.write(chunk)
python
def _download_movielens(dest_path): """ Download the dataset. """ url = 'http://files.grouplens.org/datasets/movielens/ml-100k.zip' req = requests.get(url, stream=True) with open(dest_path, 'wb') as fd: for chunk in req.iter_content(): fd.write(chunk)
[ "def", "_download_movielens", "(", "dest_path", ")", ":", "url", "=", "'http://files.grouplens.org/datasets/movielens/ml-100k.zip'", "req", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ")", "with", "open", "(", "dest_path", ",", "'wb'", "...
Download the dataset.
[ "Download", "the", "dataset", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/examples/movielens/data.py#L21-L31
train
lyst/lightfm
examples/movielens/data.py
_get_movie_raw_metadata
def _get_movie_raw_metadata(): """ Get raw lines of the genre file. """ path = _get_movielens_path() if not os.path.isfile(path): _download_movielens(path) with zipfile.ZipFile(path) as datafile: return datafile.read('ml-100k/u.item').decode(errors='ignore').split('\n')
python
def _get_movie_raw_metadata(): """ Get raw lines of the genre file. """ path = _get_movielens_path() if not os.path.isfile(path): _download_movielens(path) with zipfile.ZipFile(path) as datafile: return datafile.read('ml-100k/u.item').decode(errors='ignore').split('\n')
[ "def", "_get_movie_raw_metadata", "(", ")", ":", "path", "=", "_get_movielens_path", "(", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "_download_movielens", "(", "path", ")", "with", "zipfile", ".", "ZipFile", "(", "path", ...
Get raw lines of the genre file.
[ "Get", "raw", "lines", "of", "the", "genre", "file", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/examples/movielens/data.py#L82-L93
train
lyst/lightfm
lightfm/lightfm.py
LightFM._initialize
def _initialize(self, no_components, no_item_features, no_user_features): """ Initialise internal latent representations. """ # Initialise item features. self.item_embeddings = ( (self.random_state.rand(no_item_features, no_components) - 0.5) / no_compone...
python
def _initialize(self, no_components, no_item_features, no_user_features): """ Initialise internal latent representations. """ # Initialise item features. self.item_embeddings = ( (self.random_state.rand(no_item_features, no_components) - 0.5) / no_compone...
[ "def", "_initialize", "(", "self", ",", "no_components", ",", "no_item_features", ",", "no_user_features", ")", ":", "# Initialise item features.", "self", ".", "item_embeddings", "=", "(", "(", "self", ".", "random_state", ".", "rand", "(", "no_item_features", ",...
Initialise internal latent representations.
[ "Initialise", "internal", "latent", "representations", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/lightfm.py#L264-L295
train
lyst/lightfm
lightfm/lightfm.py
LightFM._run_epoch
def _run_epoch( self, item_features, user_features, interactions, sample_weight, num_threads, loss, ): """ Run an individual epoch. """ if loss in ("warp", "bpr", "warp-kos"): # The CSR conversion needs to happen be...
python
def _run_epoch( self, item_features, user_features, interactions, sample_weight, num_threads, loss, ): """ Run an individual epoch. """ if loss in ("warp", "bpr", "warp-kos"): # The CSR conversion needs to happen be...
[ "def", "_run_epoch", "(", "self", ",", "item_features", ",", "user_features", ",", "interactions", ",", "sample_weight", ",", "num_threads", ",", "loss", ",", ")", ":", "if", "loss", "in", "(", "\"warp\"", ",", "\"bpr\"", ",", "\"warp-kos\"", ")", ":", "# ...
Run an individual epoch.
[ "Run", "an", "individual", "epoch", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/lightfm.py#L651-L742
train
lyst/lightfm
lightfm/lightfm.py
LightFM.predict
def predict( self, user_ids, item_ids, item_features=None, user_features=None, num_threads=1 ): """ Compute the recommendation score for user-item pairs. For details on how to use feature matrices, see the documentation on the :class:`lightfm.LightFM` class. Argumen...
python
def predict( self, user_ids, item_ids, item_features=None, user_features=None, num_threads=1 ): """ Compute the recommendation score for user-item pairs. For details on how to use feature matrices, see the documentation on the :class:`lightfm.LightFM` class. Argumen...
[ "def", "predict", "(", "self", ",", "user_ids", ",", "item_ids", ",", "item_features", "=", "None", ",", "user_features", "=", "None", ",", "num_threads", "=", "1", ")", ":", "self", ".", "_check_initialized", "(", ")", "if", "not", "isinstance", "(", "u...
Compute the recommendation score for user-item pairs. For details on how to use feature matrices, see the documentation on the :class:`lightfm.LightFM` class. Arguments --------- user_ids: integer or np.int32 array of shape [n_pairs,] single user id or an array co...
[ "Compute", "the", "recommendation", "score", "for", "user", "-", "item", "pairs", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/lightfm.py#L744-L828
train
lyst/lightfm
lightfm/lightfm.py
LightFM.get_item_representations
def get_item_representations(self, features=None): """ Get the latent representations for items given model and features. Arguments --------- features: np.float32 csr_matrix of shape [n_items, n_item_features], optional Each row contains that item's weights over fe...
python
def get_item_representations(self, features=None): """ Get the latent representations for items given model and features. Arguments --------- features: np.float32 csr_matrix of shape [n_items, n_item_features], optional Each row contains that item's weights over fe...
[ "def", "get_item_representations", "(", "self", ",", "features", "=", "None", ")", ":", "self", ".", "_check_initialized", "(", ")", "if", "features", "is", "None", ":", "return", "self", ".", "item_biases", ",", "self", ".", "item_embeddings", "features", "...
Get the latent representations for items given model and features. Arguments --------- features: np.float32 csr_matrix of shape [n_items, n_item_features], optional Each row contains that item's weights over features. An identity matrix will be used if not supplied. ...
[ "Get", "the", "latent", "representations", "for", "items", "given", "model", "and", "features", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/lightfm.py#L947-L974
train
lyst/lightfm
lightfm/lightfm.py
LightFM.get_user_representations
def get_user_representations(self, features=None): """ Get the latent representations for users given model and features. Arguments --------- features: np.float32 csr_matrix of shape [n_users, n_user_features], optional Each row contains that user's weights over fe...
python
def get_user_representations(self, features=None): """ Get the latent representations for users given model and features. Arguments --------- features: np.float32 csr_matrix of shape [n_users, n_user_features], optional Each row contains that user's weights over fe...
[ "def", "get_user_representations", "(", "self", ",", "features", "=", "None", ")", ":", "self", ".", "_check_initialized", "(", ")", "if", "features", "is", "None", ":", "return", "self", ".", "user_biases", ",", "self", ".", "user_embeddings", "features", "...
Get the latent representations for users given model and features. Arguments --------- features: np.float32 csr_matrix of shape [n_users, n_user_features], optional Each row contains that user's weights over features. An identity matrix will be used if not supplied. ...
[ "Get", "the", "latent", "representations", "for", "users", "given", "model", "and", "features", "." ]
87b942f87759b8336f9066a25e4762ae7d95455e
https://github.com/lyst/lightfm/blob/87b942f87759b8336f9066a25e4762ae7d95455e/lightfm/lightfm.py#L976-L1003
train
quantopian/empyrical
empyrical/stats.py
_adjust_returns
def _adjust_returns(returns, adjustment_factor): """ Returns the returns series adjusted by adjustment_factor. Optimizes for the case of adjustment_factor being 0 by returning returns itself, not a copy! Parameters ---------- returns : pd.Series or np.ndarray adjustment_factor : pd.Series o...
python
def _adjust_returns(returns, adjustment_factor): """ Returns the returns series adjusted by adjustment_factor. Optimizes for the case of adjustment_factor being 0 by returning returns itself, not a copy! Parameters ---------- returns : pd.Series or np.ndarray adjustment_factor : pd.Series o...
[ "def", "_adjust_returns", "(", "returns", ",", "adjustment_factor", ")", ":", "if", "isinstance", "(", "adjustment_factor", ",", "(", "float", ",", "int", ")", ")", "and", "adjustment_factor", "==", "0", ":", "return", "returns", "return", "returns", "-", "a...
Returns the returns series adjusted by adjustment_factor. Optimizes for the case of adjustment_factor being 0 by returning returns itself, not a copy! Parameters ---------- returns : pd.Series or np.ndarray adjustment_factor : pd.Series or np.ndarray or float or int Returns ------- adj...
[ "Returns", "the", "returns", "series", "adjusted", "by", "adjustment_factor", ".", "Optimizes", "for", "the", "case", "of", "adjustment_factor", "being", "0", "by", "returning", "returns", "itself", "not", "a", "copy!" ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L127-L143
train
quantopian/empyrical
empyrical/stats.py
annualization_factor
def annualization_factor(period, annualization): """ Return annualization factor from period entered or if a custom value is passed in. Parameters ---------- period : str, optional Defines the periodicity of the 'returns' data for purposes of annualizing. Value ignored if `annua...
python
def annualization_factor(period, annualization): """ Return annualization factor from period entered or if a custom value is passed in. Parameters ---------- period : str, optional Defines the periodicity of the 'returns' data for purposes of annualizing. Value ignored if `annua...
[ "def", "annualization_factor", "(", "period", ",", "annualization", ")", ":", "if", "annualization", "is", "None", ":", "try", ":", "factor", "=", "ANNUALIZATION_FACTORS", "[", "period", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "\"Period canno...
Return annualization factor from period entered or if a custom value is passed in. Parameters ---------- period : str, optional Defines the periodicity of the 'returns' data for purposes of annualizing. Value ignored if `annualization` parameter is specified. Defaults are:: ...
[ "Return", "annualization", "factor", "from", "period", "entered", "or", "if", "a", "custom", "value", "is", "passed", "in", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L146-L183
train
quantopian/empyrical
empyrical/stats.py
simple_returns
def simple_returns(prices): """ Compute simple returns from a timeseries of prices. Parameters ---------- prices : pd.Series, pd.DataFrame or np.ndarray Prices of assets in wide-format, with assets as columns, and indexed by datetimes. Returns ------- returns : array-li...
python
def simple_returns(prices): """ Compute simple returns from a timeseries of prices. Parameters ---------- prices : pd.Series, pd.DataFrame or np.ndarray Prices of assets in wide-format, with assets as columns, and indexed by datetimes. Returns ------- returns : array-li...
[ "def", "simple_returns", "(", "prices", ")", ":", "if", "isinstance", "(", "prices", ",", "(", "pd", ".", "DataFrame", ",", "pd", ".", "Series", ")", ")", ":", "out", "=", "prices", ".", "pct_change", "(", ")", ".", "iloc", "[", "1", ":", "]", "e...
Compute simple returns from a timeseries of prices. Parameters ---------- prices : pd.Series, pd.DataFrame or np.ndarray Prices of assets in wide-format, with assets as columns, and indexed by datetimes. Returns ------- returns : array-like Returns of assets in wide-for...
[ "Compute", "simple", "returns", "from", "a", "timeseries", "of", "prices", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L186-L209
train
quantopian/empyrical
empyrical/stats.py
cum_returns
def cum_returns(returns, starting_value=0, out=None): """ Compute cumulative returns from simple returns. Parameters ---------- returns : pd.Series, np.ndarray, or pd.DataFrame Returns of the strategy as a percentage, noncumulative. - Time series with decimal returns. - Ex...
python
def cum_returns(returns, starting_value=0, out=None): """ Compute cumulative returns from simple returns. Parameters ---------- returns : pd.Series, np.ndarray, or pd.DataFrame Returns of the strategy as a percentage, noncumulative. - Time series with decimal returns. - Ex...
[ "def", "cum_returns", "(", "returns", ",", "starting_value", "=", "0", ",", "out", "=", "None", ")", ":", "if", "len", "(", "returns", ")", "<", "1", ":", "return", "returns", ".", "copy", "(", ")", "nanmask", "=", "np", ".", "isnan", "(", "returns...
Compute cumulative returns from simple returns. Parameters ---------- returns : pd.Series, np.ndarray, or pd.DataFrame Returns of the strategy as a percentage, noncumulative. - Time series with decimal returns. - Example:: 2015-07-16 -0.012143 2015-07-17...
[ "Compute", "cumulative", "returns", "from", "simple", "returns", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L212-L270
train
quantopian/empyrical
empyrical/stats.py
cum_returns_final
def cum_returns_final(returns, starting_value=0): """ Compute total returns from simple returns. Parameters ---------- returns : pd.DataFrame, pd.Series, or np.ndarray Noncumulative simple returns of one or more timeseries. starting_value : float, optional The starting returns. ...
python
def cum_returns_final(returns, starting_value=0): """ Compute total returns from simple returns. Parameters ---------- returns : pd.DataFrame, pd.Series, or np.ndarray Noncumulative simple returns of one or more timeseries. starting_value : float, optional The starting returns. ...
[ "def", "cum_returns_final", "(", "returns", ",", "starting_value", "=", "0", ")", ":", "if", "len", "(", "returns", ")", "==", "0", ":", "return", "np", ".", "nan", "if", "isinstance", "(", "returns", ",", "pd", ".", "DataFrame", ")", ":", "result", ...
Compute total returns from simple returns. Parameters ---------- returns : pd.DataFrame, pd.Series, or np.ndarray Noncumulative simple returns of one or more timeseries. starting_value : float, optional The starting returns. Returns ------- total_returns : pd.Series, np.ndarr...
[ "Compute", "total", "returns", "from", "simple", "returns", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L273-L306
train
quantopian/empyrical
empyrical/stats.py
aggregate_returns
def aggregate_returns(returns, convert_to): """ Aggregates returns by week, month, or year. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. convert_to : str Can be 'wee...
python
def aggregate_returns(returns, convert_to): """ Aggregates returns by week, month, or year. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. convert_to : str Can be 'wee...
[ "def", "aggregate_returns", "(", "returns", ",", "convert_to", ")", ":", "def", "cumulate_returns", "(", "x", ")", ":", "return", "cum_returns", "(", "x", ")", ".", "iloc", "[", "-", "1", "]", "if", "convert_to", "==", "WEEKLY", ":", "grouping", "=", "...
Aggregates returns by week, month, or year. Parameters ---------- returns : pd.Series Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. convert_to : str Can be 'weekly', 'monthly', or 'yearly'. Returns ------- ...
[ "Aggregates", "returns", "by", "week", "month", "or", "year", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L309-L340
train
quantopian/empyrical
empyrical/stats.py
max_drawdown
def max_drawdown(returns, out=None): """ Determines the maximum drawdown of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. out : array-like, optiona...
python
def max_drawdown(returns, out=None): """ Determines the maximum drawdown of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. out : array-like, optiona...
[ "def", "max_drawdown", "(", "returns", ",", "out", "=", "None", ")", ":", "allocated_output", "=", "out", "is", "None", "if", "allocated_output", ":", "out", "=", "np", ".", "empty", "(", "returns", ".", "shape", "[", "1", ":", "]", ")", "returns_1d", ...
Determines the maximum drawdown of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. out : array-like, optional Array to use as output buffer. ...
[ "Determines", "the", "maximum", "drawdown", "of", "a", "strategy", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L343-L393
train
quantopian/empyrical
empyrical/stats.py
annual_return
def annual_return(returns, period=DAILY, annualization=None): """ Determines the mean annual growth rate of returns. This is equivilent to the compound annual growth rate. Parameters ---------- returns : pd.Series or np.ndarray Periodic returns of the strategy, noncumulative. - ...
python
def annual_return(returns, period=DAILY, annualization=None): """ Determines the mean annual growth rate of returns. This is equivilent to the compound annual growth rate. Parameters ---------- returns : pd.Series or np.ndarray Periodic returns of the strategy, noncumulative. - ...
[ "def", "annual_return", "(", "returns", ",", "period", "=", "DAILY", ",", "annualization", "=", "None", ")", ":", "if", "len", "(", "returns", ")", "<", "1", ":", "return", "np", ".", "nan", "ann_factor", "=", "annualization_factor", "(", "period", ",", ...
Determines the mean annual growth rate of returns. This is equivilent to the compound annual growth rate. Parameters ---------- returns : pd.Series or np.ndarray Periodic returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. period :...
[ "Determines", "the", "mean", "annual", "growth", "rate", "of", "returns", ".", "This", "is", "equivilent", "to", "the", "compound", "annual", "growth", "rate", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L399-L438
train
quantopian/empyrical
empyrical/stats.py
annual_volatility
def annual_volatility(returns, period=DAILY, alpha=2.0, annualization=None, out=None): """ Determines the annual volatility of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Periodic...
python
def annual_volatility(returns, period=DAILY, alpha=2.0, annualization=None, out=None): """ Determines the annual volatility of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Periodic...
[ "def", "annual_volatility", "(", "returns", ",", "period", "=", "DAILY", ",", "alpha", "=", "2.0", ",", "annualization", "=", "None", ",", "out", "=", "None", ")", ":", "allocated_output", "=", "out", "is", "None", "if", "allocated_output", ":", "out", "...
Determines the annual volatility of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Periodic returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. period : str, optional Defines the periodicity of the 'returns...
[ "Determines", "the", "annual", "volatility", "of", "a", "strategy", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L478-L531
train
quantopian/empyrical
empyrical/stats.py
calmar_ratio
def calmar_ratio(returns, period=DAILY, annualization=None): """ Determines the Calmar ratio, or drawdown ratio, of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum...
python
def calmar_ratio(returns, period=DAILY, annualization=None): """ Determines the Calmar ratio, or drawdown ratio, of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum...
[ "def", "calmar_ratio", "(", "returns", ",", "period", "=", "DAILY", ",", "annualization", "=", "None", ")", ":", "max_dd", "=", "max_drawdown", "(", "returns", "=", "returns", ")", "if", "max_dd", "<", "0", ":", "temp", "=", "annual_return", "(", "return...
Determines the Calmar ratio, or drawdown ratio, of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. period : str, optional Defines the periodicity of ...
[ "Determines", "the", "Calmar", "ratio", "or", "drawdown", "ratio", "of", "a", "strategy", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L539-L587
train
quantopian/empyrical
empyrical/stats.py
omega_ratio
def omega_ratio(returns, risk_free=0.0, required_return=0.0, annualization=APPROX_BDAYS_PER_YEAR): """Determines the Omega ratio of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in...
python
def omega_ratio(returns, risk_free=0.0, required_return=0.0, annualization=APPROX_BDAYS_PER_YEAR): """Determines the Omega ratio of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in...
[ "def", "omega_ratio", "(", "returns", ",", "risk_free", "=", "0.0", ",", "required_return", "=", "0.0", ",", "annualization", "=", "APPROX_BDAYS_PER_YEAR", ")", ":", "if", "len", "(", "returns", ")", "<", "2", ":", "return", "np", ".", "nan", "if", "annu...
Determines the Omega ratio of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. risk_free : int, float Constant risk-free return throughout the period ...
[ "Determines", "the", "Omega", "ratio", "of", "a", "strategy", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L590-L640
train
quantopian/empyrical
empyrical/stats.py
sharpe_ratio
def sharpe_ratio(returns, risk_free=0, period=DAILY, annualization=None, out=None): """ Determines the Sharpe ratio of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncu...
python
def sharpe_ratio(returns, risk_free=0, period=DAILY, annualization=None, out=None): """ Determines the Sharpe ratio of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncu...
[ "def", "sharpe_ratio", "(", "returns", ",", "risk_free", "=", "0", ",", "period", "=", "DAILY", ",", "annualization", "=", "None", ",", "out", "=", "None", ")", ":", "allocated_output", "=", "out", "is", "None", "if", "allocated_output", ":", "out", "=",...
Determines the Sharpe ratio of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. risk_free : int, float Constant risk-free return throughout the period...
[ "Determines", "the", "Sharpe", "ratio", "of", "a", "strategy", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L643-L712
train
quantopian/empyrical
empyrical/stats.py
sortino_ratio
def sortino_ratio(returns, required_return=0, period=DAILY, annualization=None, out=None, _downside_risk=None): """ Determines the Sortino ratio of a strategy. Parameters ---------- returns : pd.Series or np.n...
python
def sortino_ratio(returns, required_return=0, period=DAILY, annualization=None, out=None, _downside_risk=None): """ Determines the Sortino ratio of a strategy. Parameters ---------- returns : pd.Series or np.n...
[ "def", "sortino_ratio", "(", "returns", ",", "required_return", "=", "0", ",", "period", "=", "DAILY", ",", "annualization", "=", "None", ",", "out", "=", "None", ",", "_downside_risk", "=", "None", ")", ":", "allocated_output", "=", "out", "is", "None", ...
Determines the Sortino ratio of a strategy. Parameters ---------- returns : pd.Series or np.ndarray or pd.DataFrame Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. required_return: float / series minimum acceptable re...
[ "Determines", "the", "Sortino", "ratio", "of", "a", "strategy", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L718-L796
train
quantopian/empyrical
empyrical/stats.py
downside_risk
def downside_risk(returns, required_return=0, period=DAILY, annualization=None, out=None): """ Determines the downside deviation below a threshold Parameters ---------- returns : pd.Series or np.ndarray or pd.DataFrame ...
python
def downside_risk(returns, required_return=0, period=DAILY, annualization=None, out=None): """ Determines the downside deviation below a threshold Parameters ---------- returns : pd.Series or np.ndarray or pd.DataFrame ...
[ "def", "downside_risk", "(", "returns", ",", "required_return", "=", "0", ",", "period", "=", "DAILY", ",", "annualization", "=", "None", ",", "out", "=", "None", ")", ":", "allocated_output", "=", "out", "is", "None", "if", "allocated_output", ":", "out",...
Determines the downside deviation below a threshold Parameters ---------- returns : pd.Series or np.ndarray or pd.DataFrame Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. required_return: float / series minimum accep...
[ "Determines", "the", "downside", "deviation", "below", "a", "threshold" ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L802-L879
train
quantopian/empyrical
empyrical/stats.py
excess_sharpe
def excess_sharpe(returns, factor_returns, out=None): """ Determines the Excess Sharpe of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. factor_retu...
python
def excess_sharpe(returns, factor_returns, out=None): """ Determines the Excess Sharpe of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. factor_retu...
[ "def", "excess_sharpe", "(", "returns", ",", "factor_returns", ",", "out", "=", "None", ")", ":", "allocated_output", "=", "out", "is", "None", "if", "allocated_output", ":", "out", "=", "np", ".", "empty", "(", "returns", ".", "shape", "[", "1", ":", ...
Determines the Excess Sharpe of a strategy. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. factor_returns: float / series Benchmark return to compare returns ag...
[ "Determines", "the", "Excess", "Sharpe", "of", "a", "strategy", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L885-L931
train
quantopian/empyrical
empyrical/stats.py
_to_pandas
def _to_pandas(ob): """Convert an array-like to a pandas object. Parameters ---------- ob : array-like The object to convert. Returns ------- pandas_structure : pd.Series or pd.DataFrame The correct structure based on the dimensionality of the data. """ if isinstanc...
python
def _to_pandas(ob): """Convert an array-like to a pandas object. Parameters ---------- ob : array-like The object to convert. Returns ------- pandas_structure : pd.Series or pd.DataFrame The correct structure based on the dimensionality of the data. """ if isinstanc...
[ "def", "_to_pandas", "(", "ob", ")", ":", "if", "isinstance", "(", "ob", ",", "(", "pd", ".", "Series", ",", "pd", ".", "DataFrame", ")", ")", ":", "return", "ob", "if", "ob", ".", "ndim", "==", "1", ":", "return", "pd", ".", "Series", "(", "ob...
Convert an array-like to a pandas object. Parameters ---------- ob : array-like The object to convert. Returns ------- pandas_structure : pd.Series or pd.DataFrame The correct structure based on the dimensionality of the data.
[ "Convert", "an", "array", "-", "like", "to", "a", "pandas", "object", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L937-L960
train
quantopian/empyrical
empyrical/stats.py
_aligned_series
def _aligned_series(*many_series): """ Return a new list of series containing the data in the input series, but with their indices aligned. NaNs will be filled in for missing values. Parameters ---------- *many_series The series to align. Returns ------- aligned_series : it...
python
def _aligned_series(*many_series): """ Return a new list of series containing the data in the input series, but with their indices aligned. NaNs will be filled in for missing values. Parameters ---------- *many_series The series to align. Returns ------- aligned_series : it...
[ "def", "_aligned_series", "(", "*", "many_series", ")", ":", "head", "=", "many_series", "[", "0", "]", "tail", "=", "many_series", "[", "1", ":", "]", "n", "=", "len", "(", "head", ")", "if", "(", "isinstance", "(", "head", ",", "np", ".", "ndarra...
Return a new list of series containing the data in the input series, but with their indices aligned. NaNs will be filled in for missing values. Parameters ---------- *many_series The series to align. Returns ------- aligned_series : iterable[array-like] A new list of series...
[ "Return", "a", "new", "list", "of", "series", "containing", "the", "data", "in", "the", "input", "series", "but", "with", "their", "indices", "aligned", ".", "NaNs", "will", "be", "filled", "in", "for", "missing", "values", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L963-L992
train
quantopian/empyrical
empyrical/stats.py
roll_alpha_beta
def roll_alpha_beta(returns, factor_returns, window=10, **kwargs): """ Computes alpha and beta over a rolling window. Parameters ---------- lhs : array-like The first array to pass to the rolling alpha-beta. rhs : array-like The second array to pass to the rolling alpha-beta. ...
python
def roll_alpha_beta(returns, factor_returns, window=10, **kwargs): """ Computes alpha and beta over a rolling window. Parameters ---------- lhs : array-like The first array to pass to the rolling alpha-beta. rhs : array-like The second array to pass to the rolling alpha-beta. ...
[ "def", "roll_alpha_beta", "(", "returns", ",", "factor_returns", ",", "window", "=", "10", ",", "*", "*", "kwargs", ")", ":", "returns", ",", "factor_returns", "=", "_aligned_series", "(", "returns", ",", "factor_returns", ")", "return", "roll_alpha_beta_aligned...
Computes alpha and beta over a rolling window. Parameters ---------- lhs : array-like The first array to pass to the rolling alpha-beta. rhs : array-like The second array to pass to the rolling alpha-beta. window : int Size of the rolling window in terms of the periodicity o...
[ "Computes", "alpha", "and", "beta", "over", "a", "rolling", "window", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L1049-L1074
train
quantopian/empyrical
empyrical/stats.py
stability_of_timeseries
def stability_of_timeseries(returns): """Determines R-squared of a linear fit to the cumulative log returns. Computes an ordinary least squares linear fit, and returns R-squared. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. ...
python
def stability_of_timeseries(returns): """Determines R-squared of a linear fit to the cumulative log returns. Computes an ordinary least squares linear fit, and returns R-squared. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. ...
[ "def", "stability_of_timeseries", "(", "returns", ")", ":", "if", "len", "(", "returns", ")", "<", "2", ":", "return", "np", ".", "nan", "returns", "=", "np", ".", "asanyarray", "(", "returns", ")", "returns", "=", "returns", "[", "~", "np", ".", "is...
Determines R-squared of a linear fit to the cumulative log returns. Computes an ordinary least squares linear fit, and returns R-squared. Parameters ---------- returns : pd.Series or np.ndarray Daily returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical...
[ "Determines", "R", "-", "squared", "of", "a", "linear", "fit", "to", "the", "cumulative", "log", "returns", ".", "Computes", "an", "ordinary", "least", "squares", "linear", "fit", "and", "returns", "R", "-", "squared", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L1454-L1481
train
quantopian/empyrical
empyrical/stats.py
capture
def capture(returns, factor_returns, period=DAILY): """ Compute capture ratio. Parameters ---------- returns : pd.Series or np.ndarray Returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. factor_returns : pd.Series or np.ndarray...
python
def capture(returns, factor_returns, period=DAILY): """ Compute capture ratio. Parameters ---------- returns : pd.Series or np.ndarray Returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. factor_returns : pd.Series or np.ndarray...
[ "def", "capture", "(", "returns", ",", "factor_returns", ",", "period", "=", "DAILY", ")", ":", "return", "(", "annual_return", "(", "returns", ",", "period", "=", "period", ")", "/", "annual_return", "(", "factor_returns", ",", "period", "=", "period", ")...
Compute capture ratio. Parameters ---------- returns : pd.Series or np.ndarray Returns of the strategy, noncumulative. - See full explanation in :func:`~empyrical.stats.cum_returns`. factor_returns : pd.Series or np.ndarray Noncumulative returns of the factor to which beta is ...
[ "Compute", "capture", "ratio", "." ]
badbdca75f5b293f28b5e947974894de041d6868
https://github.com/quantopian/empyrical/blob/badbdca75f5b293f28b5e947974894de041d6868/empyrical/stats.py#L1514-L1546
train