import nltk
from nltk.stem import PorterStemmer
from nltk.corpus import wordnet
from nltk.tokenize import word_tokenize

def process_and_compare(input_text, database_tags):
    # Ensure NLTK dependencies are downloaded
    nltk.download('punkt')

    # Initialize stemmer
    stemmer = PorterStemmer()

    # Tokenize and stem input text
    tokens = word_tokenize(input_text.lower())
    stemmed_tokens = [stemmer.stem(token) for token in tokens]

    # Check for matches with database tags
    matches = [tag for tag in database_tags if stemmer.stem(tag) in stemmed_tokens]
    return matches

def main():

    # Prompt the user for input
    # TODO: Change the words
    input_text = input("Enter your search query: ")
    
    # TODO: Change to compare with the tags in database
    database_tags = ["run", "shoe", "sport", "outdoor"]

    matches = process_and_compare(input_text, database_tags)
    
    # TODO: return the item based on the matched tags
    print("Placeholder")
    return 0

if __name__ == "__main__":
    main()