Commit fd91c0cb by Michelle Awh

fixed child safety issue

parent 45d8ae55
......@@ -172,9 +172,8 @@ class SearchResults:
def passes_all_filters(self, article):
if 'Main-Page' in article.url:
return False
if 'child_safe' in self.__filters:
if self.__filters['child_safe']:
self.__forbidden_words += inappropriate_words_lst
if self.__filters['child_safe']:
self.__forbidden_words += inappropriate_words_lst
if 'pct_helpful' in self.__filters:
try:
if int(article.pct_helpful) < self.__filters['pct_helpful']:
......@@ -194,13 +193,13 @@ class SearchResults:
for w in self.__required_words:
W = w[0].upper() + w[1:]
wl = w[0].lower() + w[1:]
if W not in article.words and wl not in article.words:
if W not in article.words_lst and wl not in article.words_lst:
return False
if len(self.__forbidden_words) != 0:
for w in self.__forbidden_words:
W = w[0].upper() + w[1:]
wl = w[0].lower() + w[1:]
if W in article.words or wl in article.words:
if W in article.words_lst or wl in article.words_lst:
return False
if self.__filters['q_verif']:
try:
......@@ -280,7 +279,7 @@ class Article:
self.languages = self.find_languages(self.__soup)
self.verif = self.expert_data(self.__soup)
self.view = self.__repr__()
self.words = self.scrape_words(self.url, self.__soup)
self.words, self.words_lst = self.scrape_words(self.url, self.__soup)
self.tags = self.find_common_words(self.words)
self.link_family = self.all_peripheral_links(self.__soup, self.url)
self.related_articles = []
......@@ -450,7 +449,7 @@ class Article:
for x in t:
x = x.strip()
text.append(x)
return " ".join(text)
return (" ".join(text), text)
def all_peripheral_links(self, soup, url):
......
......@@ -36,7 +36,7 @@ def __main__(filters = {}):
[sg.Spin([i for i in range(100)], initial_value=0, key = "num_voters"), sg.Text('Number of people who voted on helpfulness')],
[sg.Spin([i for i in range(100)], initial_value=0, key = "num_sources"), sg.Text('Number of sources cited')],
[sg.Spin([i for i in range(100)], initial_value=0, key = "num_views"), sg.Text('Views')],
[sg.Combo(['English', 'Español', 'Português', 'Italiano', 'Français', 'русский язык', 'Deutsch', '简体中文', 'Nederlands', 'Čeština', 'Bahasa', '日本語', 'हिंदी', 'ภาษาไทย',' العَرَبِيةُ', 'Tiếng Việt', '한국말', 'Türkçe',' فارسی'], key = 'language'), sg.Text('Available in')]]
[sg.Combo(['Español', 'Português', 'Italiano', 'Français', 'русский язык', 'Deutsch', '简体中文', 'Nederlands', 'Čeština', 'Bahasa', '日本語', 'हिंदी', 'ภาษาไทย',' العَرَبِيةُ', 'Tiếng Việt', '한국말', 'Türkçe',' فارسی'], key = 'language'), sg.Text('Available in (Defaults to English)')]]
window = sg.Window('WikiHow Search and Filters', layout)
results_pg_active = False
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment