We did manage to import an open source AI Chatbot for the part of the code teaching python. The code does compile and it does work as intended however, the library doesn't seem to work very well. Here's the code which incorporates the Chatbot:

import random import string import nltk from nltk.corpus import wordnet as wn import nltk nltk.download('wordnet')

letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J" "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T" "U", "V", "W", "X", "Y", "Z"]

print("Welcome to Noun, Verb, Adjective!") print("Choose a language from the following to play the game. Type 'p' for Python, 't' for Turkish") languagechoice = input()

def game(): letterchoice = random.choice(letters) print("Think of a noun, verb and an adjective starting with the letter " + letterchoice) Noun = input() Verb = input() Adjective = input() synsets = {"noun": wn.synsets('noun'), "verb": wn.synsets('verb'), "adj": wn.synsets('adj')}

def is_in_database(term, category=""):
    try:
        if not category:
            return False
        _ = synsets[category](lemma=term)[0]
        return True
    except IndexError:
        return False

def is_correct_pos(term, expected_pos):
    pos_tags = nltk.pos_tag([term])
    return pos_tags[0][1].replace("-", "_").startswith(expected_pos)

def validate_entry(entry, entry_type, expected_pos):
    if is_in_database(entry):
        if is_correct_pos(entry, expected_pos):
            return True
        else:
            print(f"{entry} seems to be invalid according to our records.")
    else:
        print(f"The term {entry} isn't found in our dictionary.")

    return False

result = all(validate_entry(entry, f"{entry}_type".capitalize(), entry[:2]) for entry in (Noun, Verb, Adjective) if entry)
return result

def levelonepython(): print("Level 1") if game() == True: print("Congratulations! You have passed level 1. ") print("Reward : Learn how to take a user input in python: ") print('"x = input("Hello! What is your name?")" where your input is assigned to a variable x') print("Do you want to keep playing? If yes, enter y else type n to exit") continueplaying = input() if continueplaying == 'y': leveltwopython() else: exit
else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': levelonepython() else: exit def leveltwopython(): print("Level 2") if game() == True: print("Congratulations! You have passed level 2. ") print("Reward : Learn how to check a condition and execute something if the condition holds true") print('"if x == 1: print("Yes")" where if the value of x is 1 then it prints "Yes"') print("Do you want to keep playing? If yes, enter y else type n to exit") continueplaying = input() if continueplaying == 'y': levelthreepython() else: exit
else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': leveltwopython() else: exit def levelthreepython(): print("Level 3") if game() == True: print("Congratulations! You have passed level 3. ") print('"Reward : Learn how to print integers from one to ten with iteration using the "for" loop"') print("for i in range(1, 11): ") print(" print(i)") print("where i will keep incrementing by 1 and being printed until it reaches 10. How cool is that?!") print("Do you want to keep playing? If yes, enter y else type n to exit") continueplaying = input() if continueplaying == 'y': levelfourpython() else: exit
else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': levelthreepython() else: exit def levelfourpython(): print("Level 4") if game() == True: print("Congratulations! You have passed level 4. ") print('"Reward : Learn how to print integers from one to ten with iteration using the "while" loop"') print("numbers = 1") print("While (numbers != 11):") print(" print(i)") print(" number += 1") print("where the variable numbers is initialised as 1. The value of numbers will be printed in each iteration and incremented. The loop will end when numbers reach greater than 10.") print("Do you want to keep playing? If yes, enter y else type n to exit") continueplaying = input() if continueplaying == 'y': levelfivepython() else: exit
else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': levelfourpython() else: exit def levelfivepython(): print("Level 5") if game() == True: print("Congratulations! You have passed level 5. ") print('"Reward : Learn how to print integers from one to ten with iteration using the "while" loop"') print("Did you know that the 6 standard data types in Python are Numeric, String, List, Tuple, Set, and Dictionary.") print("Well done! You now know the most basic facts about Python! :)))") exit else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': levelfourpython() else: exit

def leveloneturkish(): print('Hi! Today we will be playing a game of Noun, Verb, Adjective in Turkish. This will help you with learning the Turkish language.') print('First I will give you a Noun, a Verb, and an Adjective in Turkish:')

yesno = input('Ready? Type yes or no')

if yesno.lower() == 'no':
    print("Oh")
else :
    print('Here are your words:')

Here, you would import the language model that we are unable to. It would choose 3 words -- a noun,

a verb, and an adjective -- that start with the letter 'a'. It would also be in the correct Turkish alphabet with the

necessary accents. An example of this would be Turneng-Translation-CLI.

    print('Noun: agac = tree. Pronounced "aadch" with a long a in the beginning.')
    print('Verb: atlamak = to jump. Pronounced as read.')
    print('Adjective: alcak = short. Pronounced "alchak".')

    print('Please write each of the words in the box below:')

    agac = input('Please write the noun that means tree: ')

    if agac.lower() == 'agak':
        print('Close! One letter off.')
    elif agac.lower() == 'agac':
        print('Great! Let\'s move to the verb.')
        atlamak = input('Please write the verb that means to jump:')  
        if atlamak.lower() == 'altamak':
            print('Close! Please switch some letters around.')
        elif atlamak.lower() == 'atlamak':
            print('Great! Let\'s move to the adjective.')
            alcak = input('Please write the adjective that means short:')
        else:
            print('Please try again.')
            leveloneturkish()
    else:
        print('Please try again.')
        leveloneturkish()
    print("Congratulations! You now know a noun, verb and adjective starting with the letter a in Turkish :)))")

def generate_word(start_letter): nouns = ['agac', 'araba', 'avukat', 'ay', 'anne'] verbs = ['b', 'beben', 'beklemek', 'bulmak']
adjectives = ['akilli', 'az', 'agir', 'aziz', 'asiri']

filtered_nouns = [noun for noun in nouns if noun.startswith(start_letter)]
filtered_verbs = [verb for verb in verbs if verb.startswith(start_letter)]
filtered_adjectives = [adj for adj in adjectives if adj.startswith(start_letter)]

chosen_noun = random.choice(filtered_nouns) if filtered_nouns else 'No matching noun'
chosen_verb = random.choice(filtered_verbs) if filtered_verbs else 'No matching verb'
chosen_adjective = random.choice(filtered_adjectives) if filtered_adjectives else 'No matching adjective'

return chosen_noun, chosen_verb, chosen_adjective

def play_game(): alphabet = list(string.ascii_lowercase) random.shuffle(alphabet)

for letter in alphabet:
    print(f'\nFor the letter {letter.upper()}:')

    noun, verb, adjective = generate_word(letter)

    print(f'Noun: {noun}')
    print(f'Verb: {verb}')
    print(f'Adjective: {adjective}')

    user_noun = input('Your guess for the noun: ')
    user_verb = input('Your guess for the verb: ')
    user_adjective = input('Your guess for the adjective: ')

    if user_noun.lower() == noun and user_verb.lower() == verb and user_adjective.lower() == adjective:
        print('Correct! Next letter...')
    else:
        print('Incorrect. Try again with the next letter.')    

This is an example of how the remainder of the game can go. After iterating thorugh all of the letters, stage 1 of the

program runs again and new nouns, verbs, and adjectives are learnt by the users.

This system repeats until all of the letters of the alphabet that a word can start with have been learnt. Afterwards,

the code progresses to the next stage.

if (languagechoice == 'p'): levelonepython() else: leveloneturkish()

Without importing the open source AI Chatbot, the code works as intended. We used a set list of values called vocabulary to test that the code runs as follows:

import random import string

letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J" "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T" "U", "V", "W", "X", "Y", "Z"]

vocabulary = ["Apple", "Act", "Adamant"]

print("Welcome to Noun, Verb, Adjective!") print("Choose a language from the following to play the game. Type 'p' for Python, 't' for Turkish") languagechoice = input()

def game(): letterchoice = random.choice(letters) print("Think of a noun, verb and an adjective starting with the letter " + letterchoice) Noun = input() Verb = input() Adjective = input() # Here, you would use the open source AI Bot that we are unable to. It would check that the inputs are valid. # We have just created a small list called vocabulary to test if the game runs. if (Noun in vocabulary): if (Verb in vocabulary): if (Adjective in vocabulary): return True else: print("Oops...seems like the adjective doesn't exist") else: print("Oops...seems like the verb doesn't exist") else: print("Oops...seems like the noun doesn't exist") return False

def levelonepython(): print("Level 1") if game() == True: print("Congratulations! You have passed level 1. ") print("Reward : Learn how to take a user input in python: ") print('"x = input("Hello! What is your name?")" where your input is assigned to a variable x') print("Do you want to keep playing? If yes, enter y else type n to exit") continueplaying = input() if continueplaying == 'y': leveltwopython() else: exit
else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': levelonepython() else: exit def leveltwopython(): print("Level 2") if game() == True: print("Congratulations! You have passed level 2. ") print("Reward : Learn how to check a condition and execute something if the condition holds true") print('"if x == 1: print("Yes")" where if the value of x is 1 then it prints "Yes"') print("Do you want to keep playing? If yes, enter y else type n to exit") continueplaying = input() if continueplaying == 'y': levelthreepython() else: exit
else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': leveltwopython() else: exit def levelthreepython(): print("Level 3") if game() == True: print("Congratulations! You have passed level 3. ") print('"Reward : Learn how to print integers from one to ten with iteration using the "for" loop"') print("for i in range(1, 11): ") print(" print(i)") print("where i will keep incrementing by 1 and being printed until it reaches 10. How cool is that?!") print("Do you want to keep playing? If yes, enter y else type n to exit") continueplaying = input() if continueplaying == 'y': levelfourpython() else: exit
else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': levelthreepython() else: exit def levelfourpython(): print("Level 4") if game() == True: print("Congratulations! You have passed level 4. ") print('"Reward : Learn how to print integers from one to ten with iteration using the "while" loop"') print("numbers = 1") print("While (numbers != 11):") print(" print(i)") print(" number += 1") print("where the varaible numbers is initialised as 1. Th evalue of numbers will be printed in each iteration and incremented. The loop will end when numbers reach greater than 10.") print("Do you want to keep playing? If yes, enter y else type n to exit") continueplaying = input() if continueplaying == 'y': levelfivepython() else: exit
else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': levelfourpython() else: exit def levelfivepython(): print("Level 5") if game() == True: print("Congratulations! You have passed level 5. ") print('"Reward : Learn how to print integers from one to ten with iteration using the "while" loop"') print("Did you know that the 6 standard data types in Python are Numeric, String, List, Tuple, Set, and Dictionary.") print("Well done! You now know the most basic facts about Python! :)))") exit else: print("Do you want to try again? If yes, enter y else type n to exit") tryagain = input() if tryagain == 'y': levelfourpython() else: exit

def leveloneturkish(): print('Hi! Today we will be playing a game of Noun, Verb, Adjective in Turkish. This will help you with learning the Turkish language.') print('First I will give you a Noun, a Verb, and an Adjective in Turkish:')

yesno = input('Ready? Type yes or no')

if yesno.lower() == 'no':
    print("Oh")
else :
    print('Here are your words:')

Here, you would import the language model that we are unable to. It would choose 3 words -- a noun,

a verb, and an adjective -- that start with the letter 'a'. It would also be in the correct Turkish alphabet with the

necessary accents. An example of this would be Turneng-Translation-CLI.

    print('Noun: agac = tree. Pronounced "aadch" with a long a in the beginning.')
    print('Verb: atlamak = to jump. Pronounced as read.')
    print('Adjective: alcak = short. Pronounced "alchak".')

    print('Please write each of the words in the box below:')

    agac = input('Please write the noun that means tree: ')

    if agac.lower() == 'agak':
        print('Close! One letter off.')
    elif agac.lower() == 'agac':
        print('Great! Let\'s move to the verb.')
        atlamak = input('Please write the verb that means to jump:')  
        if atlamak.lower() == 'altamak':
            print('Close! Please switch some letters around.')
        elif atlamak.lower() == 'atlamak':
            print('Great! Let\'s move to the adjective.')
            alcak = input('Please write the adjective that means short:')
        else:
            print('Please try again.')
            leveloneturkish()
    else:
        print('Please try again.')
        leveloneturkish()
    print("Congratulations! You now know a noun, verb and adjective starting with the letter a in Turkish :)))")

def generate_word(start_letter): nouns = ['agac', 'araba', 'avukat', 'ay', 'anne'] verbs = ['b', 'beben', 'beklemek', 'bulmak']
adjectives = ['akilli', 'az', 'agir', 'aziz', 'asiri']

filtered_nouns = [noun for noun in nouns if noun.startswith(start_letter)]
filtered_verbs = [verb for verb in verbs if verb.startswith(start_letter)]
filtered_adjectives = [adj for adj in adjectives if adj.startswith(start_letter)]

chosen_noun = random.choice(filtered_nouns) if filtered_nouns else 'No matching noun'
chosen_verb = random.choice(filtered_verbs) if filtered_verbs else 'No matching verb'
chosen_adjective = random.choice(filtered_adjectives) if filtered_adjectives else 'No matching adjective'

return chosen_noun, chosen_verb, chosen_adjective

def play_game(): alphabet = list(string.ascii_lowercase) random.shuffle(alphabet)

for letter in alphabet:
    print(f'\nFor the letter {letter.upper()}:')

    noun, verb, adjective = generate_word(letter)

    print(f'Noun: {noun}')
    print(f'Verb: {verb}')
    print(f'Adjective: {adjective}')

    user_noun = input('Your guess for the noun: ')
    user_verb = input('Your guess for the verb: ')
    user_adjective = input('Your guess for the adjective: ')

    if user_noun.lower() == noun and user_verb.lower() == verb and user_adjective.lower() == adjective:
        print('Correct! Next letter...')
    else:
        print('Incorrect. Try again with the next letter.')    

This is an example of how the remainder of the game can go. After iterating thorugh all of the letters, stage 1 of the

program runs again and new nouns, verbs, and adjectives are learnt by the users.

This system repeats until all of the letters of the alphabet that a word can start with have been learnt. Afterwards,

the code progresses to the next stage.

if (languagechoice == 'p'): levelonepython() else: leveloneturkish()

Built With

Share this project:

Updates