Last active
September 5, 2018 20:34
-
-
Save adambom/432eb9d12c55cc30370ac81f07932391 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NewspaperStyle: | |
def __init__(self, paper, brain, evaluator): | |
self._paper = paper | |
self._brain = brain | |
def read_newspaper(self): | |
self._read_news() | |
self._read_travel() | |
self._read_sports() | |
self._read_funnies() | |
def _read_news(self): | |
self._read_section('news') | |
def _read_section(self, section): | |
articles_to_read = self._scan_headlines(section) | |
for article in articles_to_read: | |
self._read(article) | |
def _scan_headlines(self, section): | |
results = [] | |
for article in self._get_articles_for_section(section): | |
if self._is_interesting(article.headline): | |
results.append(article) | |
return results | |
def _get_articles_for_section(self, section): | |
return self._paper.get_section(section) | |
def _is_interesting(self, headline): | |
return self._brain.finds_interesting(headline) | |
def _read(self, article): | |
for word in article: | |
self._brain.add(word) | |
def _read_travel(self): | |
self._read_section('travel') | |
def _read_sports(self): | |
self._read_section('sports') | |
def _read_funnies(self): | |
self._read_section('funnies') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment