time-link / timelink-py

Timelink Python Package
MIT License
3 stars 0 forks source link

Act.to_Kleio() wrongly displays inferred relations #31

Closed joaquimrcarvalho closed 8 months ago

joaquimrcarvalho commented 8 months ago

Description

Acts contain inferred relations, that are added at the end of the translation of the act and so are exported and "inside" the act. Current Entity.to_kleio() does not displays this correctly.

Getting and act from the database and displaying it with Act.to_kleio()

What I Did

from timelink.api.models import Act
from sqlalchemy import select, func

stmt = select(Act).where(Act.the_date > '16850800',
                         Act.the_date < '16850900')

print(stmt)
with tlnb.db.session() as session:

    result = session.execute(stmt).scalars().all()
    for row in result:
        print()
        print(row.groupname,row.the_date,row.loc,row.obs)
        print(row.to_kleio())

relations do not appear inside the correct group.

Check:

bap$b1685.3/16850802/type=bap/ref=?/loc=igreja de s. tiago
n$ana/f/id=b1685.3-per1
    rel$function-in-act/n/b1685.3/16850802
    pai$antonio joao/m/id=b1685.3-per1-per2
    rel$function-in-act/pai/b1685.3/16850802
    ls$residencia/montais/16850802
    ls$ec/c/16850802
    mae$maria de oliveira/f/id=b1685.3-per1-per3
    rel$function-in-act/mae/b1685.3/16850802
    ls$ec/c/16850802
    pad$domingos simoes/m/id=b1685.3-per4
    rel$function-in-act/pad/b1685.3/16850802
    ls$residencia/sobral/16850802
    ls$profissao/padre/16850802
    mad$ana velho/f/id=b1685.3-per5
    rel$function-in-act/mad/b1685.3/16850802
    mrmad$nomes desconhecido/m/id=b1685.3-per6
        rel$function-in-act/mrmad/b1685.3/16850802
        ls$profissao/boticario/16850802
        ls$residencia/soure/16850802
rel$parentesco/pai/ana/b1685.3-per1/16850802  <-- this 4 lines should appear  next to the origin
rel$parentesco/mae/ana/b1685.3-per1/16850802
rel$parentesco/marido/maria de oliveira/b1685.3-per1-per3/16850802
rel$parentesco/marido/ana velho/b1685.3-per5/16850802

This is a problem with to_kleio() in Entity.

First the attributes and relations, should be output, then the contained groups which are not attributes nor relations. Contained groups should be ordered by Order

The best way to handle this is to create a function that maps POM-SOM, to obtain the Kleio Group from an entity in the database and then use KGroup.to_kleio(). So other nice functions of KGroup can be used.

Assignees: joaquimrcarvalho Labels: Bug Milestone:

joaquimrcarvalho commented 8 months ago

This should be fixed in the Kleio translator see https://github.com/time-link/timelink-kleio/issues/29

Nevertheless the POM-SOM mapping idea is good, should be a separate one.