To Label Studio
Convert Fonduer candidates to Label Studio annotations.
ToLabelStudio
Transfere Fonduer candidates to Label Studio Labes.
Source code in LabelstudioToFonduer/to_label_studio.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
get_offsets(span, sentence)
Get all occurences of a span in a sentence and return the offset
Parameters:
Name | Type | Description | Default |
---|---|---|---|
span |
str
|
Span to be matched. |
required |
sentence |
str
|
Sentence to be searched. |
required |
Returns:
Type | Description |
---|---|
List[Tuple[int, int]]
|
List[Tuple[int, int]]: List of offsets. |
Source code in LabelstudioToFonduer/to_label_studio.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
seriealize_relation(relation, confidence=0.0)
Serialize a Fonduer candidate relation into a Label Studio annotated relation of entities.
The Fonduer candidate is parsed and modified to create a Label Studio annotation from it. First the Relation is created and then all enteties are added. The offset is modified to match the HTML element span, the XPath is modifies to use the body element as root.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
relation |
Any
|
Fonduer candidate relation. |
required |
confidence |
Float
|
confidence score of the relation. Defaults to 0.00. |
0.0
|
Returns:
Type | Description |
---|---|
List[Dict[str, Any]]
|
List[Dict[str, Any]]: List of serialized relations and entities. |
Source code in LabelstudioToFonduer/to_label_studio.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
|
create_export(candidates, fonduer_export_path='')
Create a Label Studio import file from Fonduer candidates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
candidates |
List[Any]
|
Candidates from Fonduer. |
required |
fonduer_export_path |
str
|
Desired location for the Label Studio import file. Defaults to "". |
''
|
Returns:
Type | Description |
---|---|
Union[str, List[Any]]
|
Union[str, List[Any]]: Import dictionary or the |
Union[str, List[Any]]
|
path where the import file is saved. |
Source code in LabelstudioToFonduer/to_label_studio.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|