<commit_before># Copyright 2017-2018 IBM Corp. All Rights Reserved.
# See LICENSE for details.
#
# Author: <NAME>
#
# Manage workspaces for IBM Watson Assistant service on IBM Cloud.
# See the README for documentation.
#

import json, argparse, importlib
from os.path import join, dirname
from ibm_watson import AssistantV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

privcontext=None
assistant=None

def loadAndInit(confFile=None):
    # Credentials are read from a file
    with open(confFile) as confFile:
        config=json.load(confFile)
        configWA=config['credentials']
        if 'ICF_KEY' in config:
            global privcontext
            icf_key=config['ICF_KEY'].split(':')
            privcontext={"private": {"icfcreds": {"user": icf_key[0], "password": icf_key[1]}}}

    # Initialize the Watson Assistant client
    global assistant
    if 'apikey' in configWA:
        # Authentication via IAM
        authenticator = IAMAuthenticator(configWA['apikey'])
        assistant = AssistantV1(
            authenticator=authenticator,
            version=configWA['version'])
        assistant.set_service_url(configWA['url'])
    else:
        print('Apikey for Watson Assistant in credentials.')
        exit


# Define parameters that we want to catch and some basic command help
def initParser(args=None):
    parser = argparse.ArgumentParser(description='Manage Watson Assistant workspaces (skills)',
                                     prog='wctool.py',
                                     usage='%(prog)s [-h | -l | -g | -c | -u | -delete] [options]')
    parser.add_argument("-l",dest='listWorkspaces', action='store_true', help='list workspaces')
    parser.add_argument("-c",dest='createWorkspace', action='store_true', help='create workspace')
    parser.add_argument("-u",dest='updateWorkspace', action='store_true', help='update workspace')
    parser.add_argument("-delete",dest='deleteWorkspace', action='store_true', help='delete workspace')
    parser.add_argument("-g",dest='getWorkspace', action='store_true', help='get details for single workspace')
    parser.add_argument("-logs",dest='listLogs', action='store_true', help='list logs')
    parser.add_argument("-dialog",dest='dialog', action='store_true', help='have dialog')
    parser.add_argument("-outputonly",dest='outputOnly', action='store_true', help='print dialog output only')
    parser.add_argument("-full",dest='fullWorkspace', action='store_true', help='get the full workspace')
    parser.add_argument("-id",dest='workspaceID', help='Workspace ID')
    parser.add_argument("-o",dest='outFile', help='Workspace Output File')
    parser.add_argument("-i",dest='inFile', help='Workspace Input File')
    parser.add_argument("-name",dest='wsName', help='Workspace Name')
    parser.add_argument("-desc",dest='wsDescription', help='Workspace Description')
    parser.add_argument("-lang",dest='wsLang', help='Workspace Language')
    parser.add_argument("-actionmodule",dest='actionModule', help='Module for client action handling')
    parser.add_argument("-filter",dest='filter', help='filter query')
    parser.add_argument("-context",dest='context', help='context file')
    parser.add_argument("-intents",dest='wsIntents', action='store_true', help='Update Intents')
    parser.add_argument("-entities",dest='wsEntities', action='store_true', help='Update Entities')
    parser.add_argument("-dialog_nodes",dest='wsDialogNodes', action='store_true', help='Update Dialog Nodes')
    parser.add_argument("-counterexamples",dest='wsCounterexamples', action='store_true', help='Update Counterexamples')
    parser.add_argument("-metadata",dest='wsMetadata', action='store_true', help='Update Metadata')<commit_msg>Add more explicit synonyms for certain options<commit_after># Copyright 2017-2018 IBM Corp. All Rights Reserved.
# See LICENSE for details.
#
# Author: <NAME>
#
# Manage workspaces for IBM Watson Assistant service on IBM Cloud.
# See the README for documentation.
#

import json, argparse, importlib
from os.path import join, dirname
from ibm_watson import AssistantV1
from ibm_cloud_sdk_core.authenticators import IAMAuthenticator

privcontext=None
assistant=None

def loadAndInit(confFile=None):
    # Credentials are read from a file
    with open(confFile) as confFile:
        config=json.load(confFile)
        configWA=config['credentials']
        if 'ICF_KEY' in config:
            global privcontext
            icf_key=config['ICF_KEY'].split(':')
            privcontext={"private": {"icfcreds": {"user": icf_key[0], "password": icf_key[1]}}}

    # Initialize the Watson Assistant client
    global assistant
    if 'apikey' in configWA:
        # Authentication via IAM
        authenticator = IAMAuthenticator(configWA['apikey'])
        assistant = AssistantV1(
            authenticator=authenticator,
            version=configWA['version'])
        assistant.set_service_url(configWA['url'])
    else:
        print('Apikey for Watson Assistant in credentials.')
        exit


# Define parameters that we want to catch and some basic command help
def initParser(args=None):
    parser = argparse.ArgumentParser(description='Manage Watson Assistant workspaces (skills)',
                                     prog='wctool.py',
                                     usage='%(prog)s [-h | -l | -g | -c | -u | -delete] [options]')
    parser.add_argument("-l", "-list" ,dest='listWorkspaces', action='store_true', help='list workspaces')
    parser.add_argument("-c", "-create", dest='createWorkspace', action='store_true', help='create workspace')
    parser.add_argument("-u", "-update", dest='updateWorkspace', action='store_true', help='update workspace')
    parser.add_argument("-delete",dest='deleteWorkspace', action='store_true', help='delete workspace')
    parser.add_argument("-g", "-get", dest='getWorkspace', action='store_true', help='get details for single workspace')
    parser.add_argument("-logs",dest='listLogs', action='store_true', help='list logs')
    parser.add_argument("-dialog",dest='dialog', action='store_true', help='have dialog')
    parser.add_argument("-outputonly",dest='outputOnly', action='store_true', help='print dialog output only')
    parser.add_argument("-full",dest='fullWorkspace', action='store_true', help='get the full workspace')
    parser.add_argument("-id",dest='workspaceID', help='Workspace ID')
    parser.add_argument("-o", "-outfile", dest='outFile', help='Workspace Output File')
    parser.add_argument("-i", "-infile", dest='inFile', help='Workspace Input File')
    parser.add_argument("-name",dest='wsName', help='Workspace Name')
    parser.add_argument("-desc",dest='wsDescription', help='Workspace Description')
    parser.add_argument("-lang",dest='wsLang', help='Workspace Language')
    parser.add_argument("-actionmodule",dest='actionModule', help='Module for client action handling')
    parser.add_argument("-filter",dest='filter', help='filter query')
    parser.add_argument("-context",dest='context', help='context file')
    parser.add_argument("-intents",dest='wsIntents', action='store_true', help='Update Intents')
    parser.add_argument("-entities",dest='wsEntities', action='store_true', help='Update Entities')
    parser.add_argument("-dialog_nodes",dest='wsDialogNodes', action='store_true', help='Update Dialog Nodes')
    parser.add_argument("-counterexamples",dest='wsCounterexamples', action='store_true', help='Update Counterexamples')
    parser.add_argument("-metadata",dest='wsMetadata', action='store_true', help='Update Metadata')
{'fraction_non_alphanumeric': 0.14461010687425782, 'fraction_numerical': 0.0031666446760786385, 'mean_word_length': 4.76425855513308, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6042886', 'n_tokens_mistral': 2124, 'n_tokens_neox': 2151, 'n_words': 475}