Skip to content

Commit d4f4864

Browse files
authored
Merge pull request #22 from idaholab/wangc/causal_update
Causal Analysis Update
2 parents d979218 + 5bc5f87 commit d4f4864

22 files changed

+276
-2757
lines changed

examples/ER_schema_functionality_test.ipynb

Lines changed: 7 additions & 468 deletions
Large diffs are not rendered by default.

examples/PreprocessingDemo.ipynb

Lines changed: 26 additions & 328 deletions
Large diffs are not rendered by default.

examples/RuleBasedNLP.ipynb

Lines changed: 17 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
{
2020
"cell_type": "code",
21-
"execution_count": 1,
21+
"execution_count": null,
2222
"id": "0e32d652-af95-44d4-89a0-de554d2f33a2",
2323
"metadata": {},
2424
"outputs": [],
@@ -41,7 +41,7 @@
4141
},
4242
{
4343
"cell_type": "code",
44-
"execution_count": 2,
44+
"execution_count": null,
4545
"id": "4f0c40e5-bec7-4281-a313-80234c19b95f",
4646
"metadata": {},
4747
"outputs": [],
@@ -60,7 +60,7 @@
6060
},
6161
{
6262
"cell_type": "code",
63-
"execution_count": 3,
63+
"execution_count": null,
6464
"id": "fdd6ef86-ce41-4813-aba4-70af07693a9f",
6565
"metadata": {},
6666
"outputs": [],
@@ -78,12 +78,12 @@
7878
},
7979
{
8080
"cell_type": "code",
81-
"execution_count": 4,
81+
"execution_count": null,
8282
"id": "8126fb35-a9b1-45b1-b63d-b07b02e5dcf1",
8383
"metadata": {},
8484
"outputs": [],
8585
"source": [
86-
"from dackar.workflows.RuleBasedMatcher import RuleBasedMatcher\n",
86+
"from dackar.causal.CausalSentence import CausalSentence\n",
8787
"from dackar import config\n",
8888
"from dackar.utils.nlp.nlp_utils import generatePatternList"
8989
]
@@ -98,7 +98,7 @@
9898
},
9999
{
100100
"cell_type": "code",
101-
"execution_count": 5,
101+
"execution_count": null,
102102
"id": "2c0f142f-42fd-45c4-8389-1eeca5f8e8ce",
103103
"metadata": {},
104104
"outputs": [],
@@ -117,7 +117,7 @@
117117
},
118118
{
119119
"cell_type": "code",
120-
"execution_count": 6,
120+
"execution_count": null,
121121
"id": "31319bfe-c0b9-4e9f-9c1f-a52bfae36215",
122122
"metadata": {},
123123
"outputs": [],
@@ -142,7 +142,7 @@
142142
},
143143
{
144144
"cell_type": "code",
145-
"execution_count": 7,
145+
"execution_count": null,
146146
"id": "643de747-4981-4bdd-ab44-f4f1abb16f1a",
147147
"metadata": {},
148148
"outputs": [],
@@ -167,23 +167,13 @@
167167
},
168168
{
169169
"cell_type": "code",
170-
"execution_count": 8,
170+
"execution_count": null,
171171
"id": "8503b3c3-8a9e-4526-84b7-64cc8ccb9728",
172172
"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": [],
184174
"source": [
185175
"name = 'ssc_entity_ruler'\n",
186-
"matcher = RuleBasedMatcher(nlp, entID=entId, causalKeywordID=causalID)\n",
176+
"matcher = CausalSentence(nlp, entID=entId, causalKeywordID=causalID)\n",
187177
"matcher.addEntityPattern(name, patternsOPM)\n",
188178
"\n",
189179
"causalName = 'causal_keywords_entity_ruler'\n",
@@ -200,7 +190,7 @@
200190
},
201191
{
202192
"cell_type": "code",
203-
"execution_count": 9,
193+
"execution_count": null,
204194
"id": "e5ba4b71-c0ec-40dd-bcbb-51ce67de4b95",
205195
"metadata": {},
206196
"outputs": [],
@@ -220,35 +210,10 @@
220210
},
221211
{
222212
"cell_type": "code",
223-
"execution_count": 10,
213+
"execution_count": null,
224214
"id": "9cb4ae56-ea17-4289-b2c5-e3602ce4fd9f",
225215
"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": [],
252217
"source": [
253218
"matcher(doc)"
254219
]
@@ -263,77 +228,18 @@
263228
},
264229
{
265230
"cell_type": "code",
266-
"execution_count": 11,
231+
"execution_count": null,
267232
"id": "cdf032fd-3c88-46fc-9629-0762973669eb",
268233
"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": [],
329235
"source": [
330236
"matcher._extractedCausals"
331237
]
332238
}
333239
],
334240
"metadata": {
335241
"kernelspec": {
336-
"display_name": "Python 3",
242+
"display_name": "dackar_libs",
337243
"language": "python",
338244
"name": "python3"
339245
},

0 commit comments

Comments
 (0)