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)
Beispiel #2
0
def test_analyze_flow_request_list():
    container = [wh.UnstructuredContainer(TEXT)]
    container_group = ACD.analyze_with_flow(FLOW, container)

    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_UnstructuredContainer_model():
    container_annotation = wh.ContainerAnnotation()
    metadata_dict = {}
    model = wh.UnstructuredContainer(text="text", id="id", type="type", data=container_annotation,
                                     metadata=metadata_dict, uid=1)
    assert model.__str__() is not None
def test_analyze_flow_container():
    container = wh.UnstructuredContainer(TEXT)
    data = ACD.analyze_with_flow(FLOW, container)
    tuc.TestUnstructuredContainer.test_unstructured_container(data=data)
Beispiel #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)