Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ©ft`Tã@sZddlmZddlmZddlmZddlmZddddd œZd d „ZGd d „d eƒZ dS)é)Úabsolute_import)Úprint_function)Úunicode_literals)Úreduceéééé)ÚnameZsummaryÚ descriptionZurlcCs"t|ƒ}dg||t|ƒ}|S)z, Ordered sset with empty strings prepended. Ú)ÚlenÚsorted)ZssetZlengthZcurrentÚl©rú#/usr/lib/python3.6/match_counter.pyÚ_canonize_string_set"src@sfeZdZdZedd„ƒZdd„Zdd„Zdd „Zd d „Z d d „Z dd„Z dd„Z ddd„Z dd„ZdS)Ú MatchCounterz—Map packages to which of their attributes matched in a search against what values. The mapping is: ``package -> [(key, needle), ... ]``. cs‡fdd„}tt||ƒƒS)Ncs>|d}|d}tˆ|ƒ}|dkr6||kr6dt|St|S)Nrr r r)ÚgetattrÚWEIGHTS)ÚmatchÚkeyÚneedleZhaystack)ÚpkgrrÚweight4s   z*MatchCounter._eval_weights..weight)ÚsumÚmap)rZmatchesrr)rrÚ _eval_weights1s zMatchCounter._eval_weightscs‡fdd„}|S)aŒGet the key function used for sorting matches. It is not enough to only look at the matches and order them by the sum of their weighted hits. In case this number is the same we have to ensure that the same matched needles are next to each other in the result. Returned function is: pkg -> (weights_sum, canonized_needles_set, -distance) csˆj|ˆ|ƒ |jfS)N)rr )r)ÚselfrrÚget_keyKsz'MatchCounter._key_func..get_keyr)rrr)rrÚ _key_func?s zMatchCounter._key_funccsˆrt‡fdd„ˆDƒƒSdS)z0Return the max count of needles of all packages.c3s|]}tˆj|ƒƒVqdS)N)r Úmatched_needles)Ú.0r)rrrú Wsz,MatchCounter._max_needles..r)Úmax)rr)rrÚ _max_needlesTszMatchCounter._max_needlescCs|j|gƒj||fƒdS)N)Ú setdefaultÚappend)rrrrrrrÚaddZszMatchCounter.addcCs&x |D]}td|||fƒqWdS)Nz%s %s)Úprint)rrrrrÚdump]s zMatchCounter.dumpcst‡fdd„|ˆDƒƒS)Nc3s|]}tˆ|dƒVqdS)rN)r)r"Úm)rrrr#bsz1MatchCounter.matched_haystacks..)Úset)rrr)rrÚmatched_haystacksaszMatchCounter.matched_haystackscCs6g}x,||D] }|d|kr q|j|dƒqW|S)Nr)r')rrÚresultÚirrrÚ matched_keysds  zMatchCounter.matched_keyscCstdd„||DƒƒS)Ncss|]}|dVqdS)r Nr)r"r+rrrr#nsz/MatchCounter.matched_needles..)r,)rrrrrr!mszMatchCounter.matched_needlesFNcCs |r|n|jƒ}t||jƒd�S)N)r)Úkeysrr )rÚreverseZlimit_tor1rrrrpszMatchCounter.sortedcst‡fdd„ˆdƒS)Ncs|tˆ|ƒS)N)r )Útotalr)rrrÚusz$MatchCounter.total..r)r)rr)rrr3tszMatchCounter.total)FN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú staticmethodrr r%r(r*r-r0r!rr3rrrrr)s   rN) Z __future__rrrÚ functoolsrrrÚdictrrrrrÚs