renamed extract_headline to extract_article, reduced the function cal…#18
Open
riseandshine0 wants to merge 1 commit intoLearning-Python-Team:masterfrom
Open
renamed extract_headline to extract_article, reduced the function cal…#18riseandshine0 wants to merge 1 commit intoLearning-Python-Team:masterfrom
riseandshine0 wants to merge 1 commit intoLearning-Python-Team:masterfrom
Conversation
…l for downloading the article to 1
mandjevant
requested changes
Sep 4, 2019
| try: | ||
| self.article.download() | ||
| self.article.parse() | ||
| return self.article |
Collaborator
There was a problem hiding this comment.
There is no need to return the article since only the connection adapters need to be downloaded and parsed. Returning does not do anything since the article is already defined in self.article.
| self.article.download() | ||
| self.article.parse() | ||
| return self.article | ||
| except newspaper.article.ArticleException: # List possible errors in case of any exception |
Collaborator
There was a problem hiding this comment.
For this issue; #17
We could also simply say;
except newspaper.article.ArticleException as e:
print(e)
| self.neg = [] # Variable to store all negative tokens from negative_headlines.csv file | ||
| self.article = newspaper.Article(self.news_url) | ||
|
|
||
| # extract headline |
|
|
||
| # Initialisations | ||
| def __init__(self): | ||
| self.news_url = input("\nEnter The URL : ") |
Collaborator
There was a problem hiding this comment.
We should consider working with config files, requirement files and readme.md's from now on. This improves readability, efficiency and minimizes the chance someone fricks with the code.
|
|
||
| # main of class | ||
| def main(self): | ||
| article = self.extract_article() |
Collaborator
There was a problem hiding this comment.
Why would you define article here if self.article is already initiated?
There are 2 ways around this;
- Instead of
article = self.extract_article()sayself.extract_article() - In
def __init__makeself.article = self.extract_article()where the entired article is initiated, downloaded and parsed. Here you would want the return.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…l for downloading the article to 1