63 lines
2.5 KiB
Python
63 lines
2.5 KiB
Python
import uuid
|
|
|
|
from sqlalchemy import String, Text, ForeignKey, Integer
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from sqlalchemy.dialects.postgresql import UUID, ARRAY, JSONB
|
|
|
|
from ..database import Base
|
|
|
|
|
|
class DictionaryLemmaEntity(Base):
|
|
__tablename__ = "dictionary_lemma"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
headword: Mapped[str] = mapped_column(Text, nullable=False)
|
|
language: Mapped[str] = mapped_column(String(2), nullable=False, index=True)
|
|
pos_raw: Mapped[str] = mapped_column(Text, nullable=False)
|
|
pos_normalised: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
gender: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
tags: Mapped[list[str]] = mapped_column(ARRAY(Text), nullable=False, server_default="{}")
|
|
|
|
|
|
class DictionarySenseEntity(Base):
|
|
__tablename__ = "dictionary_sense"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
lemma_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
ForeignKey("dictionary_lemma.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
sense_index: Mapped[int] = mapped_column(Integer, nullable=False)
|
|
gloss: Mapped[str] = mapped_column(Text, nullable=False, server_default="")
|
|
topics: Mapped[list[str]] = mapped_column(ARRAY(Text), nullable=False, server_default="{}")
|
|
tags: Mapped[list[str]] = mapped_column(ARRAY(Text), nullable=False, server_default="{}")
|
|
|
|
|
|
class DictionaryWordformEntity(Base):
|
|
__tablename__ = "dictionary_wordform"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
lemma_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
ForeignKey("dictionary_lemma.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
form: Mapped[str] = mapped_column(Text, nullable=False, index=True)
|
|
tags: Mapped[list[str]] = mapped_column(ARRAY(Text), nullable=False, server_default="{}")
|
|
|
|
|
|
class DictionaryLemmaRawEntity(Base):
|
|
__tablename__ = "dictionary_lemma_raw"
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
|
|
lemma_id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True),
|
|
ForeignKey("dictionary_lemma.id", ondelete="CASCADE"),
|
|
nullable=False,
|
|
unique=True,
|
|
)
|
|
language: Mapped[str] = mapped_column(String(2), nullable=False)
|
|
raw: Mapped[dict] = mapped_column(JSONB, nullable=False)
|