Esempio n. 1
0
    def extract(self, cas: Cas) -> (str, float):
        studentView = cas.get_view(FeatureExtractor.STUDENT_ANSWER_VIEW)

        variety = 0.0
        for al in AlignmentLabel:
            variety += self.get_perc_of_mapping_type(studentView, al)

        return ("Variety", variety)
Esempio n. 2
0
    def extract(self, cas: Cas) -> (str, float):
        studentView = cas.get_view(FeatureExtractor.STUDENT_ANSWER_VIEW)
        answer = next(studentView.select(FeatureExtractor.ANSWER_TYPE))
        score = answer.contentScore

        if score in Outcome.LABEL2INT:
            return ("Outcome", Outcome.LABEL2INT[score])
        else:
            try:
                outcome = float(score)
            except ValueError:
                outcome = float('nan')
            return ("Outcome", outcome)
Esempio n. 3
0
    def extract(self, cas: Cas) -> (str, float):
        view = cas.get_view(self.view_name)
        dep_matches = len(list(view.select(TripleOverlap.DEP_MAPPING_TYPE)))
        dep_rels = 0

        for d in view.select(FeatureExtractor.DEPENDENCY_TYPE):
            if d.DependencyType in self.english_arg_rels:
                dep_rels += 1

        ret = -1.0
        if not dep_rels:
            ret = 0.0
        else:
            ret = dep_matches / dep_rels

        return (self.view_name + "-Triple-Overlap", ret)
Esempio n. 4
0
    def extract(self, cas: Cas) -> (str, float):
        view = cas.get_view(self.view_name)
        matched_ann = 0
        all_ann = 0
        for a in view.select(self.ann_type):
            all_ann += 1
            mappable = self.get_mappable_ann(view, a)

            if mappable.match:
                matched_ann += 1

        ret = -1.0
        if not all_ann:
            ret = 0.0
        else:
            ret = matched_ann / all_ann

        return (self.view_name + "-" + uima.simple_type_name(self.ann_type) +
                "-Overlap", ret)
Esempio n. 5
0
 def extract(self, cas: Cas) -> (str, float):
     studentView = cas.get_view(FeatureExtractor.STUDENT_ANSWER_VIEW)
     return (self.alignment.name + "-Match",
             self.get_perc_of_mapping_type(studentView, self.alignment))
Esempio n. 6
0
 def extract(self, cas: Cas) -> (str, float):
     studentView = cas.get_view(FeatureExtractor.STUDENT_ANSWER_VIEW)
     answer = next(studentView.select(FeatureExtractor.ANSWER_TYPE))
     return ("Diagnosis", int(answer.contentDiagnosis))
Esempio n. 7
0
def _get_indexed_feature_structures(cas: Cas) -> Iterable[FeatureStructure]:
    feature_structures = []
    for sofa in cas.sofas:
        view = cas.get_view(sofa.sofaID)
        feature_structures.extend(view.select_all())
    return feature_structures