Spaces:
Running
Running
Commit
·
ab71a6e
1
Parent(s):
929cf45
add labels and rels
Browse files
app.py
CHANGED
@@ -11,10 +11,6 @@ _CACHE_DIR = os.environ.get("CACHE_DIR", None)
|
|
11 |
from gliner import GLiNER
|
12 |
from gliner.multitask import GLiNERRelationExtractor
|
13 |
|
14 |
-
# Import inference pipeline and configuration
|
15 |
-
from my_project.pipeline import inference_pipeline
|
16 |
-
from my_project.config import TYPE2RELS, labels
|
17 |
-
|
18 |
# Cache and initialize model + relation extractor
|
19 |
DATA_MODEL_ID = "rafmacalaba/gliner_re_finetuned-v3"
|
20 |
model = GLiNER.from_pretrained(DATA_MODEL_ID, cache_dir=_CACHE_DIR)
|
@@ -34,6 +30,17 @@ SAMPLE_TEXT = (
|
|
34 |
|
35 |
# Post-processing: prune acronyms and self-relations
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
def prune_acronym_and_self_relations(ner_preds, rel_preds):
|
38 |
# 1) Find acronym targets strictly shorter than their source
|
39 |
acronym_targets = {
|
|
|
11 |
from gliner import GLiNER
|
12 |
from gliner.multitask import GLiNERRelationExtractor
|
13 |
|
|
|
|
|
|
|
|
|
14 |
# Cache and initialize model + relation extractor
|
15 |
DATA_MODEL_ID = "rafmacalaba/gliner_re_finetuned-v3"
|
16 |
model = GLiNER.from_pretrained(DATA_MODEL_ID, cache_dir=_CACHE_DIR)
|
|
|
30 |
|
31 |
# Post-processing: prune acronyms and self-relations
|
32 |
|
33 |
+
labels = ['named dataset', 'unnamed dataset', 'vague dataset']
|
34 |
+
rels = ['acronym', 'author', 'data description',\
|
35 |
+
'data geography', 'data source', 'data type',\
|
36 |
+
'publication year', 'publisher', 'reference year', 'version']
|
37 |
+
|
38 |
+
TYPE2RELS = {
|
39 |
+
"named dataset": rels,
|
40 |
+
"unnamed dataset": rels,
|
41 |
+
"vague dataset": rels,
|
42 |
+
}
|
43 |
+
|
44 |
def prune_acronym_and_self_relations(ner_preds, rel_preds):
|
45 |
# 1) Find acronym targets strictly shorter than their source
|
46 |
acronym_targets = {
|