#!/usr/bin/env python3

import os
import sys

from analyzer import Analyzer
from termcolor import colored

def main():

    # ensure proper usage of command line argument
    if len(sys.argv) != 2:
        sys.exit("Usage: ./smile word")

    # absolute paths to lists
    positives = os.path.join(sys.path[0], "positive-words.txt") # positives = ./positive-words.txt
    negatives = os.path.join(sys.path[0], "negative-words.txt")

    # instantiate analyzer
    analyzer = Analyzer(positives, negatives) # it uses "class" in python. 
                                            # It is similar to structure in C but provides method of a structure

    # analyze word and retrieves score
    score = analyzer.analyze(sys.argv[1]) # passing the second argument to analyzer.analyze() method, 
                                            #the return value was assigned to score
    if score > 0.0: # positive case
        print(colored(":)", "green")) # prints result, colored accordingly
    elif score < 0.0:
        print(colored(":(", "red"))
    else:
        print(colored(":|", "yellow"))

if __name__ == "__main__":
    main()
