class ImageAnnotation(db.Model): __tablename__ = 'imageannotation' id = db.Column(db.Integer, primary_key=True) image_id = db.Column(db.Integer, db.ForeignKey("imagecontent.id", ondelete="SET NULL")) user_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="SET NULL")) # three boolean classifiers meme_class = db.Column(db.Boolean, nullable=False) HS_class = db.Column(db.Boolean, nullable=False) text_class = db.Column(db.Boolean, nullable=False) # pos-neg polarity classifiers polarity_classA = db.Column(db.Integer, nullable=True) polarity_classB = db.Column(db.Integer, nullable=True) # HS classifiers HS_strength = db.Column(db.Integer, nullable=True) HS_category = db.Column(db.String(128), nullable=True) # text classifiers text_text = db.Column(db.String(300), nullable=True) text_language = db.Column(db.String(64), nullable=True) images = db.relationship("ImageContent", back_populates="image_annotations", uselist=True) image_annotators = db.relationship("User", back_populates="image_annotator", uselist=True)
class PhotoAnnotation(db.Model): __tablename__ = 'photoannotation' id = db.Column(db.Integer, primary_key=True) photo_id = db.Column(db.Integer, db.ForeignKey("imagecontent.id", ondelete="SET NULL")) user_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="SET NULL")) # boolean classifiers persons_class = db.Column(db.Boolean, nullable=False) slideshow_class = db.Column(db.Boolean, nullable=False) # pos value classifier positivity_class = db.Column(db.Integer, nullable=False) # text classifiers text_free_comment = db.Column(db.String(128), nullable=True) text_persons = db.Column(db.String(128), nullable=True) text_persons_comment = db.Column(db.String(128), nullable=True) # geografical location - not created photos = db.relationship("ImageContent", back_populates="photo_annotations", uselist=True) photo_annotators = db.relationship("User", back_populates="photo_annotator", uselist=True)
class User(db.Model): __tablename__ = 'user' id = db.Column(db.Integer, primary_key=True) user_name = db.Column(db.String(128), unique=True, nullable=False) user_password = db.Column(db.String(32), nullable=True) image_user = db.relationship("ImageContent", back_populates="image_users") photo_user = db.relationship("ImageContent", back_populates="photo_users") image_annotator = db.relationship("ImageAnnotation", back_populates="image_annotators") photo_annotator = db.relationship("PhotoAnnotation", back_populates="photo_annotators")
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(20), unique=True, nullable=False) email = db.Column(db.String(120), unique=True, nullable=False) image_file = db.Column(db.String(20), nullable=False, default='default.jpg') password = db.Column(db.String(60), nullable=False) posts = db.relationship('Post', backref='author', lazy=True) def __repr__(self): return f"User('{self.username}', '{self.email}', '{self.image_file}')"
class ImageContent(db.Model): __tablename__ = 'imagecontent' id = db.Column(db.Integer, primary_key=True) user_id = db.Column(db.Integer, db.ForeignKey("user.id", ondelete="SET NULL")) name = db.Column(db.String(128), nullable=False) publish_date = db.Column(db.DateTime, nullable=True) location = db.Column(db.String(64), nullable=False) is_private = db.Column(db.Boolean(), default=True) date = db.Column(db.DateTime, nullable=False, default=datetime.now()) image_annotations = db.relationship("ImageAnnotation", back_populates="images") image_users = db.relationship("User", back_populates="image_user", uselist=True) photo_annotations = db.relationship("PhotoAnnotation", back_populates="photos") photo_users = db.relationship("User", back_populates="photo_user", uselist=True)