Commit 084a41a7 by Chris Johnson
parents eb2f2d6f fd91c0cb
WikiWikiHow.py - contains code to creates the user interface, including a window to enter query and filters, along with the display of results. TO USE WikiWikiHow, type: python3 WikiWikiHow.py
SearchResults.py
- SearchResults class, which takes query and filters input and returns a list of Article objects that match the query and filters
- Article class, each instance of which corresponds to one article in the SearchResults output. Articles also contain lists of related articles, which are filtered by relevance.
- OuterArticle class, which allows for some filtering to be done before BeautifulSoup objects are made. This saves computational power.
old - a directory containing old test files and individual group members' work that was later added to the main file
inappropriate_words.py - contains a function that creates a list of words that will be selected out if Child Safe mode is turned on. I would advise against opening this file since it's basically just a very long list of vulgar words.
......@@ -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):
......
......@@ -35,7 +35,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