

# https://www.globalsino.com/ICs/
# Input a sentence and then output a sentence based on a dictionary match on csv


# Dic structure > "Key":"Value"
import csv

theFile = r"C:\GlobalSino20230219\ICs\ForDictionary.csv"
theSentense = "I have a Camry! I am good."

reader = csv.reader(open(theFile, 'r'))
myDict = {}
for row in reader:
    k, v = row
    myDict[k] = v

print("The dictionary is:")
print(myDict)

# https://www.globalsino.com/ICs/page4331.html
# Remove all special characters and spaces from a sentence

import re
import os

MyNewSentense = re.split(r'[`!@#$%^&*()_+\-=\[\]{};\':"\\|,.<>\/?~]', theSentense)
newItem = " "

AllTheItemsInNewList = MyNewSentense[0:1]
[AllTheItemsInNewList.extend((newItem, x)) for x in MyNewSentense[1:]]

# Merge all items
theNewList = newItem.join(AllTheItemsInNewList[:])
wordsInTheNewList = theNewList.split() ###

print("\n")
print("My input words are: ")
print(wordsInTheNewList)
for j in wordsInTheNewList:
    # Check if a key in the dic
    if j in myDict:
        if myDict[j] == "Toyota":
            print("\n")
            print("I have a Toyota car!")
        


