diff --git a/dictionaries/postprocessing-and-lexical-rules-matching/stop_words_anatomy.lst b/dictionaries/postprocessing-and-lexical-rules-matching/stop_words_anatomy.lst index ce73d36e574abec0fa01b8c055569aa46ee4370c..42c292bad7416af304dd4726843b09a8641fbf44 100644 --- a/dictionaries/postprocessing-and-lexical-rules-matching/stop_words_anatomy.lst +++ b/dictionaries/postprocessing-and-lexical-rules-matching/stop_words_anatomy.lst @@ -2,4 +2,7 @@ liver weight general body weigh body weight -weight \ No newline at end of file +weight +animal +animals +da \ No newline at end of file diff --git a/jape_rules/limtox-hepatoxicity-dictionaries/basic_mapping.jape b/jape_rules/limtox-hepatoxicity-dictionaries/basic_mapping.jape index 18d0c04f9c38fd9d5c8e864b4c4939aee17d7790..83a4aa9845d42eb5dcffe2aa9f455254c2f0d5c9 100644 --- a/jape_rules/limtox-hepatoxicity-dictionaries/basic_mapping.jape +++ b/jape_rules/limtox-hepatoxicity-dictionaries/basic_mapping.jape @@ -1,3 +1,6 @@ +Imports: { +import static gate.Utils.*; +} Phase:firstphase Input: Lookup Options: control = appelt @@ -14,6 +17,8 @@ Rule: basic_mapp FeatureMap lookupFeatures = ann.getFeatures(); gate.FeatureMap features = Factory.newFeatureMap(); features.putAll(lookupFeatures); + String content = stringFor(doc, ann); + features.put("text",content); String mayorType = features.get("majorType").toString(); String minorType = features.get("minorType").toString(); gate.AnnotationSet tokens = outputAS.get("Token", ann.getStartNode().getOffset(), ann.getEndNode().getOffset()); diff --git a/jape_rules/main.jape b/jape_rules/main.jape index 3710fa3613291f0e788dc12f2527d16213833a9b..db3cf7889f845236a4fac3ffcfbeddea59734bd3 100644 --- a/jape_rules/main.jape +++ b/jape_rules/main.jape @@ -23,7 +23,7 @@ postprocessing-and-lexical-rules-matching/merge_annotations postprocessing-and-lexical-rules-matching/merge_hepatotoxicity postprocessing-and-lexical-rules-matching/merge_livermarker postprocessing-and-lexical-rules-matching/remove_study_domain -postprocessing-and-lexical-rules-matching/remove_manifestation_findings_false_positive_dose +postprocessing-and-lexical-rules-matching/dose_qualification_rule postprocessing-and-lexical-rules-matching/remove_manifestation_findings_false_positive_no_finding postprocessing-and-lexical-rules-matching/study_testcd_manifestation_finding postprocessing-and-lexical-rules-matching/study_testcd_over_finding @@ -33,4 +33,7 @@ postprocessing-and-lexical-rules-matching/add_lemma_to_annotations postprocessing-and-lexical-rules-matching/CV_activity_study_testcd postprocessing-and-lexical-rules-matching/CHANGE_manifestation_specimen postprocessing-and-lexical-rules-matching/negation_finding +relation-extraction/dose_sex +relation-extraction/dose_sex_multi +relation-extraction/finding_dose_sex delete_lookups \ No newline at end of file diff --git a/jape_rules/postprocessing-and-lexical-rules-matching/CHANGE_manifestation_specimen.jape b/jape_rules/postprocessing-and-lexical-rules-matching/CHANGE_manifestation_specimen.jape index b38d29bd7dad2d1f80e64f9de1f3a3a0b9183733..3b1bd916d93023503c3ade7c7223685a3ba08e0a 100644 --- a/jape_rules/postprocessing-and-lexical-rules-matching/CHANGE_manifestation_specimen.jape +++ b/jape_rules/postprocessing-and-lexical-rules-matching/CHANGE_manifestation_specimen.jape @@ -21,6 +21,8 @@ Rule: study_test_cd System.out.println(stringFor(doc, sentence)); try{ gate.FeatureMap features = Factory.newFeatureMap(); + String content = stringFor(doc, lookup.firstNode().getOffset(),lookup.lastNode().getOffset()); + features.put("text",content); features.put("rule", "change_specimen"); outputAS.add(lookup.firstNode().getOffset(),lookup.lastNode().getOffset(), "FINDING", features); }catch(InvalidOffsetException e){ diff --git a/jape_rules/postprocessing-and-lexical-rules-matching/CV_activity_study_testcd.jape b/jape_rules/postprocessing-and-lexical-rules-matching/CV_activity_study_testcd.jape index d0d4942e880cbf6891bdab6182bcc387e06d5652..80a4322c56a109df2edd7c4cf938b6204ccc316a 100644 --- a/jape_rules/postprocessing-and-lexical-rules-matching/CV_activity_study_testcd.jape +++ b/jape_rules/postprocessing-and-lexical-rules-matching/CV_activity_study_testcd.jape @@ -19,11 +19,14 @@ Rule: study_test_cd //System.out.println(stringFor(doc, sentence)); try{ gate.FeatureMap features = Factory.newFeatureMap(); + String content = stringFor(doc, lookup.firstNode().getOffset(),lookup.lastNode().getOffset()); + features.put("text",content); features.put("rule", "activity_cv"); features.put("CDISC_SEND_CODE", "ACTIVITY"); features.put("CDISC_CODELIST", "SCVTSTCD"); features.put("CDISC_SEND_CODE_ID", "C120914"); features.put("CDISC_CODELIST_ID", "C120532"); + features.put("CDISC_SEND_DOMAIN_CODE", "CV"); outputAS.add(lookup.firstNode().getOffset(),lookup.lastNode().getOffset(), "STUDY_TESTCD", features); }catch(InvalidOffsetException e){ throw new LuckyException(e); diff --git a/jape_rules/postprocessing-and-lexical-rules-matching/dose_qualification_rule.jape b/jape_rules/postprocessing-and-lexical-rules-matching/dose_qualification_rule.jape new file mode 100644 index 0000000000000000000000000000000000000000..a4ddf3fd09c4ce3aa50d60b42d2d05fa6ac72471 --- /dev/null +++ b/jape_rules/postprocessing-and-lexical-rules-matching/dose_qualification_rule.jape @@ -0,0 +1,36 @@ +Imports: { +import static gate.Utils.*; +} +Phase:secondphase +Input: MANIFESTATION_FINDING Token +Options: control = all +Rule: dose_rule_match +( +{MANIFESTATION_FINDING} +({Token.word=~"[Dd]ose"} | {Token.word=~"[Dd]osages"} | {Token.word=~"[Dd]ose-dependently"} ) +) +:dose_rule_match +--> +{ + gate.AnnotationSet lookup = (gate.AnnotationSet) bindings.get("dose_rule_match"); + String content = stringFor(doc, lookup.firstNode().getOffset(),lookup.lastNode().getOffset()); + try{ + gate.FeatureMap features = Factory.newFeatureMap(); + + //System.out.println("ACA HAY UN MANIFESTATION_FINDING Y DOSE"); + for (Annotation ann : lookup){ + if(ann.getType().equals("MANIFESTATION_FINDING")){ + features.put("qualification",ann.getFeatures().get("text")); + outputAS.remove(ann); + } + } + + features.put("text",content); + features.put("rule", "dose_rule_match"); + outputAS.add(lookup.firstNode().getOffset(),lookup.lastNode().getOffset(), "DOSE_QUALIFICATION", features); + }catch(InvalidOffsetException e){ + throw new LuckyException(e); + } + + +} diff --git a/jape_rules/postprocessing-and-lexical-rules-matching/main.jape b/jape_rules/postprocessing-and-lexical-rules-matching/main.jape deleted file mode 100644 index ea458a48fe8c2fbc0dfd49b6ad8b8d6b8234d692..0000000000000000000000000000000000000000 --- a/jape_rules/postprocessing-and-lexical-rules-matching/main.jape +++ /dev/null @@ -1,22 +0,0 @@ -MultiPhase: Main -Phases: -remove_dnorm_false_positives -stop_words -remove_stop_words_finding -remove_stop_words_anatomy -omim_clean -clean_short_words -merge_annotations -merge_hepatotoxicity -merge_livermarker -remove_study_domain -remove_manifestation_findings_false_positive_dose -remove_manifestation_findings_false_positive_no_finding -study_testcd_manifestation_finding -study_testcd_over_finding -remove_finding_given_manifestation_and_study_testcd -doses_over_study_testcd -add_lemma_to_annotations -CV_activity_study_testcd -CHANGE_manifestation_specimen -negation_finding \ No newline at end of file diff --git a/jape_rules/postprocessing-and-lexical-rules-matching/merge_hepatotoxicity.jape b/jape_rules/postprocessing-and-lexical-rules-matching/merge_hepatotoxicity.jape index 46200b8e7049eaeeb78edf2b634ffa5a2d6125b0..a6e65a548ec2d16c9139e11a43c031f2d4b4fec0 100644 --- a/jape_rules/postprocessing-and-lexical-rules-matching/merge_hepatotoxicity.jape +++ b/jape_rules/postprocessing-and-lexical-rules-matching/merge_hepatotoxicity.jape @@ -49,6 +49,7 @@ Rule: merge_hepatotoxicity features.put("LIMTOX_HEPATOTOXICITY","YES"); try{ features.put("SOURCES","LIMTOX"); + features.put("text",content); features.remove("SOURCE"); outputAS.add(lookup.firstNode().getOffset(),lookup.lastNode().getOffset(),"FINDING", features); }catch(InvalidOffsetException e){ diff --git a/jape_rules/postprocessing-and-lexical-rules-matching/remove_manifestation_findings_false_positive_dose.jape b/jape_rules/postprocessing-and-lexical-rules-matching/remove_manifestation_findings_false_positive_dose.jape deleted file mode 100644 index 67ff77d500094a0e8610add2d6a169655be53ed7..0000000000000000000000000000000000000000 --- a/jape_rules/postprocessing-and-lexical-rules-matching/remove_manifestation_findings_false_positive_dose.jape +++ /dev/null @@ -1,22 +0,0 @@ -Imports: { -import static gate.Utils.*; -} -Phase:secondphase -Input: MANIFESTATION_FINDING Token -Options: control = all -Rule: delete_rule -( -{MANIFESTATION_FINDING} -({Token.word=~"[Dd]ose"} | {Token.word=~"[Dd]osages"} | {Token.word=~"[Dd]ose-dependently"} ) -) -:manifestation_dose ---> -{ - gate.AnnotationSet lookup = (gate.AnnotationSet) bindings.get("manifestation_dose"); - //System.out.println("ACA HAY UN MANIFESTATION_FINDING Y DOSE"); - for (Annotation ann : lookup){ - if(ann.getType().equals("MANIFESTATION_FINDING")){ - outputAS.remove(ann); - } - } -} diff --git a/jape_rules/relation-extraction/dose_sex.jape b/jape_rules/relation-extraction/dose_sex.jape new file mode 100644 index 0000000000000000000000000000000000000000..e4f1c81e881d03f3e4ce02e2cccd92668f4fdb32 --- /dev/null +++ b/jape_rules/relation-extraction/dose_sex.jape @@ -0,0 +1,30 @@ +//this rule generate the dose sex entity +Imports: { +import static gate.Utils.*; +} +Phase:secondphase +Input: Token SEX DOSE +Options: control = appelt +Rule: dose_sex_rule +( +({DOSE} {SEX}) +) :dose_sex_rule +--> +{ + + gate.AnnotationSet lookup = (gate.AnnotationSet) bindings.get("dose_sex_rule"); + gate.Annotation ann = (gate.Annotation) lookup.iterator().next(); + gate.AnnotationSet sentence_set = outputAS.get("Sentence",ann.getStartNode().getOffset(), ann.getEndNode().getOffset()); + gate.Annotation sentence = sentence_set.iterator().next(); + System.out.println("dose_sex_rule"); + System.out.println(stringFor(doc, sentence)); + try{ + gate.FeatureMap features = Factory.newFeatureMap(); + String content = stringFor(doc, lookup.firstNode().getOffset(),lookup.lastNode().getOffset()); + features.put("text",content); + features.put("rule", "dose_sex_rule"); + outputAS.add(lookup.firstNode().getOffset(),lookup.lastNode().getOffset(), "DOSE_SEX", features); + }catch(InvalidOffsetException e){ + throw new LuckyException(e); + } +} \ No newline at end of file diff --git a/jape_rules/relation-extraction/dose_sex_multi.jape b/jape_rules/relation-extraction/dose_sex_multi.jape new file mode 100644 index 0000000000000000000000000000000000000000..72a90a3cce955e0b2e9083ad6cf8f07513c31915 --- /dev/null +++ b/jape_rules/relation-extraction/dose_sex_multi.jape @@ -0,0 +1,30 @@ +//this rule generate the dose sex entity multiple with an and +Imports: { +import static gate.Utils.*; +} +Phase:secondphase +Input: Token DOSE_SEX +Options: control = appelt +Rule: dose_sex_multi_rule +( +({DOSE_SEX}) (({Token})[0,3] {Token.root=="and"} ({Token})[0,3] {DOSE_SEX}) +) :dose_sex_multi_rule +--> +{ + + gate.AnnotationSet lookup = (gate.AnnotationSet) bindings.get("dose_sex_multi_rule"); + gate.Annotation ann = (gate.Annotation) lookup.iterator().next(); + gate.AnnotationSet sentence_set = outputAS.get("Sentence",ann.getStartNode().getOffset(), ann.getEndNode().getOffset()); + gate.Annotation sentence = sentence_set.iterator().next(); + System.out.println("dose_sex_multi_rule"); + System.out.println(stringFor(doc, sentence)); + try{ + gate.FeatureMap features = Factory.newFeatureMap(); + String content = stringFor(doc, lookup.firstNode().getOffset(),lookup.lastNode().getOffset()); + features.put("text",content); + features.put("rule", "dose_sex_multi_rule"); + outputAS.add(lookup.firstNode().getOffset(),lookup.lastNode().getOffset(), "DOSE_SEX_MULTI", features); + }catch(InvalidOffsetException e){ + throw new LuckyException(e); + } +} \ No newline at end of file diff --git a/jape_rules/relation-extraction/finding_dose_sex.jape b/jape_rules/relation-extraction/finding_dose_sex.jape new file mode 100644 index 0000000000000000000000000000000000000000..56b9dd27a3e791dedb0a22067c51e2d9d9d6aac7 --- /dev/null +++ b/jape_rules/relation-extraction/finding_dose_sex.jape @@ -0,0 +1,48 @@ +//this rule generate the relations between the finding and the dose sex entities +Imports: { +import static gate.Utils.*; +} +Phase:secondphase +Input: Token DOSE_SEX DOSE_SEX_MULTI FINDING STUDY_TESTCD +Options: control = appelt +Rule: finding_dose_sex_rule +( +({FINDING} | {STUDY_TESTCD}) (({Token})[0,5] {Token.pos=="IN"} ({Token})[0,3] ({DOSE_SEX} | {DOSE_SEX_MULTI})) +) :finding_dose_sex_rule +--> +{ + gate.AnnotationSet lookup = (gate.AnnotationSet) bindings.get("finding_dose_sex_rule"); + gate.Annotation ann = (gate.Annotation) lookup.iterator().next(); + gate.AnnotationSet sentence_set = outputAS.get("Sentence",ann.getStartNode().getOffset(), ann.getEndNode().getOffset()); + gate.Annotation sentence = sentence_set.iterator().next(); + System.out.println("finding_dose_sex_rule"); + System.out.println(stringFor(doc, sentence)); + try{ + gate.AnnotationSet finding_entity = lookup.get("FINDING"); + gate.AnnotationSet study_entity = lookup.get("STUDY_TESTCD"); + gate.AnnotationSet dose_sex_entity = lookup.get("DOSE_SEX"); + gate.AnnotationSet dose_sex_multi_entity = lookup.get("DOSE_SEX_MULTI"); + if(finding_entity!=null && finding_entity.size()>0){ + System.out.println("finding_dose_sex_rule_1"); + if(dose_sex_entity!=null && dose_sex_entity.size()>0){ + finding_entity.iterator().next().getFeatures().put("DOSE_SEX", dose_sex_entity.iterator().next().getId()); + }else if(dose_sex_multi_entity!=null && dose_sex_multi_entity.size()>0){ + finding_entity.iterator().next().getFeatures().put("DOSE_SEX_MULTI", dose_sex_multi_entity.iterator().next().getId()); + } + }else if(study_entity!=null && study_entity.size()>0){ + System.out.println("finding_dose_sex_rule_2"); + if(dose_sex_entity!=null && dose_sex_entity.size()>0){ + study_entity.iterator().next().getFeatures().put("DOSE_SEX", dose_sex_entity.iterator().next().getId()); + }else if(dose_sex_multi_entity!=null && dose_sex_multi_entity.size()>0){ + study_entity.iterator().next().getFeatures().put("DOSE_SEX_MULTI", dose_sex_multi_entity.iterator().next().getId()); + } + } + gate.FeatureMap features = Factory.newFeatureMap(); + String content = stringFor(doc, lookup.firstNode().getOffset(),lookup.lastNode().getOffset()); + features.put("text",content); + features.put("rule", "finding_dose_sex_rule"); + outputAS.add(lookup.firstNode().getOffset(),lookup.lastNode().getOffset(), "FINDING_DOSE_SEX", features); + }catch(InvalidOffsetException e){ + throw new LuckyException(e); + } +} \ No newline at end of file diff --git a/jape_rules/relation-extraction/sex.jape b/jape_rules/relation-extraction/sex.jape new file mode 100644 index 0000000000000000000000000000000000000000..493aaa373463ecb297d986fb47564baf6965fe2a --- /dev/null +++ b/jape_rules/relation-extraction/sex.jape @@ -0,0 +1,30 @@ +//this rule generate the relations between the finding and the sex +Imports: { +import static gate.Utils.*; +} +Phase:secondphase +Input: Token Sentence SEX FINDING STUDY_TESTCD +Options: control = appelt +Rule: sex_rule +( +({STUDY_TESTCD} | {FINDING}) (({Token})[0,20] {Token.pos=="IN"} ({Token})[0,3] {SEX}) +) :sex_rule +--> +{ + + gate.AnnotationSet lookup = (gate.AnnotationSet) bindings.get("sex_rule"); + gate.Annotation ann = (gate.Annotation) lookup.iterator().next(); + gate.AnnotationSet sentence_set = outputAS.get("Sentence",ann.getStartNode().getOffset(), ann.getEndNode().getOffset()); + gate.Annotation sentence = sentence_set.iterator().next(); + System.out.println("sex_rule"); + System.out.println(stringFor(doc, sentence)); + try{ + gate.FeatureMap features = Factory.newFeatureMap(); + String content = stringFor(doc, lookup.firstNode().getOffset(),lookup.lastNode().getOffset()); + features.put("text",content); + features.put("rule", "change_specimen"); + outputAS.add(lookup.firstNode().getOffset(),lookup.lastNode().getOffset(), "FINDING_SEX", features); + }catch(InvalidOffsetException e){ + throw new LuckyException(e); + } +} \ No newline at end of file