d3bfdfbfc4609dd786b18140b78fa84bb1d78731,snorkel/viewer.py,Viewer,save_labels,#Viewer#,159

Before Change



    def save_labels(self):
        for cid, v in self.get_labels():
            existing_annotation = self.session.query(Annotation) \
                .filter(Annotation.annotator == self.annotator) \
                .filter(Annotation.candidate == self.candidates[cid]) \
                .first()
            if existing_annotation is not None:
                existing_annotation.value = v
            else:
                self.session.add(Annotation(annotator=self.annotator, candidate=self.candidates[cid], value=v))

After Change


        
        for cid, v in self._get_labels():
            if self.annotations[cid] is not None:
                if self.annotations[cid].value != v:
                    self.annotations[cid].value = v
            else:
                self.annotations[cid] = Annotation(annotator=self.annotator, candidate=self.candidates[cid], value=v)
                self.session.add(self.annotations[cid])
        self.session.commit()
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 3

Instances


Project Name: snorkel-team/snorkel
Commit Name: d3bfdfbfc4609dd786b18140b78fa84bb1d78731
Time: 2016-08-22
Author: stephenhbach@gmail.com
File Name: snorkel/viewer.py
Class Name: Viewer
Method Name: save_labels


Project Name: chainer/chainercv
Commit Name: 9cc2c91177a6456dea602a93b77864b0a7952333
Time: 2019-02-24
Author: ktns.87@gmail.com
File Name: chainercv/links/model/pickable_sequential_chain.py
Class Name: PickableSequentialChain
Method Name: pick


Project Name: daniel-kukiela/nmt-chatbot
Commit Name: 089735850d350dbf7ded0148c67e54e9649b2206
Time: 2017-11-21
Author: daniel@kukiela.pl
File Name: prepare_data.py
Class Name:
Method Name: