<commit_before>from django.db import models
from django.utils.translation import ugettext_lazy as _

score_text_to_score = {'complies-fully':         1.0,
                       'complies-partially':     0.5,
                       'agnostic':               0.0,
                       'opposes-partially':     -0.5,
                       'opposes-fully':         -1.0,
                       }

class AgendaVote(models.Model):
    agenda = models.ForeignKey('Agenda')
    vote = models.ForeignKey('laws.Vote')
    score = models.FloatField(default=0.0)
    reasoning = models.TextField(null=True,blank=True)
    
    def set_score_by_text(self,score_text):
        self.score = score_text_to_score[score_text]
    def get_text_score(self):
        return [score_text for score_text, score in score_text_to_score.iteritems() if score == self.score][0]
    

class Agenda(models.Model):
    name = models.CharField(max_length=300,unique=True)
    description = models.TextField(null=True,blank=True)<commit_msg>agendas models.py - small refactoring to improve code readability<commit_after>from django.db import models
from django.utils.translation import ugettext_lazy as _

score_text_to_score = {'complies-fully':         1.0,
                       'complies-partially':     0.5,
                       'agnostic':               0.0,
                       'opposes-partially':     -0.5,
                       'opposes-fully':         -1.0,
                       }

score_to_score_text = dict(zip(score_text_to_score.values(), score_text_to_score.keys()))

class AgendaVote(models.Model):
    agenda = models.ForeignKey('Agenda')
    vote = models.ForeignKey('laws.Vote')
    score = models.FloatField(default=0.0)
    reasoning = models.TextField(null=True,blank=True)
    
    def set_score_by_text(self,score_text):
        self.score = score_text_to_score[score_text]
    def get_text_score(self):
        return score_to_score_text[self.score]
    

class Agenda(models.Model):
    name = models.CharField(max_length=300,unique=True)
    description = models.TextField(null=True,blank=True)
{'fraction_non_alphanumeric': 0.10756782484531176, 'fraction_numerical': 0.014754878629224179, 'mean_word_length': 2.423452768729642, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6693371', 'n_tokens_mistral': 659, 'n_tokens_neox': 644, 'n_words': 105}