def _detectPossibleKsubcatRelsFromSent( sentence, kSubCatRelsLexicon, reverseMapping = False ):
    ''' Attempts to detect all possible K subcategorization relations from
        given sentence, using the heuristic method _detectKsubcatRelType();
        
        Returns a dictionary of relations where the key corresponds to the
        index of its parent node (the K node) and the value corresponds to 
        index of its child.
        
        If reverseMapping = True, the mapping is reversed: keys correspond
        to children and values correspond to parent nodes (K-s);
    '''
    relationIndex = dict()
    relationType  = dict()
    for i in range(len(sentence)):
        estnltkWord = sentence[i]
        # Pick the first analysis
        firstAnalysis = estnltkWord[ANALYSIS][0]
        if firstAnalysis[POSTAG] == 'K':
            (grammCats, kChild) = _detectKsubcatRelType( sentence, i, kSubCatRelsLexicon )
            if kChild != -1:
                if reverseMapping:
                    relationIndex[ kChild ] = i
                    relationType[ kChild ]  = grammCats
                else:
                    relationIndex[ i ] = kChild
                    relationType[ i ]  = grammCats
    return relationIndex, relationType
def _detectPossibleKsubcatRelsFromSent ( sentence , kSubCatRelsLexicon , reverseMapping = False ) : relationIndex = dict ( ) relationType = dict ( ) for i in range ( len ( sentence ) ) : estnltkWord = sentence [ i ] firstAnalysis = estnltkWord [ ANALYSIS ] [ 0 ] if firstAnalysis [ POSTAG ] == 'K' : ( grammCats , kChild ) = _detectKsubcatRelType ( sentence , i , kSubCatRelsLexicon ) if kChild != - 1 : if reverseMapping : relationIndex [ kChild ] = i relationType [ kChild ] = grammCats else : relationIndex [ i ] = kChild relationType [ i ] = grammCats return relationIndex , relationType
Attempts to detect all possible K subcategorization relations from
        given sentence, using the heuristic method _detectKsubcatRelType();
        
        Returns a dictionary of relations where the key corresponds to the
        index of its parent node (the K node) and the value corresponds to 
        index of its child.
        
        If reverseMapping = True, the mapping is reversed: keys correspond
        to children and values correspond to parent nodes (K-s);