File size: 702 Bytes
3170a73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 time

import gradio as gr

from litie.pipelines import EventExtractionPipeline

pipeline = EventExtractionPipeline(task_model_name="gplinker", model_name_or_path="xusenlin/duee-gplinker")


def extract(text):
    start = time.time()
    res = pipeline(text)
    running_time = time.time() - start

    return running_time, res


demo = gr.Interface(
    extract,
    [
        gr.Textbox(
            placeholder="Enter sentence here...",
            lines=5
        ),
    ],
    [gr.Number(label="Run Time"), gr.Json(label="Result")],
    examples=[
        ["油服巨头哈里伯顿裁员650人 因美国油气开采活动放缓"],
    ],
    title="Event Extraction Demo",
)

demo.launch()