Пример #1
0
class ClarityProject(BaseProject, db.Model):
    __tablename__ = 'clarity_project'

    n_summaries = db.Column(db.Integer, default=5)
    expire_duration = db.Column(db.INTEGER, nullable=False, default=3)
    summary_group_lists = db.relationship('SummaryGroupList', cascade='delete')
    proj_statuses = db.relationship('ProjectStatus', cascade='delete')
Пример #2
0
class Summary(db.Model):
    __tablename__ = 'summary'

    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    text = db.Column(db.Text, nullable=False)

    summary_group_id = db.Column(db.INTEGER,
                                 db.ForeignKey('summary_group.id'),
                                 nullable=False)
    doc_id = db.Column(db.INTEGER,
                       db.ForeignKey('document.id'),
                       nullable=False)
Пример #3
0
class FluencyResult(db.Model):
    __tablename__ = 'fluency_result'

    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    fluency = db.Column(db.REAL, nullable=False, default=50.0)
    is_invalid = db.Column(db.Boolean, default=False)
    proj_status_id = db.Column(db.INTEGER,
                               db.ForeignKey('project_status.id'),
                               nullable=False)
    summary_id = db.Column(db.INTEGER,
                           db.ForeignKey('summary.id'),
                           nullable=False)
Пример #4
0
class SummaryGroup(db.Model):
    """
    For different model or reference group
    """
    __tablename__ = 'summary_group'

    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    name = db.Column(db.String(255), nullable=False)
    is_ref = db.Column(db.Boolean, nullable=False, default=False)

    dataset_id = db.Column(db.INTEGER,
                           db.ForeignKey('dataset.id'),
                           nullable=False)
    summaries = db.relationship('Summary', backref='summary_group')
Пример #5
0
class SanitySummary(db.Model):
    """
    For sanity checking where user's submission is deemed valid
    if the good_summary >= mediocre_summary > bad_summary
    """
    __tablename__ = 'sanity_summary'

    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    good_summary = db.Column(db.Text, nullable=False)
    mediocre_summary = db.Column(db.Text, nullable=False)
    bad_summary = db.Column(db.Text, nullable=False)

    dataset_id = db.Column(db.INTEGER,
                           db.ForeignKey('dataset.id'),
                           nullable=False)
Пример #6
0
class SummaryGroupList(db.Model):
    """
    N-to-N table linking project and summary group
    """
    __tablename__ = 'summary_group_list'
    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    fluency_proj_id = db.Column(db.INTEGER,
                                db.ForeignKey('fluency_project.id'),
                                nullable=True)
    clarity_proj_id = db.Column(db.INTEGER,
                                db.ForeignKey('clarity_project.id'),
                                nullable=True)
    summ_group_id = db.Column(db.INTEGER,
                              db.ForeignKey('summary_group.id'),
                              nullable=False)
Пример #7
0
class BaseProject(object):
    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    name = db.Column(db.String(255), nullable=False)
    category = db.Column(db.String(25), nullable=False)

    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    finished_at = db.Column(db.DateTime, nullable=True)
    total_exp_results = db.Column(db.Integer, nullable=False, default=1)
    is_active = db.Column(db.Boolean, nullable=False, default=True)
Пример #8
0
class User(db.Model):
    __tablename__ = 'user'

    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    email = db.Column(db.String(120), unique=True, nullable=False)
    password = db.Column(db.String(255), nullable=False)

    def __init__(self, **kwargs):
        super(User, self).__init__(**kwargs)
        self.password = generate_password_hash(kwargs.get('password'),
                                               method='sha256')

    @classmethod
    def authenticate(cls, **kwargs):
        email = kwargs.get('email')
        password = kwargs.get('password')

        if not email or not password:
            return None

        user = cls.query.filter_by(email=email).first()
        if not user or not check_password_hash(user.password, password):
            return None
        return user
Пример #9
0
class Document(db.Model):
    __tablename__ = 'document'

    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    doc_id = db.Column(db.String(25), nullable=False)
    doc_json = db.Column(db.JSON, nullable=False)

    # For ground truth comparison
    sanity_statement = db.Column(db.Text, nullable=True)
    sanity_answer = db.Column(db.Boolean, nullable=True, default=True)

    # For reference comparison
    sanity_statement_2 = db.Column(db.Text, nullable=True)
    sanity_answer_2 = db.Column(db.Boolean, nullable=True, default=True)

    # For checking whether doc_json is empty or not
    has_highlight = db.Column(db.Boolean, nullable=False, default=False)

    # doc_statuses = db.relationship('DocStatus', backref='document', lazy=True)

    dataset_id = db.Column(db.INTEGER, db.ForeignKey('dataset.id'), nullable=True)
Пример #10
0
class Dataset(db.Model):
    __tablename__ = 'dataset'
    id = db.Column(db.INTEGER, primary_key=True, nullable=False)
    name = db.Column(db.String(255), nullable=False)
    summ_groups = db.relationship('SummaryGroup', backref='dataset', lazy=True)
Пример #11
0
class EvaluationProject(BaseProject, db.Model):
    __tablename__ = 'evaluation_project'

    highlight = db.Column(db.Boolean, default=True)
    expire_duration = db.Column(db.INTEGER, nullable=False, default=3)
Пример #12
0
class ProjectStatus(db.Model):
    __tablename__ = 'project_status'

    id = db.Column(db.INTEGER, primary_key=True, nullable=False)

    # total_exp_results = db.Column(db.Integer, nullable=False, default=1)
    # total_results = db.Column(db.Integer, nullable=False, default=0)

    is_finished = db.Column(db.Boolean, nullable=False, default=False)
    is_active = db.Column(db.Boolean, nullable=False, default=False)
    validity = db.Column(db.Boolean, nullable=True, default=False)
    mturk_code = db.Column(db.String(255), nullable=True)

    good_summ_score = db.Column(db.INTEGER, nullable=True)
    mediocre_summ_score = db.Column(db.INTEGER, nullable=True)
    bad_summ_score = db.Column(db.INTEGER, nullable=True)

    expired_in = db.Column(db.DateTime, nullable=True)
    # Used in informativeness and fluency project
    # summary_id = db.Column(db.INTEGER, db.ForeignKey('summary.id'), nullable=True)
    # ref_summary_id = db.Column(db.INTEGER, db.ForeignKey('summary.id'), nullable=True)

    # Used in annotation project
    # doc_id = db.Column(db.INTEGER, db.ForeignKey('document.id'), nullable=True)

    eval_proj_id = db.Column(db.INTEGER,
                             db.ForeignKey('evaluation_project.id'),
                             nullable=True)
    fluency_proj_id = db.Column(db.INTEGER,
                                db.ForeignKey('fluency_project.id'),
                                nullable=True)
    clarity_proj_id = db.Column(db.INTEGER,
                                db.ForeignKey('clarity_project.id'),
                                nullable=True)
    sanity_summ_id = db.Column(db.INTEGER,
                               db.ForeignKey('sanity_summary.id'),
                               nullable=True)
    fluency_results = db.relationship('FluencyResult', cascade='delete')
    clarity_results = db.relationship('ClarityResult', cascade='delete')