def add_tag_name_specific_evaluations(self, name, annotator_cas, gold_cas,
                                          kwargs):
        kwargs['filters'] = [lambda tag: tag.name == name]
        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="{} Token".format(name))

        # Basic Evaluation
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="{} Strict".format(name))

        # Add HIPAA filter to evaluation arguments
        kwargs['filters'].extend([PHITrackEvaluation.HIPAA_predicate_filter])

        # Make sure the tag has the name passed in as 'name'  AND passes HIPAA_predicate_filter
        kwargs['conjunctive'] = True

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="{} HIPPA Token".format(name))

        # Change equality back to strict
        PHITag.strict_equality()
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="{} Binary HIPAA Strict".format(name))
    def __init__(self, annotator_cas, gold_cas, **kwargs):

        super(PHITrackEvaluation, self).__init__()

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="Token")

        # Basic Evaluation
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Strict")

        # Fuzzy Evaluation
        PHITag.fuzzy_end_equality(2)
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Relaxed")

        # Add HIPAA filter to evaluation arguments
        kwargs['filters'] = [PHITrackEvaluation.HIPAA_predicate_filter]

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPPA Token")

        # Change equality back to strict
        PHITag.strict_equality()
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPAA Strict")

        # Change equality to fuzzy end
        PHITag.fuzzy_end_equality(2)
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPAA Relaxed")
Beispiel #3
0
    def __init__(self, annotator_cas, gold_cas, **kwargs):

        super(PHITrackEvaluation, self).__init__()

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="Token")

        # Basic Evaluation
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Strict")

        # Fuzzy Evaluation
        PHITag.fuzzy_end_equality(2)
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Relaxed")

        # Add HIPAA filter to evaluation arguments
        kwargs['filters'] = [PHITrackEvaluation.HIPAA_predicate_filter]

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPPA Token")

        # Change equality back to strict
        PHITag.strict_equality()
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPAA Strict")

        # Change equality to fuzzy end
        PHITag.fuzzy_end_equality(2)
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPAA Relaxed")
    def add_tag_name_specific_evaluations(self, name, annotator_cas, gold_cas, kwargs):
        kwargs['filters'] = [ lambda tag: tag.name == name ]
        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="{} Token".format(name))

        # Basic Evaluation
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="{} Strict".format(name))

        # Add HIPAA filter to evaluation arguments
        kwargs['filters'].extend([PHITrackEvaluation.HIPAA_predicate_filter])

        # Make sure the tag has the name passed in as 'name'  AND passes HIPAA_predicate_filter
        kwargs['conjunctive'] = True

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="{} HIPPA Token".format(name))

        # Change equality back to strict
        PHITag.strict_equality()
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="{} Binary HIPAA Strict".format(name))
    def __init__(self, annotator_cas, gold_cas, **kwargs):

        super(PHITrackEvaluation, self).__init__()

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="Token")

        # Basic Evaluation
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Strict")

        # Fuzzy Evaluation
        PHITag.fuzzy_end_equality(2)
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Relaxed")

        # Add HIPAA filter to evaluation arguments
        kwargs['filters'] = [PHITrackEvaluation.HIPAA_predicate_filter]

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPPA Token")

        # Change equality back to strict
        PHITag.strict_equality()
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPAA Strict")

        # Change equality to fuzzy end
        PHITag.fuzzy_end_equality(2)
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPAA Relaxed")

        # Change equality back to strict
        PHITag.strict_equality()

        # Remove HIPAA Filter for now
        del kwargs['filters']

        # New Request for Start-End only matching (could do
        # this as a context manager) but we'll just hack it here
        # Set key's to just start/end.

        _PHI_keys = {}
        for k, cls in PHITag.tag_types.items():
            if k != "PHI":
                _PHI_keys[k] = cls.key
                cls.key = ['start', 'end']

        # Big hack - PHIToken._get_key hardcodes what it returns
        # Thats what I get for trying to do it quick and dirty
        PHIToken._get_key = lambda s: (s.start, s.end)

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="Binary Token")

        # Basic Evaluation
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Binary Strict")

        # Add HIPAA filter to evaluation arguments
        kwargs['filters'] = [PHITrackEvaluation.HIPAA_predicate_filter]

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="Binary HIPPA Token")

        # Change equality back to strict
        PHITag.strict_equality()
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Binary HIPAA Strict")

        # Restore Class Keys
        for k, cls in PHITag.tag_types.items():
            if k != "PHI":
                cls.key = _PHI_keys[k]

        # restore dirty dirty hardcoded PHIToken hack
        PHIToken._get_key = lambda s: (s.name, s.TYPE, s.start, s.end)

        for t in PHITag.tag_types.keys():
            if t != "PHI":
                self.add_tag_name_specific_evaluations(t, annotator_cas,
                                                       gold_cas, kwargs)
    def __init__(self, annotator_cas, gold_cas, **kwargs):

        super(PHITrackEvaluation, self).__init__()

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="Token")

        # Basic Evaluation
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Strict")

        # Fuzzy Evaluation
        PHITag.fuzzy_end_equality(2)
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Relaxed")

        # Add HIPAA filter to evaluation arguments
        kwargs['filters'] = [PHITrackEvaluation.HIPAA_predicate_filter]

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPPA Token")

        # Change equality back to strict
        PHITag.strict_equality()
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPAA Strict")

        # Change equality to fuzzy end
        PHITag.fuzzy_end_equality(2)
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="HIPAA Relaxed")



        # Change equality back to strict
        PHITag.strict_equality()

        # Remove HIPAA Filter for now
        del kwargs['filters']
        
        # New Request for Start-End only matching (could do
        # this as a context manager) but we'll just hack it here
        # Set key's to just start/end, 
        # import pudb; pu.db

        _PHI_keys = {}
        for k, cls in PHITag.tag_types.items():
            if k != "PHI":
                _PHI_keys[k] = cls.key
                cls.key = ['start', 'end']

        # Big hack - PHIToken._get_key hardcodes what it returns
        # Thats what I get for trying to do it quick and dirty
        PHIToken._get_key = lambda s: (s.start, s.end)
        

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="Binary Token")

        # Basic Evaluation
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Binary Strict")

        # Add HIPAA filter to evaluation arguments
        kwargs['filters'] = [PHITrackEvaluation.HIPAA_predicate_filter]

        # Tokenized Evaluation
        self.add_eval(EvaluateTokenizedPHI(annotator_cas, gold_cas, **kwargs),
                      label="Binary HIPPA Token")

        # Change equality back to strict
        PHITag.strict_equality()
        self.add_eval(EvaluatePHI(annotator_cas, gold_cas, **kwargs),
                      label="Binary HIPAA Strict")

        # Restore Class Keys
        for k, cls in PHITag.tag_types.items():
            if k != "PHI":
                cls.key = _PHI_keys[k]

        # restore dirty dirty hardcoded PHIToken hack
        PHIToken._get_key = lambda s: (s.name, s.TYPE, s.start, s.end)

        for t in PHITag.tag_types.keys():
            if t != "PHI":
                self.add_tag_name_specific_evaluations(t, annotator_cas, gold_cas, kwargs)