-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add The Globe and Mail #587
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import datetime | ||
from typing import List, Optional | ||
|
||
from lxml.cssselect import CSSSelector | ||
|
||
from fundus.parser import ArticleBody, BaseParser, ParserProxy, attribute | ||
from fundus.parser.utility import ( | ||
extract_article_body_with_selector, | ||
generic_author_parsing, | ||
generic_date_parsing, | ||
generic_topic_parsing, | ||
) | ||
|
||
|
||
class TheGlobeAndMailParser(ParserProxy): | ||
class V1(BaseParser): | ||
_subheadline_selector = CSSSelector("article > h4") | ||
_paragraph_selector = CSSSelector("article > p") | ||
|
||
@attribute | ||
def body(self) -> ArticleBody: | ||
return extract_article_body_with_selector( | ||
self.precomputed.doc, | ||
subheadline_selector=self._subheadline_selector, | ||
paragraph_selector=self._paragraph_selector, | ||
) | ||
|
||
@attribute | ||
def authors(self) -> List[str]: | ||
return generic_author_parsing(self.precomputed.ld.bf_search("author")) | ||
|
||
@attribute | ||
def publishing_date(self) -> Optional[datetime.datetime]: | ||
return generic_date_parsing(self.precomputed.ld.bf_search("datePublished")) | ||
|
||
@attribute | ||
def title(self) -> Optional[str]: | ||
return self.precomputed.meta.get("og:title") | ||
|
||
@attribute | ||
def topics(self) -> List[str]: | ||
topic_list = [topic.lower() for topic in generic_topic_parsing(self.precomputed.meta.get("keywords"))] | ||
topic_set = set(topic_list) | ||
topic_duplicates = list(topic_list) | ||
for element in topic_set: | ||
topic_duplicates.remove(element) | ||
for duplicate in topic_duplicates: | ||
topic_list.remove(duplicate) | ||
return [topic.title() for topic in topic_list if "news" not in topic] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"V1": { | ||
"authors": [ | ||
"Reuters" | ||
], | ||
"body": { | ||
"summary": [], | ||
"sections": [ | ||
{ | ||
"headline": [], | ||
"paragraphs": [ | ||
"Cannabis firm Canopy Growth WEED-T said on Friday its CEO, David Klein, will retire at the end of the company’s current fiscal year on March 31.", | ||
"Klein was appointed as Canopy Growth’s chairman when the then co-CEO and founder Bruce Linton was fired in 2019.", | ||
"The announcement comes just days after the company reported a smaller-than-expected core loss and pointed to easing doubts around its ability to continue as a going concern.", | ||
"The company had raised doubts about its ability to continue as a going concern last year as it struggled to turn profitable. It later sold its sports nutrition products unit, Biosteel, after seeking bankruptcy protection for it.", | ||
"Canopy Growth said it is in the process of securing a search firm to initiate a comprehensive CEO selection process." | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would be nice to use an article including all selectable content (subheadline, paragraphs) as test case. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll keep that in mind for future publishers as well :) |
||
} | ||
] | ||
}, | ||
"publishing_date": "2024-08-16 12:27:08.062000+00:00", | ||
"title": "Canopy Growth CEO David Klein to retire at end of March", | ||
"topics": [ | ||
"Company", | ||
"Process", | ||
"Ability", | ||
"Concern", | ||
"Ceo", | ||
"Klein", | ||
"End", | ||
"Co-Ceo", | ||
"David Klein", | ||
"Canopy Growth Weed-T", | ||
"Bruce Linton" | ||
] | ||
} | ||
} |
Binary file added
BIN
+120 KB
tests/resources/parser/test_data/ca/TheGlobeAndMail_2024_08_16.html.gz
Binary file not shown.
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately this doesn't seem to be a propper
Sitemap
but just anotherNewsMap
since it only dates back one week.