Skip to content

Speed up ../characters endpoint for plays with many characters#377

Open
cmil wants to merge 1 commit into
mainfrom
249-characters-performance
Open

Speed up ../characters endpoint for plays with many characters#377
cmil wants to merge 1 commit into
mainfrom
249-characters-performance

Conversation

@cmil

@cmil cmil commented Jul 7, 2026

Copy link
Copy Markdown
Member

Refactor dutil:characters-info to precompute lookup maps in single passes over the TEI document instead of re-scanning per character:

  • index particDesc person/personGrp nodes by @xml:id
  • walk //tei:sp once to build speech-act and word-count maps
  • invert segments into a scene-count map
  • index metrics nodes by @id

For "Die letzten Tage der Menschheit" (925 characters) this brings the request from >2min down to seconds.

Preserves legacy counting semantics: numOfSpeechActs still counts only sp elements whose @who references a single speaker; numOfWords still distributes shared speeches to each referenced speaker.

Closes #249

Refactor dutil:characters-info to precompute lookup maps in single
passes over the TEI document instead of re-scanning per character:

- index particDesc person/personGrp nodes by @xml:id
- walk //tei:sp once to build speech-act and word-count maps
- invert segments into a scene-count map
- index metrics nodes by @id

For "Die letzten Tage der Menschheit" (925 characters) this brings the
request from >2min (gateway timeout) down to seconds.

Preserves legacy counting semantics: numOfSpeechActs still counts only
sp elements whose @who references a single speaker; numOfWords still
distributes shared speeches to each referenced speaker.

Closes #249
@cmil cmil self-assigned this Jul 7, 2026
@cmil cmil added this to the 1.4.0 milestone Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Characters endpoint performs poorly for plays with many characters

1 participant