# In[1]:

import pyConTextNLP.pyConText as pyConText
# itemData has been rewritten, so that it can take relative local path, where you can redirect it to your customized yml files later
import os
import itemData
import re
import glob
import pandas as pd
from xml.etree import ElementTree
import math

# In[2]:

my_targets = itemData.get_items('Yaml_Files/A1c_targets.yml')
my_modifiers = itemData.get_items('Yaml_Files/A1c_modifiers.yml')

# The functions *markup_sentence* and *markup_doc* were both ones that we went over in the NLP lab.

# In[3]:


## This one is the same, it just doesn't split it into sentences.
def markup_sentence(s, modifiers, targets, prune_inactive=True):
    """
    """
    markup = pyConText.ConTextMarkup()
    markup.setRawText(s)
    markup.cleanText()
    markup.markItems(my_modifiers, mode="modifier")
from xml.etree import ElementTree
import math

# Set distance for each modification type
distance_negation = 40
distance_other = 40
distance_hypothetical = 70
distance_type = 70

# In[2]:

os.listdir('Yaml_Files')

# In[3]:

my_targets = itemData.get_items('Yaml_Files/Diabetes_targets.yml')
my_modifiers = itemData.get_items('Yaml_Files/Diabetes_modifiers.yml')

# The functions *markup_sentence* and *markup_doc* were both ones that we went over in the NLP lab.

# In[4]:


## This one is the same, it just doesn't split it into sentences.
def markup_sentence(s, modifiers, targets, prune_inactive=True):
    """
    """
    markup = pyConText.ConTextMarkup()
    markup.setRawText(s)
    markup.cleanText()
    markup.markItems(my_modifiers, mode="modifier")
Exemplo n.º 3
0
 def read_context_types(self, context_file):
     context_types = set()
     for context_item in get_items(context_file):
         for type in context_item.getCategory():
             context_types.add(type)
     return self.gen_relation_def(context_types)
Exemplo n.º 4
0
# %%
from visual import Vis, view_pycontext_output
import pyConTextNLP.pyConText as pyConText
import itemData
modifiers = itemData.get_items(
    'https://raw.githubusercontent.com/chapmanbe/pyConTextNLP/master/KB/pneumonia_modifiers.yml'
)
targets = itemData.get_items(
    "https://raw.githubusercontent.com/chapmanbe/pyConTextNLP/master/KB/pneumonia_targets.yml"
)


def markup_sentence(s, modifiers, targets, prune_inactive=True):
    """
    """
    markup = pyConText.ConTextMarkup()
    markup.setRawText(s)
    markup.cleanText()
    markup.markItems(modifiers, mode="modifier")
    markup.markItems(targets, mode="target")
    markup.pruneMarks()
    markup.dropMarks('Exclusion')
    # apply modifiers to any targets within the modifiers scope
    markup.applyModifiers()
    markup.pruneSelfModifyingRelationships()
    if prune_inactive:
        markup.dropInactiveModifiers()
    return markup


def markup_doc(doc_text: str):