Example #1
0
 inputs=[
     labels(name='sentences',
            reference='biomedicus-sentences/sentences'),
     labels(name='umls_terms',
            reference='biomedicus-concepts/umls_terms',
            name_from_parameter='terms_index'),
     labels("negation_triggers",
            reference='biomedicus-negex-triggers')
 ],
 outputs=[
     labels(
         name='dependencies',
         description="The dependent words.",
         properties=[
             label_property('deprel',
                            description="The dependency relation",
                            data_type='str'),
             label_property(
                 'head',
                 description=
                 "The head of this label or null if its the root.",
                 nullable=True,
                 data_type='ref:dependencies'),
             label_property(
                 'dependents',
                 description="The dependents of ths dependent.",
                 data_type='list[ref:dependencies]')
         ]),
     labels(name='upos_tags',
            description="Universal Part-of-speech tags",
            properties=[
Example #2
0
from mtap.processing import DocumentProcessor, _runners
from mtap.processing.descriptions import parameter, labels, label_property
from mtap.processing._service import _ProcessorServicer


@processor('mtap-test-processor',
           description='Processor desc.',
           parameters=[
               parameter('a_param',
                         required=True,
                         data_type='bool',
                         description="desc.")
           ],
           inputs=[
               labels('input_index',
                      properties=[label_property('bar', data_type='bool')])
           ],
           outputs=[
               labels('output_index',
                      description='desc.',
                      properties=[
                          label_property('foo',
                                         data_type='str',
                                         nullable=True,
                                         description='A label property.')
                      ])
           ])
class ExampleTestProcessor(DocumentProcessor):
    def process_document(self, document: Document, params: Dict[str, Any]):
        pass
Example #3
0
        )
    ],
    inputs=[
        label_index(name='sentences',
                    reference='biomedicus-sentences/sentences'),
        label_index(name='umls_terms',
                    reference='biomedicus-concepts/umls_terms',
                    name_from_parameter='terms_index')
    ],
    outputs=[
        label_index("negation_trigger",
                    description="Spans of phrases that trigger negation.",
                    properties=[
                        label_property(
                            "tags",
                            data_type='List[str]',
                            description='The tags that apply to the trigger, '
                            'for example: POST PREN')
                    ])
    ])
class NegexTriggersProcessor(DocumentProcessor):
    def __init__(self):
        self.negex = NegexTriggerTagger()

    def process_document(self, document: Document, params: Dict[str, Any]):
        label_trigger = document.get_labeler('negation_triggers')
        with label_trigger:
            for sentence in document.get_label_index('sentences'):
                triggers = self.negex.detect_negex_triggers(sentence.text)
                for start_index, end_index, tags in triggers:
                    label_trigger(sentence.start_index + start_index,
Example #4
0
@mtap.processor(
    'mtap-example-processor-python',
    human_name="Python Example Processor",
    description=
    "counts the number of times the letters a and b occur in a document",
    parameters=[
        parameter('do_work',
                  required=True,
                  data_type='bool',
                  description="Whether the processor should do anything.")
    ],
    outputs=[
        label_index('mtap.examples.letter_counts',
                    properties=[
                        label_property('letter', data_type='str'),
                        label_property('count', data_type='int')
                    ])
    ])
class ExampleProcessor(DocumentProcessor):
    """Does some labeling of the counts of the letter 'a' and 'b' in a document.
    """
    def process_document(self, document: Document,
                         params: Dict[str, Any]) -> Optional[Dict[str, Any]]:
        if params['do_work']:
            with self.started_stopwatch('fetch_time'):
                text = document.text

            a_count = text.count('a')
            b_count = text.count('b')