Skip to main content

dajare search

Project description

dajare

皆さんに が訪れる駄洒落の 検索(Search) を行うスクリプトと、駄洒落の 玄人 になりたい人向けにWebサイトからデータをの クロール し駄洒落データベースを構築するためのスクリプトです。


環境構築

「pipenv」もしくは「自前で設定したpython環境」を利用する事ができます。
pipenvを用いる場合はpipenv installの実行のみでOKです。
pipenvを利用しない場合は、requirements.txtを利用して各moduleをinstallして下さい。

$ pipenv install
or
$ pip install -r requirements.txt

利用方法

検索用の「dajare_search.py」と各ダジャレサイトのクローラとなる「dajare_crawler.py」を用意しています。

検索

ダジャレステーションの検索窓を利用して、ダジャレを検索します。

pipenvを利用する場合は以下のように実行します。

$ pipenv run python dajare_search.py みかん

みかん星は、まだ未完成‼️
南関東では皆、みかん党
みかんが三日も見っかんねぇ
...

スクレイピング

Webサイト で得た データ をjsonにdumpします。


pipenvを利用する場合は以下のように実行します。

$ pipenv run python dajare_crawler.py --all

dajare_crawler.pyの引数は以下のようになっています。

args description クロール先
-h, --help help表示 -
-a, --all 全てのサイトのクロール -
-b, --b ダジャレナビ https://dajarenavi.net
-c, --c ダジャレステーション https://dajare.jp
-d, --d ダジャレネット http://www.dajare.net
-e, --e バカダス http://www.biwa.ne.jp/~aki-ina/gyagu.html
-f, --f ダジャレ辞典 https://dajareshuu.web.fc2.com
-g, --g 究極のダジャレ集 http://syuukaizyo.fc2web.com/02.html
-i, --i ダジャレの殿堂 http://archives.kaishaseikatsu.jp
--output OUTPUT 出力ディレクトリを指定 -
--sleep SLEEP requests毎のsleep (float) -

ダジャレネットとダジャレ辞典のデータをsampleディレクトリにsleep 3.0秒/requests で取得する時は以下のようになります。

$ python dajare_crawler.py -d -f --output ./sample --sleep 3.0

sleep値の設定等、スクレイピング時のルールについては、以下を参考にして下さい。
Webスクレイピングする際のルールとPythonによる規約の読み込み - Stimulator


既存のデータ

2020/02/21時点でのダジャレ統計は以下の通りです。

Webサイト ダジャレ数
ダジャレナビ 48102
ダジャレステーション 64533
ダジャレネット 832
バカダス 1070
ダジャレ辞典 1115
究極のダジャレ集 275
ダジャレの殿堂 2200

Json format

出力されるjsonは以下のようなフォーマットです。

{
    "url": "https://dajare.jp/works/000/",    # ダジャレが記載されているURL
    "text": "布団が吹っ飛んだ",    # ダジャレ
    "author": "サンプル",    # ダジャレ投稿者
    "author_link": "/author/サンプル/",    # ダジャレ投稿者へのLink
    "mean_score": 5.0,    # ダジャレ評価(平均)
    "deviation_score": 30.0,    # ダジャレ評価(偏差値)
    "category": [    # ダジャレカテゴリのリスト
        {
            "link": "/category/1/",
            "text": "動物"
        },
        {
            "link": "/category/1/1/",
            "text": "全般"
        },
        {
            "link": "/category/1/1/1/",
            "text": "全般"
        }
    ],
    "tag": [    # ダジャレに紐付いたキーワードのリスト
        {
            "link": "/keyword/布団/",
            "text": "布団"
        }
    ],
    "eval_list": [    # 評価のリスト
        {
            "author": {
                "link": "/author/テスト/",
                "text": "テスト"
            },
            "score": 3.0,
            "datetime": "2015/3/14 10:59"
        },
    ]
}

取得できない場合は空テキストや0が入ります。このフォーマットは全てのクロール先サイトで共通です。


参考文献

ダジャレ検出

ダジャレデータベース

ダジャレ生成

ダジャレ分析

ダジャレ対話


開発

Pull Requestをお待ちしております。READMEにダジャレを生やすだけでもOKです。

開発者向けのツールキットもリポジトリ内に含んでいますので活用して下さい。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

dajare-0.0.1-py3-none-any.whl (12.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page