GraphQuery

class polyglotdb.query.annotations.query.GraphQuery(corpus, to_find, stop_check=None)[source]

Base GraphQuery class.

Extend this class to implement more advanced query functions.

Parameters:
corpus : CorpusContext

The corpus to query

to_find : AnnotationNode

Name of the annotation type to search for

Methods

__init__(corpus, to_find[, stop_check]) Initialize self.
aggregate(*args) Aggregate the results of the query by a grouping factor or overall.
all() Returns all results for the query
cache(*args)
clear_columns() Remove any columns specified.
columns(*args) Add one or more additional columns to the results.
count() Returns the number of rows in the query.
create_subset(label)
cypher() Generates a Cypher statement based on the query.
cypher_params()
delete() Remove the results of a query from the graph.
filter(*args) Apply one or more filters to a query.
filter_left_aligned(annotation_type) Short cut function for aligning the queried annotations with another annotation type.
filter_not_left_aligned(annotation_type) Short cut function for aligning the queried annotations with another annotation type.
filter_not_right_aligned(annotation_type) Short cut function for aligning the queried annotations with another annotation type.
filter_right_aligned(annotation_type) Short cut function for aligning the queried annotations with another annotation type.
generate_return() Generates final statement from query object, calling whichever one of the other generate statements is specified in the query obj
get()
group_by(*args) Specify one or more fields for how aggregates should be grouped.
limit(limit) sets object limit to parameter limit
offset(number)
optional_nodes()
order_by(field[, descending]) Specify how the results of the query should be ordered.
preload(*args)
preload_acoustics(*args)
remove_subset(label)
required_nodes()
set_pause() sets pauses in graph
set_properties(**kwargs)
to_csv(path) Same as all, but the results of the query are output to the specified path as a CSV file.
to_json()
all()[source]

Returns all results for the query

Returns:
res_list : list

a list of results from the query

columns(*args)[source]

Add one or more additional columns to the results.

Columns should be Attribute objects.

filter_left_aligned(annotation_type)[source]

Short cut function for aligning the queried annotations with another annotation type.

Same as query.filter(g.word.begin == g.phone.begin).

filter_not_left_aligned(annotation_type)[source]

Short cut function for aligning the queried annotations with another annotation type.

Same as query.filter(g.word.begin != g.phone.begin).

filter_not_right_aligned(annotation_type)[source]

Short cut function for aligning the queried annotations with another annotation type.

Same as query.filter(g.word.end != g.phone.end).

filter_right_aligned(annotation_type)[source]

Short cut function for aligning the queried annotations with another annotation type.

Same as query.filter(g.word.end == g.phone.end).

set_pause()[source]

sets pauses in graph