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
"""青空文庫にある夏目漱石の『こころ』のテキストを章ごとに分割して形態素解析する | |
【テキストデータ】 | |
青空文庫の夏目漱石の『こころ』(773_ruby_5968.zip)を解凍したファイル(kokoro.txt) | |
https://www.aozora.gr.jp/cards/000148/card773.html | |
【動作環境】 | |
-Ubuntu 20.04 | |
-Python 3.8.5 | |
-MeCab 0.996 |
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
""" 夏目漱石の『こころ』からインタラクティブな共起ネットワークを作成 | |
コードの説明は以下のブログ | |
Pythonでインタラクティブな共起ネットワークを作成する | |
https://irukanobox.blogspot.com/2021/02/python.html | |
【テキストデータ】 | |
青空文庫の夏目漱石の『こころ』(773_ruby_5968.zip)を解凍したファイル(kokoro.txt) | |
https://www.aozora.gr.jp/cards/000148/card773.html |
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
""" | |
【必要なライブラリなど】 | |
- Jupyter Notebook | |
- Pandas | |
- GeoPandans | |
- Plotly | |
- ipywidgets | |
【用意するデータ】 | |
- 都道府県境界図 |
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
""" | |
夏目漱石の『こころ』から共起ネットワークを作成するPythonサンプルコード | |
コードの説明は以下のブログ | |
Pythonで共起ネットワークを作成する | |
https://irukanobox.blogspot.com/2019/10/python.html | |
『こころ』のテキスト(kokoro.txt)は、以下の青空文庫のサイトからダウンロードできるテキストからルビなどを取り除いたもの | |
https://www.aozora.gr.jp/cards/000148/card773.html | |
""" |
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
import os | |
import sys | |
import subprocess | |
import textwrap | |
import random | |
def create_rscript(rscript_path): | |
"""Rスクリプトファイルの作成 | |
""" | |
r_script = textwrap.dedent(""" |
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
import numpy as np | |
import pandas as pd | |
from sklearn.datasets import load_iris | |
from sklearn.preprocessing import MinMaxScaler | |
from scipy.spatial.distance import pdist | |
from scipy.cluster.hierarchy import dendrogram, linkage, fcluster | |
get_ipython().run_line_magic('matplotlib', 'inline') | |
import matplotlib.pyplot as plt |
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
import urllib.request | |
import json | |
import pandas as pd | |
from pandas.io.json import json_normalize | |
# e-Stat APIのappId | |
appId = 'コピーしておいたappIdをここにペーストする' | |
# APIのリクエストURL | |
# httpsにしておく | |
url = 'https://api.e-stat.go.jp/rest/2.1/app/getStatsData?cdCat03=47001&cdCat04=48001&cdArea=00000%2C01000%2C02000%2C03000%2C04000%2C05000%2C06000%2C07000%2C08000%2C09000%2C10000%2C11000%2C12000%2C13000%2C14000%2C15000%2C16000%2C17000%2C18000%2C19000%2C20000%2C21000%2C22000%2C23000%2C24000%2C25000%2C26000%2C27000%2C28000%2C29000%2C30000%2C31000%2C32000%2C33000%2C34000%2C35000%2C36000%2C37000%2C38000%2C39000%2C40000%2C41000%2C42000%2C43000%2C44000%2C45000%2C46000%2C47000&cdCat02=H1000%2CH1010%2CH1050&cdCat01=07001&appId=&lang=J&statsDataId=0003018185&metaGetFlg=Y&cntGetFlg=N§ionHeaderFlg=1' |
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
""" | |
Send magic(WOL) packet | |
""" | |
import socket | |
import binascii | |
import sys | |
import re | |
# Broadcast address | |
BCADDR = '255.255.255.255' |