File size: 684 Bytes
64766e7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pickle
import nltk
import TranslaterLogic

translatorPic = open("trigramTrans.pickle", "rb")
translator = pickle.load(translatorPic)

def triGramTranslate(sentence):
    sentence_romanized=sentence.split(" ")
    translation = ""
    translated = translator.tag(nltk.word_tokenize(sentence.lower()))
    print(translated)
    i=-1
    for word, trans in translated:
        i+=1
        if trans in ('NNN'):
            translation = translation + str(TranslaterLogic.convertText(str(sentence_romanized[i])) + " ")
        else:
            translation = translation + str(trans + " ")
    return translation

inputStr=input("Enter the input")
print(triGramTranslate(inputStr))