-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmodel.py
More file actions
72 lines (48 loc) · 2.12 KB
/
model.py
File metadata and controls
72 lines (48 loc) · 2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from sqlalchemy import Column, Computed # type: ignore
from sqlalchemy import Integer, String, DateTime # type: ignore
from sqlalchemy.sql import func # type: ignore
from sqlalchemy.orm import relationship # type: ignore
from db import Base, Session, engine # type: ignore
class Token(Base):
"""Annotation tokens of interest"""
__tablename__ = "tokens"
id = Column(Integer, primary_key=True)
timestamp = Column(DateTime, server_default=func.now())
token = Column(String, nullable=False)
stemmer = Column(String, nullable=False)
token_class = Column(String, nullable=False)
class Text(Base):
__tablename__ = "texts"
id = Column(Integer, primary_key=True)
timestamp = Column(DateTime, server_default=func.now())
name = Column(String, nullable=False)
fname = Column(String, nullable=False)
corpus = Column(String, nullable=False)
fulltext = Column(String, nullable=False)
class Sentence(Base):
"""Sentence of tokenized words"""
__tablename__ = "sentences"
id = Column(Integer, primary_key=True)
timestamp = Column(DateTime, server_default=func.now())
sentence = Column(String, nullable=False)
order = Column(Integer, nullable=False)
text_id = Column(Integer, nullable=False)
# stemmer = Column(String, nullable=False)
class Word(Base):
"""Tokenized words in a sentence"""
__tablename__ = "words"
id = Column(Integer, primary_key=True)
timestamp = Column(DateTime, server_default=func.now())
word = Column(String, nullable=False, comment="Word as originally present")
token = Column(String, nullable=False, comment="Actually token")
order = Column(Integer, nullable=False)
sentence_id = Column(Integer, nullable=False)
stemmer = Column(String, nullable=False)
class Annotation(Base):
__tablename__ = "annotations"
id = Column(Integer, primary_key=True)
timestamp = Column(DateTime, server_default=func.now())
text_id = Column(Integer, nullable=False)
stemmer = Column(String, nullable=False)
html = Column(String, nullable=False)
# text_id = relationship("Text", back_populates="appuser_rel")