File size: 834 Bytes
107cbbb
a16517c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import torch
from transformers import pipeline
import gradio as gr

classifier = pipeline(model="marsgrins/moby")

def POS_pipe(word):
    pos = classifier(word)[0]['entity']
    return 'I think the part-of-speech of "' + word + '" is "' + pos + '".' 

title = "Part-of-Speech Classifier"
description = "Type in a single English word and I'll try to guess what kind of word it is!"
article="<p style='text-align: center'>by Marshall Grinstead</p><p style='text-align: center'><a href='https://medium.com/@marsgrins' target='_blank'>Blog</a></p><p style='text-align: center'><a href='https://twitter.com/msteadsays' target='_blank'>Twitter</a></p>"

gr.Interface(
    fn=POS_pipe, 
    inputs=gr.Textbox(), 
    outputs=gr.Textbox(),
    title=title, 
    description=description, 
    article=article
).launch()