Speaker queriesΒΆ

Querying speaker information is similar to querying other aspects, and function very similarly to querying discourses. Queries are constructed through the function query_speakers:

with CorpusContext(config) as c:
    q = c.query_speakers()
    speakers = [x['name'] for x in q.all()]
    print(speakers)

The above code will print all of the speakers in the current corpus. Like other queries, speakers can be filtered by properties that are encoded for them and specific information can be extracted.

with CorpusContext(config) as c:
    q = c.query_speakers().filter(c.speaker.name == 'Speaker 1').columns(c.speaker.discourses.name.column_name('discourses'))
    speaker1_discourses = q.all()[0]['discourses']
    print(speaker1_discourses)

The above query will print out all the discourses that a speaker identified as "Speaker 1" spoke in.