ó i;sSc@s|dZddlmZddlmZddlmZdefd„ƒYZdefd„ƒYZd efd „ƒYZ d S( s'Josu Bermudez i(tSieve(t stopwords(tpos_tagstStrictHeadMatchingcBseeZdZeZeZeZeZd„Zd„Z d„Z d„Z d„Z d„Z d„ZRS(tSHMc Cs\tj||||ƒstSg|j|ƒD])}g|D]}|jj|^q9^q,}g|D]}|jj|^qb}|jd|d|ƒr®|jd|dƒtS|jd|d|ƒsÞ|jd|dƒtS|j d|d|d|ƒs|jd |dƒtS|j d|d|ƒsD|jd |dƒtS|jd |dƒt S( Nt mention_at mention_bs)LINK FILTERED I within I construction: %stformtmentiontcandidate_entitiessLINK FILTERED No head match: %stentitys#LINK FILTERED No word inclusion: %ss(LINK FILTERED Incompatible modifiers: %ssLINK MATCH: %s( Rtare_coreferenttFalsetentities_of_a_mentiontgraphtnodet i_within_itdebugtentity_head_matchtword_inclusiontcompatible_modifiers_onlytTrue( tselfR Rt candidatetcandidate_entitytcandidate_mentionR tmtentity_mentions((s2corefgraph/multisieve/sieves/strictHeadMatching.pyR s.<#        cCs|jj|ƒ}|dS(NR(t graph_buildert get_head_word(Rtelementthead((s2corefgraph/multisieve/sieves/strictHeadMatching.pytget_head_word_form9scCse|j|ƒ}tg|jj|ƒD])}tj|dƒr%|djƒ^q%ƒt|ƒ}|S(NtposR(R tsetRt get_wordsRt mod_formstlower(RRt element_headtwordtall_mods((s2corefgraph/multisieve/sieves/strictHeadMatching.pyt get_modifiersCs6cCs9tg|jj|ƒD]}|djƒ^qƒ}|S(NR(R"RR#R%(RRR't all_words((s2corefgraph/multisieve/sieves/strictHeadMatching.pyt get_all_wordNs5cCsZ|j|ƒjƒ}x>|D]6}x-|D]%}|j|ƒjƒ|kr)tSq)WqWtS(N(R R%RR (RRR tmention_head_wordRtcandidate_entity_mention((s2corefgraph/multisieve/sieves/strictHeadMatching.pyRWs    c Csátg|D]<}|D]/}|jj|ƒD]}|djƒ^q*qq ƒ}tg|D]/}|jj|ƒD]}|djƒ^qoqYƒ} | j|j|ƒjƒƒ| jtjƒ| jtj ƒt | |ƒdkS(NRi( R"RR#R%tremoveR tdifference_updateRtextended_stop_wordst stop_wordstlen( RR RR RRR'tcandidate_wordst n_mentiont entity_words((s2corefgraph/multisieve/sieves/strictHeadMatching.pyRes  5 2c CsŸx˜|D]}x‡|D]}xv|D]n}|j|ƒ}|j|ƒ}x-tjD]"}||krO||krOtSqOWt||ƒdkr!tSq!WqWqWtS(Ni(R+R)Rtlocation_modifiersR R2R( RR R RRtentity_mentionR3tmention_modifierstlocation_modifier((s2corefgraph/multisieve/sieves/strictHeadMatching.pyR|s   (t__name__t __module__t sort_nameRtONLY_FIRST_MENTIONt NO_PRONOUNtDISCOURSE_SALIENCEt NO_STOP_WORDSR R R)R+RRR(((s2corefgraph/multisieve/sieves/strictHeadMatching.pyRs "  tStrictHeadMatchingVariantAcBseZdZd„ZRS(tSHMAcCstS(N(R(RR R ((s2corefgraph/multisieve/sieves/strictHeadMatching.pyR”s(R:R;R<R(((s2corefgraph/multisieve/sieves/strictHeadMatching.pyRAstStrictHeadMatchingVariantBcBseZdZd„ZRS(tSHMBcCstS(N(R(RR RR ((s2corefgraph/multisieve/sieves/strictHeadMatching.pyR£s(R:R;R<R(((s2corefgraph/multisieve/sieves/strictHeadMatching.pyRCžsN( t __author__tmultisieve.sieves.baseRtresources.dictionariesRtresources.tagsetRRRARC(((s2corefgraph/multisieve/sieves/strictHeadMatching.pyts