def multinomialNB(trainDataPos, trainDataNeg, testData, c):
    testFile = testData
    with open(testFile, 'r', encoding='utf8') as file:
        txt = file.read().replace('\n', '')
    reviewList = txt.split('<br /><br />')
    for review in reviewList:
        review = re.sub('[^\\w\\s]', '', review)
    prediction = []
    (posDict, posWordCount, posdocs) = bagOfWords_MultinomialNB(trainDataPos)
    (negDict, negWordCount, negdocs) = bagOfWords_MultinomialNB(trainDataNeg)
    'TEST PRINT STATEMENTS\n    print("Pos dic: ", len(posDict))\n    print("Neg dic: ", len(negDict))\n    print("Pos word count: ", posWordCount)\n    print("Neg word count: ", negWordCount)\n    print("Pos docs: ", posdocs)\n    print("Neg docs: ", negdocs)'
    alpha = 18
    priorLogPosProb = math.log((posdocs / (negdocs + posdocs)))
    priorLogNegProb = math.log((negdocs / (negdocs + posdocs)))
    'for each review in our test, we extract the words and calculate \n    the log prob for that word given pos and neg and add this with \n    the prior log probability, then we compare the pos and neg total\n    probabilities and assign a 1 if the pos > neg, and 0 for the opposite\n    We check the prediction list and calculate the accurace for the \n    given classifier'
    for review in reviewList:
        wordsInReview = list(set(extractCleanWords(review)))
        logProbPos = 0
        logProbNeg = 0
        posPercent = 0
        negPercent = 0
        for word in wordsInReview:
            if (word not in posDict):
                logProbPos += math.log((alpha / (posWordCount + (alpha * len(posDict)))))
            if (word in posDict):
                logProbPos += math.log(((posDict[word] + alpha) / (posWordCount + (alpha * len(posDict)))))
            if (word not in negDict):
                logProbNeg += math.log((alpha / (negWordCount + (alpha * len(negDict)))))
            if (word in negDict):
                logProbNeg += math.log(((negDict[word] + alpha) / (negWordCount + (alpha * len(negDict)))))
        posPercent = (priorLogPosProb + logProbPos)
        negPercent = (priorLogNegProb + logProbNeg)
        if (posPercent > negPercent):
            prediction.append(1)
        else:
            prediction.append(0)
    poss = 0
    for p in prediction:
        if (p == c):
            poss += 1
    return (poss / len(prediction))
def multinomialNB(trainDataPos, trainDataNeg, testData, c):
    testFile = testData
    with open(testFile, 'r', encoding='utf8') as file:
        txt = file.read().replace('\n', )
    reviewList = txt.split('<br /><br />')
    for review in reviewList:
        review = re.sub('[^\\w\\s]', , review)
    prediction = []
    (posDict, posWordCount, posdocs) = bagOfWords_MultinomialNB(trainDataPos)
    (negDict, negWordCount, negdocs) = bagOfWords_MultinomialNB(trainDataNeg)
    'TEST PRINT STATEMENTS\n    print("Pos dic: ", len(posDict))\n    print("Neg dic: ", len(negDict))\n    print("Pos word count: ", posWordCount)\n    print("Neg word count: ", negWordCount)\n    print("Pos docs: ", posdocs)\n    print("Neg docs: ", negdocs)'
    alpha = 18
    priorLogPosProb = math.log((posdocs / (negdocs + posdocs)))
    priorLogNegProb = math.log((negdocs / (negdocs + posdocs)))
    'for each review in our test, we extract the words and calculate \n    the log prob for that word given pos and neg and add this with \n    the prior log probability, then we compare the pos and neg total\n    probabilities and assign a 1 if the pos > neg, and 0 for the opposite\n    We check the prediction list and calculate the accurace for the \n    given classifier'
    for review in reviewList:
        wordsInReview = list(set(extractCleanWords(review)))
        logProbPos = 0
        logProbNeg = 0
        posPercent = 0
        negPercent = 0
        for word in wordsInReview:
            if (word not in posDict):
                logProbPos += math.log((alpha / (posWordCount + (alpha * len(posDict)))))
            if (word in posDict):
                logProbPos += math.log(((posDict[word] + alpha) / (posWordCount + (alpha * len(posDict)))))
            if (word not in negDict):
                logProbNeg += math.log((alpha / (negWordCount + (alpha * len(negDict)))))
            if (word in negDict):
                logProbNeg += math.log(((negDict[word] + alpha) / (negWordCount + (alpha * len(negDict)))))
        posPercent = (priorLogPosProb + logProbPos)
        negPercent = (priorLogNegProb + logProbNeg)
        if (posPercent > negPercent):
            prediction.append(1)
        else:
            prediction.append(0)
    poss = 0
    for p in prediction:
        if (p == c):
            poss += 1
    return (poss / len(prediction))