-
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 indian publisher Bhaskar
#605
Merged
Merged
Changes from 1 commit
Commits
Show all changes
3 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,40 @@ | ||
import datetime | ||
from typing import List, Optional | ||
|
||
from lxml.etree import XPath | ||
|
||
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 BhaskarParser(ParserProxy): | ||
class V1(BaseParser): | ||
_paragraph_selector = XPath("//article //p[text()]") | ||
|
||
@attribute | ||
def body(self) -> ArticleBody: | ||
return extract_article_body_with_selector( | ||
doc=self.precomputed.doc, | ||
paragraph_selector=self._paragraph_selector, | ||
) | ||
|
||
@attribute | ||
def publishing_date(self) -> Optional[datetime.datetime]: | ||
return generic_date_parsing(self.precomputed.ld.bf_search("datePublished")) | ||
|
||
@attribute | ||
def authors(self) -> List[str]: | ||
return generic_author_parsing(self.precomputed.ld.bf_search("author")) | ||
|
||
@attribute | ||
def title(self) -> Optional[str]: | ||
return self.precomputed.ld.bf_search("headline") | ||
|
||
@attribute | ||
def topics(self) -> List[str]: | ||
return generic_topic_parsing(self.precomputed.ld.bf_search("keywords")) |
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,27 @@ | ||
{ | ||
"V1": { | ||
"authors": [ | ||
"दैनिक भास्कर" | ||
], | ||
"body": { | ||
"summary": [], | ||
"sections": [ | ||
{ | ||
"headline": [], | ||
"paragraphs": [ | ||
"मैनपुरी में एक ट्रक ने बाइक सवार को रौंद दिया। हादसे में पति-पत्नी और बच्चे की मौत हो गई। हादसे के बाद ट्रक ड्राइवर मौके से फरार हो गया। मौके पर भीड़ जुट गई। लोगों ने पुलिस को सूचना दी। पुलिस ने शवों को पोस्टमॉर्टम के लिए भेज दिया।", | ||
"सूचना पर पहुंचे परिजनों में कोहराम मच गया। हादसा सदर कोतवाली क्षेत्र में स्थित राधा रमन रोड पेट्रोल पंप के पास हुआ। मृतक की पहचान फर्रुखाबाद के शमशाबाद थाना क्षेत्र निवासी आजम के रूप में हुई। उनकी पत्नी और बेटा भी गाड़ी पर पीछे बैठे थे।", | ||
"मौके पर पहुंच परिजनों ने बताया कि आजम अपनी बाइक पर अपनी पत्नी और बच्चे को लेकर मैनपुरी में निर्माणाधीन कोल्ड स्टोरेज में मजदूरी करने के लिए अपने घर से निकले थे। जैसे ही वह राधा रमन रोड पेट्रोल पंप के सामने पहुंचे। वैसे ही पीछे से आ रहे तेज रफ्तार डंपर ट्रक ने उनकी बाइक को रौंद दिया।", | ||
"मौके पर ही तीनों की मौत हो गई। परिजन ने आगे बताया कि आजम और उसकी पत्नी एक साथ मजदूरी करते थे। इसी से उनका घर चलता था। आज अपने बेटे को भी साथ ले जा रहे थे।" | ||
] | ||
} | ||
] | ||
}, | ||
"publishing_date": "2024-09-03 20:46:01+05:30", | ||
"title": "सड़क हादसे में पति-पत्नी सहित बच्चे की मौत: मैनपुरी में अनियंत्रित ट्रक ने रौंदा, बाइक से तीनों जा रहे थे", | ||
"topics": [ | ||
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 would also consider filtering topics containting |
||
"bhaskar news", | ||
"mainpuri news" | ||
] | ||
} | ||
} |
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.
There are some articles that have subheadlines, such as this one. It is clearer in the HTML:
You might have to copy and paste it out of here. But there are some sections like this one:
<p class="" style="word-break:break-word"><strong>सवाल : पेपर कहां छपेंगे, ये फैसला कौन और कैसे करता है?</strong></p>
that seem to be a subheadline. The text translates to
question: Who decides where the papers will be printed and how?
, which does suggest it could be a subheadline as well. At the moment lines like this are not parsed at all.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.
I removed the
text()
constraint fromp
again, so those should be parsed again. Additionally, I think there is no reliable way to distinguish between subheadlines and bloat, and thus no way to differentiate between paragraphs and subheadings. I will add them as simple paragraphs.