File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ This block searches for relative clauses modifying a determiner ('el que...').
3
+ It is written for Catalan but a similar block should work for Spanish and other
4
+ Romance languages.
5
+ """
6
+ from udapi .core .block import Block
7
+ import logging
8
+ import re
9
+
10
+ class ElQue (Block ):
11
+
12
+ def process_node (self , node ):
13
+ # We take 'que' as the central node of the construction.
14
+ if node .lemma == 'que' and node .upos == 'PRON' and node .parent .ord > node .ord :
15
+ # We will refer to the parent of 'que' as a verb, although it can be
16
+ # a non-verbal predicate, too.
17
+ que = node
18
+ verb = node .parent
19
+ # Check the lemma of the determiner. The form may vary for gender and number.
20
+ if que .prev_node and que .prev_node .lemma == 'el' :
21
+ el = que .prev_node
22
+ stanford = []
23
+ adp = None
24
+ if el .prev_node and el .prev_node .upos == 'ADP' :
25
+ adp = el .prev_node
26
+ parentstr = 'OTHER'
27
+ if adp .parent == el :
28
+ parentstr = 'el'
29
+ elif adp .parent == que :
30
+ parentstr = 'que'
31
+ elif adp .parent == verb :
32
+ parentstr = 'VERB'
33
+ stanford .append (adp .deprel + '(' + parentstr + ', ADP)' )
34
+ if el .parent == adp :
35
+ parentstr = 'ADP'
36
+ elif el .parent == que :
37
+ parentstr = 'que'
38
+ elif el .parent == verb :
39
+ parentstr = 'VERB'
40
+ else :
41
+ parentstr = 'OTHER'
42
+ stanford .append (el .deprel + '(' + parentstr + ', el)' )
43
+ stanford .append (que .deprel + '(VERB, que)' )
44
+ if verb .parent == adp :
45
+ parentstr = 'ADP'
46
+ elif verb .parent == el :
47
+ parentstr = 'el'
48
+ else :
49
+ parentstr = 'OTHER'
50
+ stanford .append (verb .deprel + '(' + parentstr + ', VERB)' )
51
+ print ('; ' .join (stanford ))
You can’t perform that action at this time.
0 commit comments