<commit_before>from sqlalchemy import Table, Column, DateTime, ForeignKey, Integer, String, Text, Float, LargeBinary, Enum, func
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import column_property, relationship
from eve_sqlalchemy.decorators import registerSchema
import enum

Base = declarative_base()

class CommonColumns(Base):
    __abstract__ = True
    _created = Column(DateTime, default=func.now())
    _updated = Column(DateTime, default=func.now(), onupdate=func.now())
    _id = Column(Integer, primary_key=True, autoincrement=True)

class User(CommonColumns):
    __tablename__ = 'user'
    name = Column(String(120))
    password = Column(String(120))
    fonts = relationship('Font', back_populates='author')

class Tag(CommonColumns):
    __tablename__ = 'tag'
    text = Column(String(200))
    type = Column(String(100))

tag_sample_text_association_table = Table('tag_sample_text_association', Base.metadata,
    Column('tag_id', Integer, ForeignKey('tag._id')),
    Column('sample_text_id', Integer, ForeignKey('sample_text._id')))

class SampleText(CommonColumns):
    __tablename__ = 'sample_text'
    title = Column(String(120))
    text = Column(Text)
    author_id = Column(Integer, ForeignKey('user._id'))
    author = relationship(User, uselist=False)
    tags = relationship('Tag', secondary=tag_sample_text_association_table)

class Family(CommonColumns):
    __tablename__ = 'family'
    name = Column(String(300))
    fonts = relationship('Font', back_populates='family')

tag_font_association_table = Table('tag_font_association', Base.metadata,
    Column('tag_id', Integer, ForeignKey('tag._id')),
    Column('font_id', Integer, ForeignKey('font._id')))

class Font(CommonColumns):
    __tablename__ = 'font'
    name = Column(String(300))
    family_id = Column(Integer, ForeignKey('family._id'))
    author_id = Column(Integer, ForeignKey('user._id'))
    family = relationship('Family', back_populates='fonts')
    tags = relationship('Tag', secondary=tag_font_association_table)
    glyphs = relationship('Glyph', back_populates='font')
    author = relationship('User', back_populates='fonts')

class Glyph(CommonColumns):
    __tablename__ = 'glyph'
    name = Column(String(300))
    version_hash = Column(String(40))
    font_id = Column(Integer, ForeignKey('font._id'))
    font = relationship('Font', back_populates='glyphs')

tag_thread_association_table = Table('tag_thread_association', Base.metadata,
    Column('tag_id', Integer, ForeignKey('tag._id')),
    Column('thread_id', Integer, ForeignKey('thread._id')))

thread_glyph_association_table = Table('thread_glyph_association', Base.metadata,
    Column('thread_id', Integer, ForeignKey('thread._id')),
    Column('glyph_id', Integer, ForeignKey('glyph._id')))

class Thread(CommonColumns):
    __tablename__ = 'thread'
    title = Column(Text)
    tags = relationship('Tag', secondary=tag_thread_association_table)
    glyphs = relationship('Glyph', secondary=thread_glyph_association_table)
    # FIXME we also would like to save the indices of the glyphs from their unicode
    codepoints = relationship('Codepoint', back_populates='thread')
    comments = relationship('Comment', back_populates='thread')

class Codepoint(CommonColumns):
    __tablename__ = 'codepoint'
    value = Column(Integer)
    features = Column(Text)
    size = Column(Float)<commit_msg>Fix usage of already reserved selectors in data model<commit_after>from sqlalchemy import Table, Column, DateTime, ForeignKey, Integer, String, Text, Float, LargeBinary, Enum, func
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import column_property, relationship
from eve_sqlalchemy.decorators import registerSchema
import enum

Base = declarative_base()

class CommonColumns(Base):
    __abstract__ = True
    _created = Column(DateTime, default=func.now())
    _updated = Column(DateTime, default=func.now(), onupdate=func.now())
    _id = Column(Integer, primary_key=True, autoincrement=True)

class User(CommonColumns):
    __tablename__ = 'user'
    userName = Column(String(120))
    password = Column(String(120))
    fonts = relationship('Font', back_populates='author')

class Tag(CommonColumns):
    __tablename__ = 'tag'
    text = Column(String(200))
    type = Column(String(100))

tag_sample_text_association_table = Table('tag_sample_text_association', Base.metadata,
    Column('tag_id', Integer, ForeignKey('tag._id')),
    Column('sample_text_id', Integer, ForeignKey('sample_text._id')))

class SampleText(CommonColumns):
    __tablename__ = 'sample_text'
    title = Column(String(120))
    text = Column(Text)
    author_id = Column(Integer, ForeignKey('user._id'))
    author = relationship(User, uselist=False)
    tags = relationship('Tag', secondary=tag_sample_text_association_table)

class Family(CommonColumns):
    __tablename__ = 'family'
    familyName = Column(String(300))
    fonts = relationship('Font', back_populates='family')

tag_font_association_table = Table('tag_font_association', Base.metadata,
    Column('tag_id', Integer, ForeignKey('tag._id')),
    Column('font_id', Integer, ForeignKey('font._id')))

class Font(CommonColumns):
    __tablename__ = 'font'
    fontName = Column(String(300))
    family_id = Column(Integer, ForeignKey('family._id'))
    author_id = Column(Integer, ForeignKey('user._id'))
    family = relationship('Family', back_populates='fonts')
    tags = relationship('Tag', secondary=tag_font_association_table)
    glyphs = relationship('Glyph', back_populates='font')
    author = relationship('User', back_populates='fonts')

class Glyph(CommonColumns):
    __tablename__ = 'glyph'
    glyphName = Column(String(300))
    version_hash = Column(String(40))
    font_id = Column(Integer, ForeignKey('font._id'))
    font = relationship('Font', back_populates='glyphs')

tag_thread_association_table = Table('tag_thread_association', Base.metadata,
    Column('tag_id', Integer, ForeignKey('tag._id')),
    Column('thread_id', Integer, ForeignKey('thread._id')))

thread_glyph_association_table = Table('thread_glyph_association', Base.metadata,
    Column('thread_id', Integer, ForeignKey('thread._id')),
    Column('glyph_id', Integer, ForeignKey('glyph._id')))

class Thread(CommonColumns):
    __tablename__ = 'thread'
    title = Column(Text)
    tags = relationship('Tag', secondary=tag_thread_association_table)
    glyphs = relationship('Glyph', secondary=thread_glyph_association_table)
    # FIXME we also would like to save the indices of the glyphs from their unicode
    codepoints = relationship('Codepoint', back_populates='thread')
    comments = relationship('Comment', back_populates='thread')

class Codepoint(CommonColumns):
    __tablename__ = 'codepoint'
    unicodeValue = Column(Integer)
    features = Column(Text)
    pointSize = Column(Float)
{'fraction_non_alphanumeric': 0.12432668510700247, 'fraction_numerical': 0.007570243121269472, 'mean_word_length': 5.795252225519288, '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': '1599594', 'n_tokens_mistral': 2106, 'n_tokens_neox': 2040, 'n_words': 423}