File size: 911 Bytes
040033f
 
 
 
 
30bc313
 
040033f
 
30bc313
040033f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30bc313
040033f
 
 
 
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
35
36
import os
import tarfile
import spacy
import gradio as gr

# Nama file dan lokasi ekstraksi
tar_file = "xx_cv_parsing_ner-0.0.1.tar.gz"
extract_path = "xx_cv_parsing_ner"

# Ekstrak jika belum diekstrak
if not os.path.exists(extract_path):
    with tarfile.open(tar_file, "r:gz") as tar:
        tar.extractall(path=extract_path)

# Load spaCy model
model_path = os.path.join(
    extract_path, "xx_cv_parsing_ner-0.0.1", "xx_CV_Parsing_NER", "xx_CV_Parsing_NER-0.0.1"
)
nlp = spacy.load(model_path)

# Fungsi ekstraksi entitas
def extract_entities(text):
    doc = nlp(text)
    return [(ent.text, ent.label_) for ent in doc.ents]

# Gradio UI
demo = gr.Interface(
    fn=extract_entities,
    inputs=gr.Textbox(lines=15, label="Masukkan Teks CV"),
    outputs=gr.Dataframe(headers=["Entity", "Label"], label="Hasil Ekstraksi"),
    title="Ekstraksi Entitas CV"
)

if __name__ == "__main__":
    demo.launch()