Skip to content

Commit 3821624

Browse files
authored
Weigh search results according to where the keywords are found (#182)
1 parent 0318102 commit 3821624

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tldr.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,9 +528,15 @@ def main() -> None:
528528
for word in searchquery:
529529
prob = 0
530530
for line in result:
531-
if word in line and \
532-
(line.startswith('-') or line.startswith('>')):
531+
line = line.lower()
532+
if word in line:
533533
prob += 1
534+
if line.startswith("#"):
535+
prob += 7
536+
elif line.startswith(">"):
537+
prob += 5
538+
elif line.startswith("-"):
539+
prob += 2
534540
if prob > maxprob:
535541
maxprob = prob
536542
page = i

0 commit comments

Comments
 (0)