예제 #1
0
class Response(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    #neg_sentence = db.Column(LONGTEXT()) #joined
    #pos_sent = db.Column(LONGTEXT()) #joined
    #clause = db.Column(LONGTEXT()) #joined
    len_of_neg = db.Column(db.Integer)
    len_of_pos = db.Column(db.Integer)
    len_of_clause = db.Column(db.Integer)
    abstract_id = db.Column(db.Integer,
                            db.ForeignKey('abstract.id', ondelete='CASCADE'))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id',
                                                  ondelete='CASCADE'))
    nsentences = db.relationship('Nsentence', backref='source', lazy='dynamic')
    psentences = db.relationship('Psentence', backref='source', lazy='dynamic')
    pclauses = db.relationship('Pclause', backref='source', lazy='dynamic')

    def __repr__(self):
        return f'<Labeller: {self.user_id}; Source ID: {self.abstract_id}; Length of Neg: {self.len_of_neg}; Length of Pos: {self.len_of_pos}; Clause size: {self.len_of_clause}>'
예제 #2
0
class Nsentence(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    sentence = db.Column(LONGTEXT())
    label = db.Column(db.Boolean,
                      default=False,
                      server_default=expression.false(),
                      nullable=False)
    response_id = db.Column(db.Integer,
                            db.ForeignKey('response.id', ondelete='CASCADE'))

    def __repr__(self):
        return f'<Source ID: {self.abstract_id}; Content: {self.sentence}; Label: {self.label}>'
예제 #3
0
class Pclause(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    clause = db.Column(LONGTEXT())
    label = db.Column(db.Boolean,
                      default=True,
                      server_default=expression.true(),
                      nullable=False)
    response_id = db.Column(db.Integer,
                            db.ForeignKey('response.id', ondelete='CASCADE'))

    #sentence = db.relationship('Psentence', backref='source')

    def __repr__(self):
        return f'<Source ID: {self.sentence_id}; Content: {self.clause}; Label: {self.label}>'
예제 #4
0
    def get_id(self):
        """Return the email address to satisfy Flask-Login's requirements."""
        return self.email

    def is_authenticated(self):
        """Return True if the user is authenticated."""
        return self.is_authenticated

    def is_anonymous(self):
        """False, as anonymous users aren't supported."""
        return False

    def is_admin(self):
        return self.role == ROLE['admin']

    def allowed(self, access_level):
        return self.role >= access_level


user_abstracts = db.Table(
    'user_abstracts',
    db.Column('user_id',
              db.Integer,
              db.ForeignKey('user.id'),
              primary_key=True),
    db.Column('abstract_id',
              db.Integer,
              db.ForeignKey('abstract.id'),
              primary_key=True))