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
eZ dS ) )absolute_import)print_function)unicode_literals)reduce )nameZsummarydescriptionZurlc C s" t | }dg|| t| }|S )z, Ordered sset with empty strings prepended. )lensorted)ZssetZlengthZcurrentl 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 ZdddZ
dd ZdS )MatchCounterzMap 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 )getattrWEIGHTS)matchkeyneedleZhaystack)pkgr r weight4 s
z*MatchCounter._eval_weights..weight)summap)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)
setdefaultappend)r r r r r r r addZ s zMatchCounter.addc C s&