|
18 | 18 | }, |
19 | 19 | { |
20 | 20 | "cell_type": "code", |
21 | | - "execution_count": 1, |
| 21 | + "execution_count": null, |
22 | 22 | "id": "0e32d652-af95-44d4-89a0-de554d2f33a2", |
23 | 23 | "metadata": {}, |
24 | 24 | "outputs": [], |
|
41 | 41 | }, |
42 | 42 | { |
43 | 43 | "cell_type": "code", |
44 | | - "execution_count": 2, |
| 44 | + "execution_count": null, |
45 | 45 | "id": "4f0c40e5-bec7-4281-a313-80234c19b95f", |
46 | 46 | "metadata": {}, |
47 | 47 | "outputs": [], |
|
60 | 60 | }, |
61 | 61 | { |
62 | 62 | "cell_type": "code", |
63 | | - "execution_count": 3, |
| 63 | + "execution_count": null, |
64 | 64 | "id": "fdd6ef86-ce41-4813-aba4-70af07693a9f", |
65 | 65 | "metadata": {}, |
66 | 66 | "outputs": [], |
|
78 | 78 | }, |
79 | 79 | { |
80 | 80 | "cell_type": "code", |
81 | | - "execution_count": 4, |
| 81 | + "execution_count": null, |
82 | 82 | "id": "8126fb35-a9b1-45b1-b63d-b07b02e5dcf1", |
83 | 83 | "metadata": {}, |
84 | 84 | "outputs": [], |
85 | 85 | "source": [ |
86 | | - "from dackar.workflows.RuleBasedMatcher import RuleBasedMatcher\n", |
| 86 | + "from dackar.causal.CausalSentence import CausalSentence\n", |
87 | 87 | "from dackar import config\n", |
88 | 88 | "from dackar.utils.nlp.nlp_utils import generatePatternList" |
89 | 89 | ] |
|
98 | 98 | }, |
99 | 99 | { |
100 | 100 | "cell_type": "code", |
101 | | - "execution_count": 5, |
| 101 | + "execution_count": null, |
102 | 102 | "id": "2c0f142f-42fd-45c4-8389-1eeca5f8e8ce", |
103 | 103 | "metadata": {}, |
104 | 104 | "outputs": [], |
|
117 | 117 | }, |
118 | 118 | { |
119 | 119 | "cell_type": "code", |
120 | | - "execution_count": 6, |
| 120 | + "execution_count": null, |
121 | 121 | "id": "31319bfe-c0b9-4e9f-9c1f-a52bfae36215", |
122 | 122 | "metadata": {}, |
123 | 123 | "outputs": [], |
|
142 | 142 | }, |
143 | 143 | { |
144 | 144 | "cell_type": "code", |
145 | | - "execution_count": 7, |
| 145 | + "execution_count": null, |
146 | 146 | "id": "643de747-4981-4bdd-ab44-f4f1abb16f1a", |
147 | 147 | "metadata": {}, |
148 | 148 | "outputs": [], |
|
167 | 167 | }, |
168 | 168 | { |
169 | 169 | "cell_type": "code", |
170 | | - "execution_count": 8, |
| 170 | + "execution_count": null, |
171 | 171 | "id": "8503b3c3-8a9e-4526-84b7-64cc8ccb9728", |
172 | 172 | "metadata": {}, |
173 | | - "outputs": [ |
174 | | - { |
175 | | - "name": "stderr", |
176 | | - "output_type": "stream", |
177 | | - "text": [ |
178 | | - "30-May-25 15:56:31 dackar.workflows.WorkflowBase INFO Create instance of RuleBasedMatcher\n", |
179 | | - "30-May-25 15:56:33 dackar.utils.nlp.nlp_utils INFO Model: core_web_lg, Language: en\n", |
180 | | - "30-May-25 15:56:33 dackar.utils.nlp.nlp_utils INFO Available pipelines:pysbdSentenceBoundaries, tok2vec, tagger, parser, attribute_ruler, lemmatizer, mergePhrase, normEntities, initCoref, aliasResolver, anaphorCoref, anaphorEntCoref\n" |
181 | | - ] |
182 | | - } |
183 | | - ], |
| 173 | + "outputs": [], |
184 | 174 | "source": [ |
185 | 175 | "name = 'ssc_entity_ruler'\n", |
186 | | - "matcher = RuleBasedMatcher(nlp, entID=entId, causalKeywordID=causalID)\n", |
| 176 | + "matcher = CausalSentence(nlp, entID=entId, causalKeywordID=causalID)\n", |
187 | 177 | "matcher.addEntityPattern(name, patternsOPM)\n", |
188 | 178 | "\n", |
189 | 179 | "causalName = 'causal_keywords_entity_ruler'\n", |
|
200 | 190 | }, |
201 | 191 | { |
202 | 192 | "cell_type": "code", |
203 | | - "execution_count": 9, |
| 193 | + "execution_count": null, |
204 | 194 | "id": "e5ba4b71-c0ec-40dd-bcbb-51ce67de4b95", |
205 | 195 | "metadata": {}, |
206 | 196 | "outputs": [], |
|
220 | 210 | }, |
221 | 211 | { |
222 | 212 | "cell_type": "code", |
223 | | - "execution_count": 10, |
| 213 | + "execution_count": null, |
224 | 214 | "id": "9cb4ae56-ea17-4289-b2c5-e3602ce4fd9f", |
225 | 215 | "metadata": {}, |
226 | | - "outputs": [ |
227 | | - { |
228 | | - "name": "stderr", |
229 | | - "output_type": "stream", |
230 | | - "text": [ |
231 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher INFO Start to extract health status\n", |
232 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher WARNING No status identified for \"pump\" in \"Slight Vibrations is noticed - likely from pump shaft deflection.\n", |
233 | | - "\"\n", |
234 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher WARNING Entity \"pump\" dep_ is \"xcomp\" is not among valid list \"[nsubj, nsubjpass, pobj, dobj, compound]\"\n", |
235 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher WARNING Entity \"pump\" dep_ is \"xcomp\" is not among valid list \"[nsubj, nsubjpass, pobj, dobj, compound]\"\n", |
236 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher WARNING Entity \"pump\" dep_ is \"advcl\" is not among valid list \"[nsubj, nsubjpass, pobj, dobj, compound]\"\n", |
237 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher INFO End of health status extraction!\n", |
238 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher INFO Start to extract causal relation using OPM model information\n", |
239 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher INFO End of causal relation extraction!\n", |
240 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher INFO Start to use general extraction method to extract causal relation\n", |
241 | | - "30-May-25 15:56:33 dackar.workflows.RuleBasedMatcher INFO End of causal relation extraction using general extraction method!\n" |
242 | | - ] |
243 | | - }, |
244 | | - { |
245 | | - "name": "stdout", |
246 | | - "output_type": "stream", |
247 | | - "text": [ |
248 | | - "(bearings, caused, shaft degradation) (bearings, caused, shaft degradation) (inspection, revealed, degradation) (inspection, revealed, degradation) (they, caused, failure) (Low flow conditions, causing, cavitation) (Pump, keep, the check valves) (shaft, made, noise) (Pump, made, noises)\n" |
249 | | - ] |
250 | | - } |
251 | | - ], |
| 216 | + "outputs": [], |
252 | 217 | "source": [ |
253 | 218 | "matcher(doc)" |
254 | 219 | ] |
|
263 | 228 | }, |
264 | 229 | { |
265 | 230 | "cell_type": "code", |
266 | | - "execution_count": 11, |
| 231 | + "execution_count": null, |
267 | 232 | "id": "cdf032fd-3c88-46fc-9629-0762973669eb", |
268 | 233 | "metadata": {}, |
269 | | - "outputs": [ |
270 | | - { |
271 | | - "data": { |
272 | | - "text/plain": [ |
273 | | - "[[pump bearings,\n", |
274 | | - " None,\n", |
275 | | - " caused,\n", |
276 | | - " shaft degradation,\n", |
277 | | - " None,\n", |
278 | | - " Rupture of pump bearings caused pump shaft degradation.,\n", |
279 | | - " False],\n", |
280 | | - " [pump bearings,\n", |
281 | | - " None,\n", |
282 | | - " caused,\n", |
283 | | - " shaft degradation,\n", |
284 | | - " None,\n", |
285 | | - " Rupture of pump bearings caused pump shaft degradation and consequent flow reduction.,\n", |
286 | | - " False],\n", |
287 | | - " [power supply,\n", |
288 | | - " None,\n", |
289 | | - " due to,\n", |
290 | | - " Pump,\n", |
291 | | - " None,\n", |
292 | | - " Pump test failed due to power supply failure.,\n", |
293 | | - " False],\n", |
294 | | - " [Pump,\n", |
295 | | - " None,\n", |
296 | | - " revealed,\n", |
297 | | - " impeller,\n", |
298 | | - " None,\n", |
299 | | - " Pump inspection revealed excessive impeller degradation.,\n", |
300 | | - " False],\n", |
301 | | - " [Pump,\n", |
302 | | - " None,\n", |
303 | | - " revealed,\n", |
304 | | - " impeller,\n", |
305 | | - " None,\n", |
306 | | - " Pump inspection revealed excessive impeller degradation likely due to cavitation.,\n", |
307 | | - " True],\n", |
308 | | - " [pump shaft,\n", |
309 | | - " None,\n", |
310 | | - " caused,\n", |
311 | | - " pump,\n", |
312 | | - " None,\n", |
313 | | - " Several cracks on pump shaft were observed; they could have caused pump failure within few days.,\n", |
314 | | - " True],\n", |
315 | | - " [pump shaft,\n", |
316 | | - " None,\n", |
317 | | - " causing,\n", |
318 | | - " motor,\n", |
319 | | - " None,\n", |
320 | | - " The pump shaft vibration appears to be causing the motor to vibrate as well.,\n", |
321 | | - " False]]" |
322 | | - ] |
323 | | - }, |
324 | | - "execution_count": 11, |
325 | | - "metadata": {}, |
326 | | - "output_type": "execute_result" |
327 | | - } |
328 | | - ], |
| 234 | + "outputs": [], |
329 | 235 | "source": [ |
330 | 236 | "matcher._extractedCausals" |
331 | 237 | ] |
332 | 238 | } |
333 | 239 | ], |
334 | 240 | "metadata": { |
335 | 241 | "kernelspec": { |
336 | | - "display_name": "Python 3", |
| 242 | + "display_name": "dackar_libs", |
337 | 243 | "language": "python", |
338 | 244 | "name": "python3" |
339 | 245 | }, |
|
0 commit comments