<jupyter_start><jupyter_text>IMPORTING DEPENDENCIES<jupyter_code>from datetime import datetime as dt
from requests.utils import requote_uri
import http.client
import json<jupyter_output><empty_output><jupyter_text>FOR THE USER<jupyter_code>#Create a bank for the complaints
complaints_bank = {}
# create signup page
# create empty dictionary that marks the unique ID of the person to the complaint


def complain():
    complaint_id = 1
    while True:
        name = input("Enter your name: ")
        print("Welcome to Customer Care Unit , {}".format(name))
        order_id = input("Enter the ID of the order you are laying complaint for: ")
        date = dt.now()
        issue = input("Kndly input your complaint: ")

        if order_id in complaints_bank.keys() or name in complaints_bank.values() or date in complaints_bank.values() or issue in complaints_bank.values():
            print('==========================')
            yes_no = input("Your complaint has already been recorded.\n Do you want to record another complaint?!\n Y for Yes and N for No: ")
            if yes_no.lower() == "y":
                continue
            elif yes_no.lower() == "n":
                print("Your complaint has been recorded. We will place a call to you shortly.")
                break
            else:
                print("Invalid response!. Try again.")
                continue
        elif name == "" or order_id == "" or date == "" or issue == "":
            print("You have entered an invalid response!. Try again.")
            continue
        else:
            complaints_bank[complaint_id] = {"order_id": order_id, "name": name, "date": date, "complaint": issue}
            print('Your complaint has been recorded. We will place a call to you shortly.')
            complaint_id += 1
            yes_no = input("Do you want to record another complaint?!\n Y for Yes and N for No: ")
            
            if yes_no.lower() == "y":
                continue
            elif yes_no.lower() == "n":
                print("Thank you for your feedback.")
                break
            else:
                print("Invalid response!. Try again")
                continue
            
complain()<jupyter_output>Enter your name: <NAME>
Welcome to Customer Care Unit , Ibukunoluwa Oguns
Enter the ID of the order you are laying complaint for: 1234
Kndly input your complaint: The T-shirt isn't my size, it is small.
Your complaint has been recorded. We will place a call to you shortly.
Do you want to record another complaint?!
 Y for Yes and N for No: y
Enter your name: <NAME>
Welcome to Customer Care Unit , Ibukunoluwa Oguns
Enter the ID of the order you are laying complaint for: 9087
Kndly input your complaint: The shoe is too big
Your complaint has been recorded. We will place a call to you shortly.
Do you want to record another complaint?!
 Y for Yes and N for No: n
Thank you for your feedback.<jupyter_text>FOR THE TEAM<jupyter_code>def api_request(coded_complaint, output_language_code):
    conn = http.client.HTTPSConnection("google-translate1.p.rapidapi.com")

    headers = {
      'content-type': "application/x-www-form-urlencoded",
      'accept-encoding': "application/gzip",
      'x-rapidapi-key': "<KEY>",
      'x-rapidapi-host': "google-translate1.p.rapidapi.com"
      }

    payload = "q=" + coded_complaint + "&target=" + output_language_code
    print(payload)

    conn.request("POST", "/language/translate/v2", payload, headers)

    res = conn.getresponse()
    data = res.read().decode("utf-8")
    return data



def translateFunction(complaints_bank):
    complaint_choice_id = int(input("Please enter the complaint ID of choice you want to translate: "))

    complaint_choice = complaints_bank[complaint_choice_id]['complaint']
    print(complaint_choice)

    coded_complaint = requote_uri(complaint_choice)
    print(coded_complaint)

    output_language_code = input("Please enter the expected output language: ")
 
    print(output_language_code)

    api_call = api_request(coded_complaint, output_language_code)
    print(api_call)

    result_dict = json.loads(api_call)
    print("Translation dictionary: ", result_dict)

    complaint_language = result_dict["data"]["translations"][0]["detectedSourceLanguage"]
    print("The complaint you selected was entered in ", complaint_language)

    translated_result = result_dict["data"]["translations"][0]["translatedText"]
    print("This selected complaint, ", complaint_choice, " translated from ", complaint_language, " to ", output_language_code, " is ", translated_result)
print(complaints_bank)

translateFunction(complaints_bank)


while True: 
    proceed_target = input("Do you want to Translate another complaint? ")
    if proceed_target.lower() == "yes":
        translateFunction(complaints_bank)

    elif proceed_target.lower() == "no":
        break
    else:
        print("Invalid Response. Valid Entreis are yes and no.")
        continue<jupyter_output>{1: {'order_id': '1234', 'name': '<NAME>', 'date': datetime.datetime(2021, 6, 10, 13, 4, 35, 662497), 'complaint': "The T-shirt isn't my size, it is small."}, 2: {'order_id': '9087', 'name': '<NAME>', 'date': datetime.datetime(2021, 6, 10, 13, 5, 14, 582208), 'complaint': 'The shoe is too big'}}
Please enter the complaint ID of choice you want to translate: 1
The T-shirt isn't my size, it is small.
The%20T-shirt%20isn't%20my%20size,%20it%20is%20small.
Please enter the expected output language: es
es
q=The%20T-shirt%20isn't%20my%20size,%20it%20is%20small.&target=es
{"data":{"translations":[{"translatedText":"La camiseta no es de mi talla, es pequeña.","detectedSourceLanguage":"en"}]}}
Translation dictionary:  {'data': {'translations': [{'translatedText': 'La camiseta no es de mi talla, es pequeña.', 'detectedSourceLanguage': 'en'}]}}
The complaint you selected was entered in  en
This selected complaint,  The T-shirt isn't my size, it is small.  translated from  en [...]
{'fraction_non_alphanumeric': 0.11373534338358458, 'fraction_numerical': 0.015242881072026801, 'mean_word_length': 3.3904411764705884, 'pattern_counts': {'":': 15, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '466348', 'license': 'MIT', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1675, 'n_words': 582, 'path': 'Ibukunoluwa Ogunnaike WT-21-106/Women Techsters Assessment Week 3.ipynb', 'repo_name': 'Lilian-hub-dev/Week-3-Assessment', 'size': '6059'}