ó i;sSc@s|dZdZddlmZddlmZmZddlmZddl m Z d dd „ƒYZ d dd „ƒYZ d S(s'Josu Bermudez s 14-11-2012i(tSentenceCandidateExtractor(t ProgressBartFractioni(tsievesiÿÿÿÿ(t getLoggertMultiSieveProcessorcBseZd„Zd„ZRS(cCstdƒ|_| s(t|ƒdkrD|jjdƒtj}nd|kri|jjdƒg}n||_|jƒ|_|jj d|jƒ|jjdg|D] }|^qªƒ|jjd|ƒg|D]}tj|||ƒ^q×|_ dS( Nt multisieveisDefault sievestNOs No sievess Lang code: %ss Sieves: %s sSieves options: %s( RtloggertlentdebugRtdefaulttgraphtlowert lang_codetwarningtsieves_instances(tselfR Rt sieves_listtsieves_optionstsievet sieve_class((scorefgraph/multisieve/core.pyt__init__s    &cCs3|}x&|jD]}|j|||ƒ}qW|S(N(Rtresolve(Rtclusterstcandidates_per_mentiont registerst sieve_inputR((scorefgraph/multisieve/core.pytprocess#s(t__name__t __module__RR(((scorefgraph/multisieve/core.pyRs tCoreferenceProcessorcBsPeZed„Zd„Zd„Zd„Zd„Zd„Ze d„ƒZ RS(cCs±tdƒ|_||_||_|jd|_|jd|_||_td|d|jd|ƒ|_t ||||ƒ|_ g|_ g|_ t ƒ|_tƒ|_dS(NRt graph_buildertutilsR toptions(RRtverboset singletonsR R t graph_utilsRtcandidate_extractorRt multi_sievetmentions_textual_ordertmention_clusterstlisttregistertdictR(RR tlangRRtextractor_optionsR$R#((scorefgraph/multisieve/core.pyR3s      cCs|jS(N(R)(R((scorefgraph/multisieve/core.pyt get_clustersFscCs|jS(N(R)(R((scorefgraph/multisieve/core.pytget_candidatesKscCs®x—|D]}g}x?|D]7}||krG||j|ƒ |}Pq||7}qW||j7}|jj|gƒ||j|<|jj|dƒqW|jj|ƒdS(Ntorig(tindexR(R)tappendRR+textend(Rtconstituent_ordert text_ordertmentiont candidatest mention_list((scorefgraph/multisieve/core.pytadd_candidaturesQs     cCs2|jjd|ƒ\}}}|j||ƒdS(Ntsentence(R&tprocess_sentenceR:(RR;t mentions_bfttmentions_text_ordertmentions_constituent_order((scorefgraph/multisieve/core.pyR<hs c Cs‚|j}|j}d}|jj|j|j|jƒ}d}|r„dtƒg}t d|dt |ƒpoddt ƒj ƒ}nxÎt |ƒD]À\}}|r·|j|dƒng} x=|D]5} |jj| } |j| ƒsÄ| j| ƒqÄqÄW|st | ƒdkr‘|jjddj|ƒd | d |j|ƒ|d7}q‘q‘W|jrk|jƒn|jjd |ƒdS( NisIndexing clusterstwidgetstmaxvalit force_updatet entity_idsEN{0}tmentionstlabelsIndexed clusters: %d(R$R#R'RR)RR+tNoneRRR tTruetstartt enumeratetupdateR tnodetpurgeR3R t add_entitytformattfinishRtinfo( RR$R#tindexed_clusterstcoreference_proposalt progress_barR@R2tentityRDt mention_idtunfiltered_mention((scorefgraph/multisieve/core.pyt resolve_textss2   *  #  cCs|jdtƒS(NRL(tgettFalse(R7((scorefgraph/multisieve/core.pyRL–s( RRRYRR/R0R:R<RWt staticmethodRL(((scorefgraph/multisieve/core.pyR/s     #N((( t __author__t__date__tmultisieve.mentionSelectionRtoutput.progressbarRRtRtloggingRRR(((scorefgraph/multisieve/core.pyts