def how_many_infinitives(urn: str, is_csm: bool) -> int: """ Gives back the number of infinitives in the text. """ aql: str = 'feats=/.*Inf.*/ ->dep[deprel=/(nsubj|nsubj:pass|csubj|csubj:pass)/] feats=/.*Acc.*/' node_ids: List[str] = CorpusService.find_matches(urn, aql, is_csm=is_csm) aql = 'feats=/.*Acc.*/ ->dep[deprel=/(xcomp|ccomp)/] feats=/.*Inf.*/' node_ids += CorpusService.find_matches(urn, aql, is_csm=is_csm) return round(len(node_ids) / 2)
def how_many_ablativi_absoluti(urn: str, is_csm: bool) -> int: """ Gives back the number of ablativi absoluti in the text. """ aql: str = "tok ->dep[deprel=/(nsubj|nsubj:pass|csubj|csubj:pass)/] feats=/.*Abl.*/" node_ids: List[str] = CorpusService.find_matches(urn, aql, is_csm=is_csm) return round(len(node_ids) / 2)
def how_many_participles(urn: str, is_csm: bool) -> int: """Gives back how many participles are in the text""" aql: str = "feats=/.*VerbForm=Part.*/" node_ids: List[str] = CorpusService.find_matches(urn, aql, is_csm=is_csm) return len(node_ids)
def how_many_sub_clauses(urn: str, is_csm: bool) -> int: """Gives back the number of subordinate clauses in the text. """ aql: str = 'tok ->dep[deprel=/(acl|advcl|ccomp|xcomp)/] upostag="VERB"' node_ids: List[str] = CorpusService.find_matches(urn, aql, is_csm=is_csm) # TODO: degree of sub clauses; ellipsis not counted return round(len(node_ids) / 2)
def how_many_main_clauses(urn: str, is_csm: bool) -> int: """ Gives back how many clauses are in the text. """ # TODO: ellipsis not counted aql: str = "deps" node_ids: List[str] = CorpusService.find_matches(urn, aql, is_csm=is_csm) return len(node_ids)
def how_many_gerunds(urn: str, is_csm: bool) -> int: """ Gives back the number of gerunds in the text. """ aql: str = "feats=/.*VerbForm=Ger.*/" node_ids: List[str] = CorpusService.find_matches(urn, aql, is_csm=is_csm) # TODO: gerundivo return len(node_ids)
def get(self): """ Returns matches from ANNIS for a given CTS URN and AQL. """ # get request arguments args: dict = flask.request.args urn: str = args["urn"] aql: str = args["aql"] return NetworkService.make_json_response( CorpusService.find_matches(urn, aql, is_csm=True))