File size: 1,155 Bytes
0d083c9
 
 
5671dcd
 
0d083c9
 
 
6b90147
0d083c9
 
 
48034d5
 
 
0d083c9
 
 
 
48034d5
0d083c9
 
 
 
 
 
 
 
fdedfc2
 
 
0d083c9
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import gradio as gr
import gradio.inputs


 #interacting with input and output directories

import pickle
from final_maybe import LanguageModel
with open('without_laplace.sav','rb') as handle:
    loaded_model = pickle.load(handle)
def fn(X_test):
    
    
    X_final_list = list(map(str, X_test.split(' ')))
    X_final=tuple(X_final_list[-2:])
    model = loaded_model
    result = model._best_candidate(X_final,0)
    
    return result
description = "Here is an interface for next word prediction using tri-gram model. Given an input, our model will predict the next word. Please make sure not to add a space after the last word."
here = gr.Interface(fn=fn,
                     inputs= gradio.inputs.Textbox( lines=1, placeholder=None, default="", label=None),
                     outputs='text',
                     title="Next Word Prediction",
                     description=description,
                     theme="default",
                     allow_flagging="auto",
                     flagging_dir='flagging records')
here.launch(inline=False,share=False)
# if __name__ == "__main__":
#     app, local_url, share_url = here.launch()