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 ã @ sZ d dl mZ d dl mZ d dl mZ d dlmZ ddddd œZd
d„ ZG dd
„ d
eƒZ dS )é )Úabsolute_import)Úprint_function)Úunicode_literals)Úreduceé é é é )ÚnameZsummaryÚdescriptionZurlc C s" 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" s r c @ sf e Zd ZdZedd„ ƒZdd„ Zdd„ Zdd „ Zd
d„ Z dd
„ Z
dd„ Zdd„ Zddd„Z
dd„ ZdS )ÚMatchCounterz—Map packages to which of their attributes matched in a search against
what values.
The mapping is: ``package -> [(key, needle), ... ]``.
c s ‡ fdd„}t t||ƒƒS )Nc s> | d }| d }t ˆ |ƒ}|dkr6||kr6dt| S t| S )Nr r r
r )ÚgetattrÚWEIGHTS)ÚmatchÚkeyÚneedleZhaystack)Úpkgr r Úweight4 s
z*MatchCounter._eval_weights..weight)ÚsumÚmap)r Zmatchesr r )r r Ú
_eval_weights1 s zMatchCounter._eval_weightsc s ‡ 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)
c s ˆ j | ˆ | ƒ | jfS )N)r r
)r )Úselfr r Úget_keyK s z'MatchCounter._key_func..get_keyr )r r r )r r Ú _key_func? s zMatchCounter._key_funcc s ˆ rt ‡ fdd„ˆ D ƒƒS dS )z0Return the max count of needles of all packages.c 3 s | ]}t ˆ j|ƒƒV qd S )N)r
Úmatched_needles)Ú.0r )r r r ú W s z,MatchCounter._max_needles..r )Úmax)r r )r r Ú_max_needlesT s zMatchCounter._max_needlesc C s | j |g ƒj||fƒ d S )N)Ú
setdefaultÚappend)r r r r r r r ÚaddZ s zMatchCounter.addc C s&