Skip to content

Commit b037610

Browse files
authored
Merge pull request #688 from flairNLP/add-sankei-shimbun
Add `SankeiShimbun`
2 parents e4bc23d + 7565644 commit b037610

File tree

6 files changed

+190
-6
lines changed

6 files changed

+190
-6
lines changed

docs/supported_publishers.md

+15
Original file line numberDiff line numberDiff line change
@@ -1299,6 +1299,21 @@
12991299
<td>&#160;</td>
13001300
<td>&#160;</td>
13011301
</tr>
1302+
<tr>
1303+
<td>
1304+
<code>SankeiShimbun</code>
1305+
</td>
1306+
<td>
1307+
<div>Sankei Shimbun</div>
1308+
</td>
1309+
<td>
1310+
<a href="https://www.sankei.com/">
1311+
<span>www.sankei.com</span>
1312+
</a>
1313+
</td>
1314+
<td>&#160;</td>
1315+
<td>&#160;</td>
1316+
</tr>
13021317
<tr>
13031318
<td>
13041319
<code>TheJapanNews</code>

src/fundus/publishers/jp/__init__.py

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
from fundus.publishers.base_objects import Publisher, PublisherGroup
2-
from fundus.publishers.jp.asahi_shimbun import AsahiShimbunParser
3-
from fundus.publishers.jp.mainichi_shimbun import MainichiShimbunParser
4-
from fundus.publishers.jp.nikkei import NikkeiParser
5-
from fundus.publishers.jp.the_japan_news import TheJapanNewsParser
6-
from fundus.publishers.jp.tokyo_chunichi_shimbun import TokyoChunichiShimbunParser
7-
from fundus.publishers.jp.yomiuri_shimbun import YomiuriShimbunParser
82
from fundus.scraping.filter import inverse, regex_filter
93
from fundus.scraping.url import NewsMap, RSSFeed, Sitemap
104

5+
from .asahi_shimbun import AsahiShimbunParser
6+
from .mainichi_shimbun import MainichiShimbunParser
7+
from .nikkei import NikkeiParser
8+
from .sankei_shimbun import SankeiShimbunParser
9+
from .the_japan_news import TheJapanNewsParser
10+
from .tokyo_chunichi_shimbun import TokyoChunichiShimbunParser
11+
from .yomiuri_shimbun import YomiuriShimbunParser
12+
1113

1214
class JP(metaclass=PublisherGroup):
1315
TheJapanNews = Publisher(
@@ -74,3 +76,13 @@ class JP(metaclass=PublisherGroup):
7476
)
7577
],
7678
)
79+
80+
SankeiShimbun = Publisher(
81+
name="Sankei Shimbun",
82+
domain="https://www.sankei.com/",
83+
parser=SankeiShimbunParser,
84+
sources=[
85+
# The Google sitemap https://www.sankei.com/feeds/google-sitemapindex/ is included here as well
86+
NewsMap("https://www.sankei.com/feeds/sitemapindex-category/?outputType=xml"),
87+
],
88+
)
+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import datetime
2+
import re
3+
from typing import List, Optional
4+
5+
from lxml.cssselect import CSSSelector
6+
from lxml.etree import XPath
7+
8+
from fundus.parser import ArticleBody, BaseParser, Image, ParserProxy, attribute
9+
from fundus.parser.utility import (
10+
extract_article_body_with_selector,
11+
generic_author_parsing,
12+
generic_date_parsing,
13+
generic_nodes_to_text,
14+
generic_topic_parsing,
15+
image_extraction,
16+
)
17+
18+
19+
class SankeiShimbunParser(ParserProxy):
20+
class V1(BaseParser):
21+
_paragraph_selector = XPath(
22+
"//div[contains(@class, 'article-body')] "
23+
"/p[contains(@class, 'article-text ') and (text() or not(child::a))]"
24+
)
25+
_subheadline_selector = CSSSelector("div.article-body > h2")
26+
27+
_topic_selector = CSSSelector("ul.section-list > li")
28+
29+
@attribute
30+
def body(self) -> Optional[ArticleBody]:
31+
return extract_article_body_with_selector(
32+
self.precomputed.doc,
33+
paragraph_selector=self._paragraph_selector,
34+
subheadline_selector=self._subheadline_selector,
35+
)
36+
37+
@attribute
38+
def title(self) -> Optional[str]:
39+
return self.precomputed.meta.get("og:title")
40+
41+
@attribute
42+
def authors(self) -> List[str]:
43+
return [
44+
author for author in generic_author_parsing(self.precomputed.meta.get("author")) if "産経新聞" not in author
45+
]
46+
47+
@attribute
48+
def publishing_date(self) -> Optional[datetime.datetime]:
49+
return generic_date_parsing(self.precomputed.ld.bf_search("datePublished"))
50+
51+
@attribute
52+
def topics(self) -> List[str]:
53+
if topic_nodes := self._topic_selector(self.precomputed.doc):
54+
return generic_topic_parsing("・".join(generic_nodes_to_text(topic_nodes)), "・")
55+
return []
56+
57+
@attribute
58+
def images(self) -> List[Image]:
59+
return image_extraction(
60+
doc=self.precomputed.doc,
61+
paragraph_selector=self._paragraph_selector,
62+
lower_boundary_selector=CSSSelector("div.article-footer-wrapper"),
63+
# https://regex101.com/r/gljUs9/1
64+
author_selector=re.compile(r"(.*?(?P<credits>[^(、]*?)撮影)"),
65+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
{
2+
"V1": {
3+
"authors": [
4+
"大渡 美咲"
5+
],
6+
"body": {
7+
"summary": [],
8+
"sections": [
9+
{
10+
"headline": [],
11+
"paragraphs": [
12+
"昨年の元日に起きた能登半島地震を受け、救出救助活動に不可欠な警察の情報通信環境の整備が全国で進められる中、このほど、警視庁管内の警察無線不感地帯の解消が図られた。警察では万一に備え、幾重にも情報通信システムが確保されているが、今後も、それらの環境改善を図っていくといい、住民らの安心感につなげたい考えだ。"
13+
]
14+
},
15+
{
16+
"headline": [
17+
"アンテナ改善で解消"
18+
],
19+
"paragraphs": [
20+
"能登半島地震を受け東京都警察情報通信部(都通)が警視庁管内の11の有人島で、警察無線の環境調査を実施した。その結果、小笠原諸島の母島で、不感地帯が確認されたという。母島では、沖港周辺以外は不感地帯が多く、携帯電話も圏外が目立った。",
21+
"母島にある唯一の小笠原署母島駐在所に勤務しているのは、荻田卓警部補(41)と小沢俊介巡査部長(41)。2人によると、遭難事故や台風に伴う土砂崩れによる通行止めが発生した際には携帯電話や警察無線が通じる場所までパトカーなどで何度も往復しながら活動を行うケースもあったという。",
22+
"このため、調査結果を踏まえ、都通は3回に渡り、機動通信1課の吉田孝太技官(23)を母島に派遣して、無線通話試験を繰り返した。そして昨年7月にはパトカーの無線やアンテナを改善するなどして全ての警察無線の不感地帯を解消させたという。「迅速な対応につながる」。島民の商店経営、前田豊さん(56)からも安堵の声が漏れる。",
23+
"場所によっては、今後もアンテナの角度調整など駐在員による「作業」も必要になるが、これで約50キロ離れた父島にある小笠原署や1050キロ離れた警視庁本部と直接通話が可能となった。荻田警部補は「新たな手法を最大限活用できるよう日々訓練したい」と話している。"
24+
]
25+
},
26+
{
27+
"headline": [
28+
"停電や道路寸断、課題解決へ"
29+
],
30+
"paragraphs": [
31+
"警察では、警察無線だけではなく、電気通信事業者の専用回線や衛星通信回線など幾重にも通信手段を確保。警察庁によると、阪神大震災や東日本大震災、能登半島地震など過去の大きな地震発生時でも警察無線は途絶えることなく機能してきたという。",
32+
"一方、災害時に浮かび上がった課題の解消にも警察は力を入れる。",
33+
"平成30年に起きた北海道胆振東部地震では、北海道全域が停電するブラックアウトが発生。停電時は無線中継所は非常用発電に切り替わるが、停電が長引けば発電に必要な燃料の枯渇も想定された。このため、全国で燃料タンクの大型化が進められたという。",
34+
"東日本大震災や能登半島地震では、道路網が寸断されるなどし、技官らが徒歩で山を上ったり、ヘリで降下したりして、非常用発電の燃料補給を支えた。その経験を踏まえて日ごろから都道府県警と技官らが連携し、ヘリ降下訓練などを実施する体制も強化している。"
35+
]
36+
}
37+
]
38+
},
39+
"images": [
40+
{
41+
"versions": [
42+
{
43+
"url": "https://www.sankei.com/resizer/Tii6Nvyl1QRJ4Xz09QQvazkUoCg=/1200x0/smart/filters:quality(40)/cloudfront-ap-northeast-1.images.arcpublishing.com/sankei/C5TD7WETVJI4PD34ZPGQDC5SJM.jpg",
44+
"query_width": null,
45+
"size": {
46+
"width": 1200,
47+
"height": 0
48+
},
49+
"type": "image/jpeg"
50+
}
51+
],
52+
"is_cover": true,
53+
"description": "新型無線機を搭載したパトカーを使い、母島で通話試験を行う都通機動通信1課の吉田孝太技官(警視庁提供)",
54+
"caption": "新型無線機を搭載したパトカーを使い、母島で通話試験を行う都通機動通信1課の吉田孝太技官(警視庁提供)",
55+
"authors": [],
56+
"position": 487
57+
},
58+
{
59+
"versions": [
60+
{
61+
"url": "https://www.sankei.com/resizer/BP5e_8MyiagHLJ0UnJevOT0Bo6Q=/0x224/smart/filters:quality(70)/cloudfront-ap-northeast-1.images.arcpublishing.com/sankei/DW65IVHR65OKVCZ73WSAZCVUPQ.jpg",
62+
"query_width": null,
63+
"size": {
64+
"width": 0,
65+
"height": 0
66+
},
67+
"type": "image/jpeg"
68+
}
69+
],
70+
"is_cover": false,
71+
"description": null,
72+
"caption": null,
73+
"authors": [],
74+
"position": 524
75+
}
76+
],
77+
"publishing_date": "2025-01-21 20:50:32+09:00",
78+
"title": "小笠原諸島の警察無線「不感地帯」解消 以前は電波を探し警察官が往復 住民から安堵の声",
79+
"topics": [
80+
"社会",
81+
"地震",
82+
"災害",
83+
"地方",
84+
"関東",
85+
"東京"
86+
]
87+
}
88+
}
Binary file not shown.

tests/resources/parser/test_data/jp/meta.info

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"url": "https://www.nikkei.com/article/DGXZQOUB148MY0U5A110C2000000/",
1616
"crawl_date": "2025-01-27 16:41:04.576095"
1717
},
18+
"SankeiShimbun_2025_01_21.html.gz": {
19+
"url": "https://www.sankei.com/article/20250121-QBJP5I25BBIG5IZ76XZNDHDB5Q/",
20+
"crawl_date": "2025-01-21 14:16:41.656839"
21+
},
1822
"TheJapanNews_2024_10_13.html.gz": {
1923
"url": "https://japannews.yomiuri.co.jp/politics/politics-government/20241013-216478/",
2024
"crawl_date": "2024-10-13 16:27:01.520980"

0 commit comments

Comments
 (0)