# NOT RUN {
## This function is best used after first annotating regular quotes
## Here we first apply 3 tqueries for annotating quotes in spacy tokens
# }
# NOT RUN {
tokens = tokens_spacy[tokens_spacy$doc_id == 'text6',]
verbs = c("tell", "show", "acknowledge", "admit", "affirm", "allege",
"announce", "assert", "attest", "avow", "call", "claim", "comment",
"concede", "confirm", "declare", "deny", "exclaim", "insist", "mention",
"note", "post","predict", "proclaim", "promise", "reply", "remark",
"report", "say", "speak", "state", "suggest", "talk", "tell", "think",
"warn","write", "add")
direct = tquery(lemma = verbs, label='verb',
children(req=FALSE, relation = c('npadvmod'), block=TRUE),
children(relation=c('su','nsubj','agent','nmod:agent'), label='source'),
children(label='quote'))
nosrc = tquery(pos='VERB*',
children(relation= c('su', 'nsubj', 'agent', 'nmod:agent'), label='source'),
children(lemma = verbs, relation='xcomp', label='verb',
children(relation=c("ccomp","dep","parataxis","dobj","nsubjpass","advcl"), label='quote')))
according = tquery(label='quote',
children(relation='nmod:according_to', label='source',
children(label='verb')))
tokens = annotate_tqueries(tokens, 'quote', dir=direct, nos=nosrc, acc=according)
tokens
## now we add the span quotes. If a span quote is found, the algorithm will first
## look for already annotated sources as source candidates. If there are none,
## additional tqueries can be used to find candidates. Here we simply look for
## the most recent PERSON entity
tokens = tokens_spacy[tokens_spacy$doc_id == 'text6',]
tokens = annotate_tqueries(tokens, 'quote', dir=direct, nos=nosrc, acc=according)
last_person = tquery(entity = 'PERSON*', label='source')
tokens = add_span_quotes(tokens, 'token',
quote_col = 'quote', source_val = 'source', quote_val = 'quote',
tqueries=last_person)
tokens
## view as full text
syntax_reader(tokens, annotation = 'quote', value = 'source')
# }
Run the code above in your browser using DataLab