@@ -20,27 +20,39 @@ class GLiNERPreprocessor(Action[Dict[str, Any], Dict[str, Any]]):
20
20
21
21
"chunks_starts" (List[int]): Chunks start positions. Used by postprocessor;
22
22
23
+ "flat_ner" (bool): Whether to use flat NER;
24
+
23
25
"threshold" (float): Minimal score for an entity to put into output;
26
+
27
+ "multi_label" (bool): Whether to allow multiple labels per input;
24
28
"""
25
29
26
30
def __init__ (
27
31
self ,
28
32
sents_batch : int = 10 ,
33
+ flat_ner : bool = True ,
29
34
threshold : float = 0.5 ,
35
+ multi_label : bool = False ,
30
36
name : Optional [str ]= None ,
31
37
) -> None :
32
38
"""
33
39
Args:
34
40
sents_batch (int): Chunks size in sentences. Defaults to 10.
35
41
36
- threshold (float): Minimial score to put entities into the output.
42
+ flat_ner (bool): Whether to use flat NER. Defaults to True.
43
+
44
+ threshold (float): Minimial score to put entities into the output. Defaults to 0.5.
45
+
46
+ multi_label (bool): Whether to allow multiple labels per input. Defaults to False.
37
47
38
48
name (Optional[str], optional): Name for identification. If equals to None,
39
49
class name will be used. Defaults to None.
40
50
"""
41
51
super ().__init__ (name )
42
- self .threshold = threshold
43
52
self .sents_batch = sents_batch
53
+ self .flat_ner = flat_ner
54
+ self .threshold = threshold
55
+ self .multi_label = multi_label
44
56
45
57
46
58
def get_last_sentence_id (self , i : int , sentences_len : int ) -> int :
@@ -78,15 +90,21 @@ def execute(
78
90
79
91
"chunks_starts" (List[int]): Chunks start positions. Used by postprocessor;
80
92
93
+ "flat_ner" (bool): Whether to use flat NER;
94
+
81
95
"threshold" (float): Minimal score for an entity to put into output;
96
+
97
+ "multi_label" (bool): Whether to allow multiple labels per input;
82
98
"""
83
99
chunks , chunks_starts = (
84
100
self .chunkanize (input_data ["text" ])
85
101
)
86
102
return {
87
103
"texts" : chunks ,
88
104
"chunks_starts" : chunks_starts ,
105
+ "flat_ner" : self .flat_ner ,
89
106
"threshold" : self .threshold ,
107
+ "multi_label" : self .multi_label ,
90
108
}
91
109
92
110
0 commit comments