diff options
| author | 2020-02-12 11:35:40 +0000 | |
|---|---|---|
| committer | 2020-02-12 11:35:40 +0000 | |
| commit | a5acf0e3aa42d4f9f690d31fd64af4e5dff2b060 (patch) | |
| tree | 3ff3b7c0f5895fc51db2a18827c21f18fc114e1b | |
| parent | show PR title in pull_request events (diff) | |
| signature | ||
don't similarity test empty <title>s
| -rw-r--r-- | modules/title.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/modules/title.py b/modules/title.py index f70f4785..df05546e 100644 --- a/modules/title.py +++ b/modules/title.py @@ -29,16 +29,17 @@ class Module(ModuleManager.BaseModule): title_word = title_word.lower() title_words.append(title_word.strip("'\"<>()")) - present = 0 - for title_word in title_words: - if title_word in url: - present += 1 + if title_words: + present = 0 + for title_word in title_words: + if title_word in url: + present += 1 - similarity = present/len(title_words) - # if at least 80% of words are in the URL, too similar - if similarity >= 0.8: - return False - return True + similarity = present/len(title_words) + # less than 80% similar, proceed + if similarity < 0.8: + return True + return False def _get_title(self, server, channel, url): if not urllib.parse.urlparse(url).scheme: |
