Пример #1
0
 def start(self):
     cr = ConfigReader()
     self.workflow = Workflow([
         IntroStep(
             '<h2>Welcome to SmartAnno!</h2><h4>Do you want to start from beginning or continue previous reviewing? </h4>',
             name='intro'),
         DBInitiater(name='db_initiator'),
         DirChooser(name='choosedir'),
         ReadFiles(name='readfiles'),
         DocsToDB(name='save2db'),
         TaskChooser(name='tasknamer'),
         DataSetChooser(
             name='dataset_chooser',
             description='<h4>Choose which dateaset you want to use: </h4>'
         ),
         AnnotationTypeDef(
             '<h3>Annotation types:</h3><p>List all the types you want to identify below. Each type per line.<br/>If you'
             'have too many types, try set up them separately, so that you won&apos;t need to choose from a long list '
             'for each sample. </p>',
             name='types'),
         KeywordsFiltering(name='keywords'),
         # PreviousNextIntSlider(value=60, min=0, max=100, step=10,
         #                       description='<h4>Percentage to Filter: </h4><p>Choose how many percent of the samples '
         #                                   'you want to use the keywords filter.</p>', name='percent2filter'),
         KeywordsUMLSExtenderSetup(name='umls_extender_setup'),
         KeywordsUMLSExtender(
             name='umls_extender',
             sources=cr.getValue("umls/sources"),
             filter_by_length=cr.getValue("umls/filter_by_length"),
             filter_by_contains=cr.getValue("umls/filter_by_contains"),
             max_query=cr.getValue("umls/max_query")),
         KeywordsEmbeddingExtenderSetup(name='w_e_extender_setup'),
         KeywordsEmbeddingExtender(name='w_e_extender', max_query=40),
         ReviewRBInit(name="rb_review_init"),
         ReviewRBLoop(name='rb_review'),
         PreviousNextHTML(
             description=
             '<h2>Congratuations!</h2><h4>You have finished the initial review '
             'on the rule-base preannotations. </h4>',
             name='rb_review_done'),
         ReviewMLInit(name='ml_review_init'),
         ReviewMLLoop(name='ml_review',
                      ml_classifier_cls=self.ml_classifier_cls),
         PreviousNextHTML(
             name='finish',
             description=
             '<h3>Well done!</h3><h4>Now you have finished reviewing all the samples. '
         )
     ])
     self.workflow.start(False)
     pass
Пример #2
0
    def testRBLoop(self):
        logging.getLogger().setLevel(logging.WARN)

        ConfigReader()
        wf = Workflow()
        rb = ReviewRBInit(name="rb_review_init")
        wf.append(rb)
        rv = ReviewRBLoop(name='rb_review')
        wf.append(rv)
        wf.append(
            PreviousNextHTML(
                '<h2>Welcome to SmartAnno!</h2><h4>First, let&apos;s import txt data from a directory. </h4>',
                name='intro'))

        wf.filters = {'TypeA': ['heart'], 'TypeB': ['exam']}
        wf.types = ['TypeA', 'TypeB']
        wf.task_id = 1
        wf.umls_extended = {}
        wf.we_extended = {}
        wf.dao = Dao('sqlite+pysqlite:///data/demo.sqlite',
                     sqlalchemy_dao.POOL_DISABLED)
        wf.start()
        if len(rb.branch_buttons) == 0:
            # if no records in the db, the optional buttons won't show
            rb.sample_size_input.value = 3
            rb.complete()
            wf.start()
        print([doc.DOC_ID for doc in rb.data['docs']])
        print([
            anno.REVIEWED_TYPE for anno in wf.steps[0].data['annos'].values()
        ])
        rb.sample_size_input.value = 1
        rb.navigate(rb.branch_buttons[1])
        pass
wf.task_name = 'language'
wf.append(
    AnnotationTypeDef(
        '<h3>Annotation types:</h3><p>List all the types you want to identify below. Each type per line.<br/>If you'
        'have too many types, try set up them separately, so that you won&apos;t need to choose from a long list '
        'for each sample. </p>',
        name='types'))
wf.append(KeywordsFiltering(name='keywords'))
wf.append(
    DataSetChooser(
        name='dataset_chooser',
        description='<h4>Choose which dateaset you want to use: </h4>'))
rb = ReviewRBInit(name="rb_review_init")
wf.append(rb)
rv = ReviewRBLoop(name='rb_review', rush_rule='../conf/rush_rules.tsv')
wf.append(rv)
wf.append(
    PreviousNextHTML(
        '<h2>Congratuations!</h2><h4>You have finished the initial review on the rule-base preannotations. </h4>',
        name='intro'))
wf.append(ReviewMLInit(name='ml_review_init'))
wf.append(
    ReviewMLLoop(name='ml_review', ml_classifier_cls=LogisticBOWClassifier))

wf.start()
wf.steps[0].complete()
wf.steps[1].complete()
wf.steps[2].toggle.value = 'n2c2_sents'
wf.steps[2].complete()
wf.steps[3].sample_size_input.value = 100
Пример #4
0
from SmartAnno.utils.ConfigReader import ConfigReader
from SmartAnno.gui.PreviousNextWidgets import PreviousNextHTML
from SmartAnno.gui.Workflow import Workflow
from SmartAnno.utils.IntroStep import IntroStep
ConfigReader('../conf/smartanno_conf2.json')
intro = IntroStep(
    '<h2>Welcome to SmartAnno!</h2><h4>First, let&apos;s import txt data from a directory. </h4>',
    name='intro')
wf = Workflow([
    intro,
    PreviousNextHTML(
        name='finish',
        description=
        '<h3>Well done!</h3><h4>Now you have finished reviewing all the samples. '
    )
])
wf.start()
intro.navigate(intro.branch_buttons[0])