<jupyter_start><jupyter_text>Imports<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>User Registration<jupyter_code>user_complain = {}
def complain():
    complaint_id = 1
    while True:
        name = input("Enter your name: ")
        print("Welcome to our Complaint Management System, {}".format(name))
        product_id = input("Enter the ID of the product you are placing a complaint for: ")
        date = dt.now()
        issue = input("Please enter your complaint: ")

        if product_id in user_complain.keys() or name in user_complain.values() or date in user_complain.values() or issue in user_complain.values():
            print('==========================')
            yes_no = input("Your complaint has already been registered.\n Do you want to register 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 providing your complaint.")
                break
            else:
                print("You have entered an invalid response.")
                continue
        elif name == "" or product_id == "" or date == "" or issue == "":
            print("You have entered an invalid response. Please start all over again.")
            continue
        else:
          user_complain[complaint_id] = {"product_id": product_id, "name": name, "date": date, "complaint": issue}
          print('Complaint logged successfully!')
          complaint_id += 1
          yes_no = input("Do you want to register 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 providing your complaint.")
                break
          else:
                print("You have entered an invalid response.")
                continue


complain()<jupyter_output>Enter your name: <NAME>
Welcome to our Complaint Management System, <NAME>
Enter the ID of the product you are placing a complaint for: 75295819
Please enter your complaint: Cannot process payments
Complaint logged successfully!
Do you want to register another complaint?!
 Y for Yes and N for No: y
Enter your name: <NAME>
Welcome to our Complaint Management System, <NAME>
Enter the ID of the product you are placing a complaint for: 75234567
Please enter your complaint: I keep getting errors when processing account
Complaint logged successfully!
Do you want to register another complaint?!
 Y for Yes and N for No: n
Thank you for providing your complaint.<jupyter_text>API Translators, Dictionaries<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': "390c37a65fmsh03237005c27868ep1a87c4jsnd56c83ef5e73",
      '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(user_complain):
  complaint_choice_id = int(input("Please enter the complaint ID of choice you want to translate: "))

  complaint_choice = user_complain[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(user_complain)


translateFunction(user_complain)


while True: 
  proceed_target = input("Translate another complaint? ")
  if proceed_target.lower() == "yes":
    translateFunction(user_complain)

  elif proceed_target.lower() == "no":
    break
  else:
    print("This is not a supported entry. Supported entries are yes and no.")
    continue
print("Thank you using our complaint application")<jupyter_output>Thank you using our complaint application
{'fraction_non_alphanumeric': 0.10289256198347108, 'fraction_numerical': 0.011363636363636364, 'mean_word_length': 3.5886255924170616, 'pattern_counts': {'":': 11, '<': 15, '<?xml version=': 0, '>': 15, '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': '248243', 'license': 'MIT', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1311, 'n_words': 425, 'path': 'Munenyashaishe Hove  -WT- 21-159/Mune Python & API.ipynb', 'repo_name': 'Lilian-hub-dev/Week-3-Assessment', 'size': '4874'}