reverse sorting and change upper letter multiplier
This commit is contained in:
parent
e9ad3efbeb
commit
0d35f715f4
|
@ -43,12 +43,12 @@ class FileScanner(HTMLParser):
|
||||||
if len(word) <= 3:
|
if len(word) <= 3:
|
||||||
score //= 2
|
score //= 2
|
||||||
upper_letters_count = len(upper_check.findall(tag_name))
|
upper_letters_count = len(upper_check.findall(tag_name))
|
||||||
score *= upper_letters_count
|
score += upper_letters_count * 5
|
||||||
if word not in words_with_usage:
|
if word not in words_with_usage:
|
||||||
words_with_usage[word] = Tag(name=tag_name, score=score)
|
words_with_usage[word] = Tag(name=tag_name, score=score)
|
||||||
else:
|
else:
|
||||||
words_with_usage[word].score += score
|
words_with_usage[word].score += score
|
||||||
sorted_list = sorted(words_with_usage.values(), key=lambda tag: tag.score, reverse=False)
|
sorted_list = sorted(words_with_usage.values(), key=lambda tag: tag.score, reverse=True)
|
||||||
display_result(sorted_list)
|
display_result(sorted_list)
|
||||||
|
|
||||||
def handle_starttag(self, tag, attrs):
|
def handle_starttag(self, tag, attrs):
|
||||||
|
|
Loading…
Reference in a new issue