Skip to content

Commit

Permalink
Get intertext from database
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaasonen committed Dec 14, 2021
1 parent 5bf5d70 commit 243631f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ebl/corpus/application/display_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

class LineDisplaySchema(Schema):
number = fields.Nested(OneOfLineNumberSchema, required=True)
intertext = fields.List(
fields.Nested(OneOfNoteLinePartSchema), load_default=tuple()
)
reconstruction = fields.List(fields.Nested(OneOfTokenSchema), load_default=tuple())
translation = fields.List(
fields.Nested(OneOfNoteLinePartSchema), load_default=tuple()
Expand All @@ -20,7 +23,7 @@ class LineDisplaySchema(Schema):
def make_line(self, data: dict, **kwargs) -> LineDisplay:
return LineDisplay(
data["number"],
tuple(),
tuple(data["intertext"]),
tuple(data["reconstruction"]),
tuple(data["translation"]),
)
Expand Down
12 changes: 12 additions & 0 deletions ebl/corpus/infrastructure/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ def aggregate_chapter_display(id_: ChapterId) -> List[dict]:
0,
]
},
"intertext": {
"$arrayElemAt": [
{
"$map": {
"input": "$$line.variants",
"as": "variant",
"in": "$$variant.intertext",
}
},
0,
]
},
"reconstruction": {
"$arrayElemAt": [
{
Expand Down
3 changes: 3 additions & 0 deletions ebl/tests/corpus/test_chapter_display_schema
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def to_dict(chapter: ChapterDisplay) -> dict:
"lines": [
{
"number": OneOfLineNumberSchema().dump(line.number),
"intertext": OneOfNoteLinePartSchema().dump(
line.intertext, many=True
),
"reconstruction": OneOfTokenSchema().dump(
line.reconstruction, many=True
),
Expand Down

0 comments on commit 243631f

Please sign in to comment.