cos125-project1

Data:

processing_file [type: file]: file of training set
analysis [type: dict]: dictionary of all processed words from training set

Algorithims:

mainmenu: Interactive menu that allows you to navigate to requested feature
main: Initialize processing data and store for repeated and later use
analyzeFile: search line by line in file, calculate average sentiment for entire file, find and return highest positive and negative numbers
posNegInit: Initially set the positive and negative numbers to the first valid numbers in the file, used by analyzeFile
analyzeWord: Analysis of single word for sentiment, called by analyzeFile and individually
processFile: Processes training set file and returns usable dictionary of words

Program Structure:

Execution Order
                     main() -> processFile() -> mainmenu() -> analyzeFile() -------\
                        \----------------------/ |  ^    |      ^                  |
                                                 |  |    |      |-> posNegInit()   |
                   Program Termination <---------/  |    |      |                  |
                                                    |    \---> analyzeWord()-----> |
                                                    |                              |
                                                    \------------------------------/
            (see also ProgramExecutionLayout.png)

Program Execution Flow

mainmenu(analysis):

main program execution menu

parameters:
    None
returns:
    None

Start condition: call from main()

End condition: '4'entered in menu

Local Variables:

option: int: menu option selected
results: tuple: results returns from either analyzeWord or analyzeFile: See specific function header for details on format

Loops:

while option != 4: Keep execution in mainmenu until "quit" menu option is selected

analyzeFile(file_name)

analyze all lines in file and find highest positive and negative words

parameters:
    0: str: file_name being analyzed
returns:
    0: str: name of file
	1: float: average sentiment of file_name
	2: str: designation of insult, compliment, or neutral
	3: list: positive number information [str "max positive word searched", float "positive max analysis number"]
	4: list: negative number information [str "max negative word searched", float "negative max analysis number"]

Start condition: call from mainmenu()

End condition: computation complete

Local Variables:

count: int: total count of all words counted
sentiment: int/float: initially a float of total computed sentiment, later converted to float by averaging total sentiment value
positive: list: [str: most positive word, int: most positive value], initially first valid value
negative: list: [str: most negative word, int: most negative value], initially first valid value
words: file: file to be calculated, from para:file_name
line: str/list: initially, specific line in file:words. Converted to list with each word as seperate value
word: str: specific word from list:line
word_sentiment: int: specific sentiment from str:word, see also analyzeWord return value 3
designation: str: string with specific statement of average sentiment ['an insult', 'a compliment', 'neutral']

Loops:

for line in words: gets each line from file:words
for word in line: gets each word from list:line

setupInitialPositiveNegativeLists(file_name):

Sets up initial largest positive and largest negative numbers lists

parameters:
0: str: name of file
returns:
0: list: positive number information [str "max positive word searched", float "positive current max analysis number"]
1: list: negative number information [str "max negative word searched", float "negative current max analysis number"]

Start condition: call from mainmenu()

End condition: computation complete

Local Variables:

words: file: file from param:file_name
row: string/list: returns row from file:words, then formats as list of all words
word: string: word from list:row
positive: list: [str: word, float: sentiment] first valid word from file:words (See analyzeWord returns for more info)
negative: list: [str: word, float: sentiment] first valid word from file:words (See analyzeWord returns for more info)

Loops:

N/A

analyzeWord(word):

Sets up initial largest positive and largest negative numbers lists

parameters:
0: str: word to be searched
returns:
0: str: word analyzed
1: int: count of word in training set
2: str :string formatted sentiment analysis
3: float: numeric formatted sentiment analysis

Start condition: call from analyzeFile()

End condition: processing complete

Local Variables:

N/A

Loops:

N/A
S
Description
No description provided
Readme 2.8 MiB
Languages
Python 54.1%
Jupyter Notebook 45.9%