Initialise the NER aggregation processor (quantities + materials). Uses ``GROBID_QUANTITIES_URL`` and ``GROBID_MATERIALS_URL`` from the environment. Results are cached across Streamlit reruns. Returns: GrobidAggregationProcessor: Configured processor instance.
()
| 160 | |
| 161 | @st.cache_resource |
| 162 | def init_ner(): |
| 163 | """Initialise the NER aggregation processor (quantities + materials). |
| 164 | |
| 165 | Uses ``GROBID_QUANTITIES_URL`` and ``GROBID_MATERIALS_URL`` from |
| 166 | the environment. Results are cached across Streamlit reruns. |
| 167 | |
| 168 | Returns: |
| 169 | GrobidAggregationProcessor: Configured processor instance. |
| 170 | """ |
| 171 | quantities_client = QuantitiesAPI(os.environ["GROBID_QUANTITIES_URL"], check_server=True) |
| 172 | |
| 173 | materials_client = NERClientGeneric(ping=True) |
| 174 | config_materials = { |
| 175 | "grobid": { |
| 176 | "server": os.environ["GROBID_MATERIALS_URL"], |
| 177 | "sleep_time": 5, |
| 178 | "timeout": 60, |
| 179 | "url_mapping": { |
| 180 | "processText_disable_linking": "/service/process/text?disableLinking=True", |
| 181 | # 'processText_disable_linking': "/service/process/text" |
| 182 | }, |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | materials_client.set_config(config_materials) |
| 187 | |
| 188 | gqa = GrobidAggregationProcessor( |
| 189 | grobid_quantities_client=quantities_client, grobid_superconductors_client=materials_client |
| 190 | ) |
| 191 | return gqa |
| 192 | |
| 193 | |
| 194 | gqa = init_ner() |
no test coverage detected