Ejemplo n.º 1
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_profile():
    test_annoList = []
    test_anno = wh.Annotator(name = "concept_detection")
    test_annoList.append(test_anno)
    response = ACD.update_profile(id = 'unittest_new_profile', new_id = 'unittest_new_profile', new_name = 'test profile',
                              new_description = 'updated functional test profile', new_annotators = test_annoList)
    assert response is not None
def test_create_profile():
    test_annoList = []
    test_anno = wh.Annotator(name = "concept_detection")
    test_annoList.append(test_anno)
    try:
        response = ACD.create_profile(new_id = 'unittest_new_profile', new_name = 'test profile',
                              new_description = 'functional test profile', new_annotators = test_annoList)
        assert response is not None
    except wh.ACDException as acde:
        # flow already exists - previous delete must have failed
        assert acde.code == 409
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
def test_FlowEntry_model():
    annotator_data = wh.Annotator('concept_detection')
    model = wh.FlowEntry(annotator=annotator_data)
    assert model.__str__() is not None
def test_analyze_text_array():

    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)]

    container_group = ACD.analyze([TEXT], flow)

    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)