def test_analyze():

    config_entry = wh.ConfigurationEntity(id='test', type='test', uid=99)
    configs = [config_entry]

    allergy_annotator = wh.Annotator(name=wh.Name.ALLERGY)
    attr_detect_annotator = wh.Annotator(name=wh.Name.ATTRIBUTE_DETECTION)
    bathing_annotator = wh.Annotator(name=wh.Name.BATHING_ASSISTANCE)
    cancer_annotator = wh.Annotator(name=wh.Name.CANCER)
    concept_detect_annotator = wh.Annotator(name=wh.Name.CONCEPT_DETECTION)
    disambig_annotator = wh.Annotator(name=wh.Name.DISAMBIGUATION)
    dressing_annotator = wh.Annotator(name=wh.Name.DRESSING_ASSISTANCE)
    eating_annotator = wh.Annotator(name=wh.Name.EATING_ASSISTANCE)
    ef_annotator = wh.Annotator(name=wh.Name.EJECTION_FRACTION)
    hypothetical_annotator = wh.Annotator(name=wh.Name.HYPOTHETICAL)
    lab_value_annotator = wh.Annotator(name=wh.Name.LAB_VALUE)
    medication_annotator = wh.Annotator(name=wh.Name.MEDICATION)
    named_entities_annotator = wh.Annotator(name=wh.Name.NAMED_ENTITIES)
    negation_annotator = wh.Annotator(name=wh.Name.NEGATION)
    procedure_annotator = wh.Annotator(name=wh.Name.PROCEDURE)
    seeing_annotator = wh.Annotator(name=wh.Name.SEEING_ASSISTANCE)
    smoking_annotator = wh.Annotator(name=wh.Name.SMOKING)
    spelling_annotator = wh.Annotator(name=wh.Name.SPELL_CHECKER)
    symptom_disease_annotator = wh.Annotator(name=wh.Name.SYMPTOM_DISEASE)
    toileting_annotator = wh.Annotator(name=wh.Name.TOILETING_ASSISTANCE)
    walking_annotator = wh.Annotator(name=wh.Name.WALKING_ASSISTANCE)
    section = wh.Annotator(name=wh.Name.SECTION)
    model_broker = wh.Annotator(name=wh.Name.MODEL_BROKER)

    flow_entries = []
    flow_entries.append(wh.FlowEntry(allergy_annotator))
    flow_entries.append(wh.FlowEntry(attr_detect_annotator))
    flow_entries.append(wh.FlowEntry(bathing_annotator))
    flow_entries.append(wh.FlowEntry(cancer_annotator))
    flow_entries.append(wh.FlowEntry(concept_detect_annotator))
    flow_entries.append(wh.FlowEntry(disambig_annotator))
    flow_entries.append(wh.FlowEntry(dressing_annotator))
    flow_entries.append(wh.FlowEntry(eating_annotator))
    flow_entries.append(wh.FlowEntry(ef_annotator))
    flow_entries.append(wh.FlowEntry(hypothetical_annotator))
    flow_entries.append(wh.FlowEntry(lab_value_annotator))
    flow_entries.append(wh.FlowEntry(medication_annotator))
    flow_entries.append(wh.FlowEntry(named_entities_annotator))
    #    flow_entries.append(wh.FlowEntry(negation_annotator))
    flow_entries.append(wh.FlowEntry(procedure_annotator))
    flow_entries.append(wh.FlowEntry(seeing_annotator))
    flow_entries.append(wh.FlowEntry(smoking_annotator))
    flow_entries.append(wh.FlowEntry(spelling_annotator))
    flow_entries.append(wh.FlowEntry(symptom_disease_annotator))
    flow_entries.append(wh.FlowEntry(toileting_annotator))
    flow_entries.append(wh.FlowEntry(walking_annotator))
    flow_entries.append(wh.FlowEntry(section))
    flow_entries.append(wh.FlowEntry(model_broker))
    flow = wh.Flow(elements=flow_entries, async_=False)
    annotator_flow = wh.AnnotatorFlow(flow)

    containers = [wh.UnstructuredContainer(text=TEXT)]

    data = ACD.analyze(TEXT, flow)
    tuc.TestUnstructuredContainer.test_unstructured_container(data=data)
示例#2
0
def test_Annotator_model():
    annotator_data = wh.Annotator(name='concept_value')
    flow_data = wh.Flow()
    parameter_data = []
    configurations_data = []
    model = wh.Annotator(name='concept_value',
                         parameters=parameter_data,
                         configurations=configurations_data)
    assert model.__str__() is not None
def test_update_flow():
    test_elementList = []
    test_anno = wh.Annotator(name = 'concept_detection')
    test_flowEntry = wh.FlowEntry(annotator=test_anno)
    test_elementList.append(test_flowEntry)
    test_flow = wh.Flow(elements = test_elementList, async_ = True)
    test_annoFlow = wh.AnnotatorFlow(flow = test_flow)
    test_annoFlows = []
    test_annoFlows.append(test_annoFlow)
    response = ACD.update_flows(id = "unittest_new_flow", new_id = "unittest_new_flow", new_name = 'test flow',
                                         new_description = 'functional test flow', new_annotator_flows = test_annoFlows)
    assert response is not None
def test_create_flow():
    test_elementList = []
    test_anno = wh.Annotator(name = 'concept_detection', parameters = {"include_optional_fields": ["medical_codes", "source_vocabularies"]})
    test_flowEntry = wh.FlowEntry(annotator=test_anno)
    test_elementList.append(test_flowEntry)
    test_flow = wh.Flow(elements = test_elementList, async_ = False)
    test_annoFlow = wh.AnnotatorFlow(flow = test_flow)
    test_annoFlows = []
    test_annoFlows.append(test_annoFlow)
    try:
        response = ACD.create_flows(new_id = 'unittest_new_flow', new_name = 'test flow',
                              new_description = 'functional test flow', new_annotator_flows = test_annoFlows)
        assert response is not None
    except wh.ACDException as acde:
        # flow already exists - previous delete must have failed
        assert acde.code == 409
示例#5
0
def test_analyze_org():

    config_entry = wh.ConfigurationEntity(id='test', type='test', uid=99)
    configs = [config_entry]

    allergy_annotator = wh.Annotator(name=wh.Name.ALLERGY)
    attr_detect_annotator = wh.Annotator(name=wh.Name.ATTRIBUTE_DETECTION)
    bathing_annotator = wh.Annotator(name=wh.Name.BATHING_ASSISTANCE)
    cancer_annotator = wh.Annotator(name=wh.Name.CANCER)
    concept_detect_annotator = wh.Annotator(name=wh.Name.CONCEPT_DETECTION)
    disambig_annotator = wh.Annotator(name=wh.Name.DISAMBIGUATION)
    dressing_annotator = wh.Annotator(name=wh.Name.DRESSING_ASSISTANCE)
    eating_annotator = wh.Annotator(name=wh.Name.EATING_ASSISTANCE)
    ef_annotator = wh.Annotator(name=wh.Name.EJECTION_FRACTION)
    hypothetical_annotator = wh.Annotator(name=wh.Name.HYPOTHETICAL)
    lab_value_annotator = wh.Annotator(name=wh.Name.LAB_VALUE)
    medication_annotator = wh.Annotator(name=wh.Name.MEDICATION)
    named_entities_annotator = wh.Annotator(name=wh.Name.NAMED_ENTITIES)
    negation_annotator = wh.Annotator(name=wh.Name.NEGATION)
    procedure_annotator = wh.Annotator(name=wh.Name.PROCEDURE)
    seeing_annotator = wh.Annotator(name=wh.Name.SEEING_ASSISTANCE)
    smoking_annotator = wh.Annotator(name=wh.Name.SMOKING)
    spelling_annotator = wh.Annotator(name=wh.Name.SPELL_CHECKER)
    symptom_disease_annotator = wh.Annotator(name=wh.Name.SYMPTOM_DISEASE)
    toileting_annotator = wh.Annotator(name=wh.Name.TOILETING_ASSISTANCE)
    walking_annotator = wh.Annotator(name=wh.Name.WALKING_ASSISTANCE)
    section = wh.Annotator(name=wh.Name.SECTION)

    flow_entries = []
    flow_entries.append(wh.FlowEntry(allergy_annotator))
    flow_entries.append(wh.FlowEntry(attr_detect_annotator))
    flow_entries.append(wh.FlowEntry(bathing_annotator))
    flow_entries.append(wh.FlowEntry(cancer_annotator))
    flow_entries.append(wh.FlowEntry(concept_detect_annotator))
    flow_entries.append(wh.FlowEntry(disambig_annotator))
    flow_entries.append(wh.FlowEntry(dressing_annotator))
    flow_entries.append(wh.FlowEntry(eating_annotator))
    flow_entries.append(wh.FlowEntry(ef_annotator))
    flow_entries.append(wh.FlowEntry(hypothetical_annotator))
    flow_entries.append(wh.FlowEntry(lab_value_annotator))
    flow_entries.append(wh.FlowEntry(medication_annotator))
    flow_entries.append(wh.FlowEntry(named_entities_annotator))
    flow_entries.append(wh.FlowEntry(negation_annotator))
    flow_entries.append(wh.FlowEntry(procedure_annotator))
    flow_entries.append(wh.FlowEntry(seeing_annotator))
    flow_entries.append(wh.FlowEntry(smoking_annotator))
    flow_entries.append(wh.FlowEntry(spelling_annotator))
    flow_entries.append(wh.FlowEntry(symptom_disease_annotator))
    flow_entries.append(wh.FlowEntry(toileting_annotator))
    flow_entries.append(wh.FlowEntry(walking_annotator))
    flow_entries.append(wh.FlowEntry(section))

    flow = wh.Flow(elements=flow_entries, async_=False)
    annotator_flow = wh.AnnotatorFlow(flow=flow)

    containers = [wh.UnstructuredContainer(text=TEXT)]
    flows = [annotator_flow]

    response = ACD.analyze_org(containers, flows)
    container_group = wh.ContainerGroup._from_dict(response.get_result())

    for unstructured_container in container_group.unstructured:
        if unstructured_container.text is not None:
            assert unstructured_container.text == TEXT
        if unstructured_container.id is not None:
            assert unstructured_container.id != '0'
        if unstructured_container.type is not None:
            assert unstructured_container.type != 'bogus'

        assert unstructured_container.data is not None
        tuc.TestUnstructuredContainer.test_unstructured_container(
            data=unstructured_container.data)
def test_Flow_model():
    flowentry_data = wh.FlowEntry()
    model = wh.Flow(elements=[flowentry_data])
    assert model.__str__() is not None
示例#7
0
def test_AcdFlow_model():
    annotator_flows_list = wh.AnnotatorFlow(wh.Flow())
    model = wh.AcdFlow(id="id", name="name", description="describe", annotator_flows=[annotator_flows_list])
    assert model.__str__() is not None
def test_AnnotatorFlow_model():
    flow_data = wh.Flow()
    model = wh.AnnotatorFlow(profile="mine", flow=flow_data)
    assert model.__str__() is not None