Example #1
0
File: main.py Project: storgi/ASP
def main3():
    trainer = loadTrainer(False, 5)
    probSeq = Probability(-1,'', 1.0)
    probCon = Probability(-1,'', 1.0)

    io = IOHandler()
    b = Builder()
    inputStr = "3#843"
    text = "e the"

    tmp = ''

    i = 0

    for letter in inputStr:
        b.charSequenceProbablility(probSeq, letter, trainer)
        b.conditionalProbablility(probCon, letter, trainer)

        tmp += text[i]

        print("DEBUG Probability of word", tmp , "is ", probCon.getChild(tmp).getProbability(), probSeq.getChild(tmp).getProbability())


        #Check if input word is stil within range.  If not we can not calculate
        #probabilites
        i += 1
        if(i >= trainer.depth):
            print("DEBUG: Input word is bigger then depth of training corpus. Exiting now!")
            break

    print("DEBUG Probability of word", text , "is ", probCon.getChild(text).getProbability(), probSeq.getChild(text).getProbability())
    return True

#main3()
Example #2
0
File: main.py Project: storgi/ASP
def main():
    trainer = loadTrainer(False, 5)
    probSeq = Probability(-1,'', 1.0)
    probCon = Probability(-1,'', 1.0)

    io = IOHandler()
    b = Builder()
    inputStr = io.getInput()

    i = 0

    while(inputStr != False):
        b.charSequenceProbablility(probSeq, inputStr, trainer)
        b.conditionalProbablility(probCon, inputStr, trainer)

        #Check if input word is stil within range.  If not we can not calculate
        #probabilites
        i += 1
        if(i >= trainer.depth):
            print("DEBUG: Input word is bigger then depth of training corpus. Exiting now!")
            break

        inputStr = io.getInput()
    return True