<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>mitzのブログ</title>
<link>https://ameblo.jp/mitzoct/</link>
<atom:link href="https://rssblog.ameba.jp/mitzoct/rss20.xml" rel="self" type="application/rss+xml" />
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
<description>足の向くまま、気の向くまま ・旅行の話 ・日常の話・英語の話</description>
<language>ja</language>
<item>
<title>オンライン小説の地図　geminiで整理</title>
<description>
<![CDATA[ <p>モチベーション：</p><p>　読んでいると地域の位置関係が分からなくなってきたので、地図を作って整理したくなった。</p><p>　全て読み返すのも大変なので、Geminiに食わせて簡単な位置関係を出す。</p><p>方針：</p><p>　Geminiはスクレイピングできない仕様なのか、URL指定してもサイトの中身を見てくれないので、</p><p>　一旦ローカルに落として、解析してもらう。</p><p>手順：</p><p>1. 対象の小説をローカルPCにダウンロード</p><p>2.&nbsp;Geminiに食わせるための準備(htmlのままでもいいかも）</p><p>3.&nbsp;Gemini APIを使うための準備</p><p>4.&nbsp;Gemini実行</p><p>&nbsp;</p><p>&nbsp;</p><p>■1. 読みたい小説をローカルにhtml形式でダウンロード</p><p>curl --limit-rate 200K --retry-max-time 5 'https://ncode.syosetu.com/n0022gd/[41-102]/' -o '#1.html'</p><p>&nbsp;</p><p>--limit-rate:</p><p>　あまり早く読み込むとサーバーに負荷がかかる？と応答が来なくなるかもしれないので</p><p>　ダウンロード速度を制限（意味はないかも）</p><p>&nbsp;</p><p>--retry-max-time:</p><p>　リトライする場合、少し待つことでサーバー負荷を気持ち軽くなるかも</p><p>&nbsp;</p><p>[41-102]:</p><p>　読みたい話数を指定。序盤は、同じ場所から動かないので、動きが出てくるところを抽出</p><p>&nbsp;</p><p>#1.html:</p><p>[41-102]に対応する番号をそのままローカルに保存するファイル名にする</p><p>&nbsp;</p><p>&nbsp;</p><p>■2. Geminiに食わせるための準備</p><p>2-1.&nbsp;102話まであるので、順に処理したいので全て３桁のファイル名にする</p><p>for i in `ls [4-9]*.html`; do mv $i 0$i; done</p><p>&nbsp;</p><p>2-2. htmlファイルをtxtファイルに変換</p><p>$ cat get.py</p><p>from bs4 import BeautifulSoup</p><p>&nbsp;</p><p>def process_files(start_num, end_num):</p><p>&nbsp; for i in range(start_num, end_num+1):</p><p>&nbsp; &nbsp; html_file = format(i, '03')+str(".html")</p><p>&nbsp; &nbsp; txt_file&nbsp; = format(i, '03')+str(".txt")</p><p>&nbsp;</p><p>&nbsp; &nbsp; with open(txt_file, 'w+', encoding='utf-8') as f_txt:</p><p>&nbsp; &nbsp; &nbsp; with open(html_file, 'r', encoding='utf-8') as f_html:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; soup = BeautifulSoup(f_html, "html.parser")</p><p>&nbsp; &nbsp; &nbsp; &nbsp; p_element = soup.select('p[id]')</p><p>&nbsp; &nbsp; &nbsp; &nbsp; for contents in p_element:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; f_txt.write(contents.text+'\n')</p><p>&nbsp;</p><p>start_num = 41</p><p>end_num = 102</p><p>process_files(start_num, end_num)</p><p>&nbsp;</p><p>&nbsp;</p><p>■3.&nbsp;Gemini APIを使うための準備</p><p>3-1. ライブラリのインストール:&nbsp;</p><p>pip install google-generativeai</p><p>&nbsp;</p><p>3-2. API keyの取得</p><p>以下サイトから、右上にある「APIキーを作成」ボタンをクリック。別ウィンドウにキーができるので、コピー</p><div class="ogpCard_root"><p id="link-c911657f-0b48-4233-9b67-587b582ae308"><a href="https://aistudio.google.com/app/apikey?hl=ja" target="_blank">https://aistudio.google.com/app/apikey?hl=ja</a></p><p>&nbsp;</p></div><div class="ogpCard_root"><span style="font-family: -apple-system, BlinkMacSystemFont, sans-serif;">3-3.&nbsp;コピーしたキーを環境変数に設定</span></div><p>export GOOGLE_API_KEY="AIzaSyAx....."</p><p>&nbsp;</p><p>3-4. Geminiに渡す内容を作成（無料版を使うので、gemini-2.0-flashを指定）</p><p>複数のテキストファイルを順番に読み込み、その内容を1つの大きな文字列に結合し、</p><p>最後にその文字列をGemini APIに送るためのプロンプトを組み立てる</p><p>&nbsp;</p><p>$cat analyze.py</p><p>import os</p><p>import google.generativeai as genai</p><p>&nbsp;</p><p># Configure the API key from your environment variable</p><p>genai.configure(api_key=os.environ["GOOGLE_API_KEY"])</p><p>&nbsp;</p><p># Set the start and end file numbers</p><p>start_num = 41</p><p>end_num = 101</p><p>model = genai.GenerativeModel('gemini-2.0-flash')</p><p>&nbsp;</p><p># Combine the content of all text files</p><p>combined_text = ""</p><p>for i in range(start_num, end_num + 1):</p><p>&nbsp; &nbsp; file_path = f'{i:03d}.txt'</p><p>&nbsp; &nbsp; if os.path.exists(file_path):</p><p>&nbsp; &nbsp; &nbsp; &nbsp; with open(file_path, 'r', encoding='utf-8') as f:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; combined_text += f.read() + "\n"</p><p>&nbsp; &nbsp; else:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; print(f"Warning: File '{file_path}' not found. Skipping.")</p><p>&nbsp;</p><p># Construct the prompt for analysis</p><p>prompt_text = f"""以下の小説の内容を分析してください。</p><p>登場する地域名とその位置関係をリストアップしてください。</p><p>&nbsp;</p><p>{combined_text}</p><p>"""</p><p>&nbsp;</p><p># Send the combined text to the Gemini API</p><p>if combined_text:</p><p>&nbsp; &nbsp; try:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; response = model.generate_content(prompt_text)</p><p>&nbsp; &nbsp; &nbsp; &nbsp; print("分析結果:")</p><p>&nbsp; &nbsp; &nbsp; &nbsp; print(response.text)</p><p>&nbsp; &nbsp; except Exception as e:</p><p>&nbsp; &nbsp; &nbsp; &nbsp; print(f"An error occurred: {e}")</p><p>else:</p><p>&nbsp; &nbsp; print("No file content to analyze. Please check your files.")</p><p>&nbsp;</p><p>&nbsp;</p><p>4. Gemini実行</p><p>$python3 analyze.py</p><p>&nbsp;</p><p>&nbsp;</p><p>本文の取得は以下のサイトのようにすればよかったのかな。</p><p id="link-b3c20f7b-4ed0-4335-8838-2ed451e779a9"><a href="https://scol.hatenablog.com/entry/2019/04/04/193000" target="_blank">https://scol.hatenablog.com/entry/2019/04/04/193000</a></p><p>&nbsp;</p><p>そもそもログインすれば、txtで落とせるのか。</p><p>&nbsp;</p><p>EoF</p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12930102745.html</link>
<pubDate>Sun, 14 Sep 2025 16:17:18 +0900</pubDate>
</item>
<item>
<title>iphoneでbluetoothイヤホンのマイクテスト</title>
<description>
<![CDATA[ <p>LINEを使う。</p><p>&nbsp;</p><p>方法：</p><p>0.&nbsp;bluetoothイヤホンをペアリングする</p><p>１. LINEのトーク画面下の入力欄の横にあるマイクをタップして、赤ボタンをタップして録音開始</p><p>２. iphoneから離れて適当にしゃべる</p><p>３. 緑ボタン（□）を押して、録音終了</p><p>４. 緑ボタン（▲）を押して、音声確認</p><p>５. 左のごみ箱マークで録音データを削除</p><p>&nbsp;</p><p>解説：</p><p>iphoneに接続したbluetoothイヤホンのマイクが正しく動作するのかを確認したかったが、ブラウザや音声メモはイヤホンのマイクではなく、iphone自体が音声を拾っているっぽい。</p><p>電話やzoomでマイクテストをしたかったが、iphoneアプリのzoomにはマイクテスト機能が見当たらなかった。</p><p>LINEのマイクはbluetoothイヤホンをつなぐとiphone自体のマイクではなく、bluetoothイヤホンのマイクを使うみたい。</p><p>（念のため、録音時はiphoneから離れて録音。）</p><p>録音データは、相手に送らないので、削除。</p><p>（間違って送信しないように、keepメモか無人グループのトークルームで確認した。）</p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12816390185.html</link>
<pubDate>Tue, 15 Aug 2023 20:01:26 +0900</pubDate>
</item>
<item>
<title>GSMA</title>
<description>
<![CDATA[ <p>Global System for Mobile Communications Association</p><p>3GPPが定めた規格では統一されないベンダー間の方言を共通言語化して相互利用できるように取り組む組合</p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12813647039.html</link>
<pubDate>Tue, 25 Jul 2023 13:46:43 +0900</pubDate>
</item>
<item>
<title>GIS</title>
<description>
<![CDATA[ <p>Geographic Information System</p><p>いくつものレイヤーにそれぞれデータを重ねて、地図上に情報を持たせる</p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12813480253.html</link>
<pubDate>Mon, 24 Jul 2023 09:29:03 +0900</pubDate>
</item>
<item>
<title>スキャッターギャザー</title>
<description>
<![CDATA[ <p>DMA転送などで、物理メモリ上の散りばめられたデータを一元化、綺麗にして転送</p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12812720791.html</link>
<pubDate>Wed, 19 Jul 2023 15:31:26 +0900</pubDate>
</item>
<item>
<title>QUIC</title>
<description>
<![CDATA[ <p>UDPでweb通信する。複数セッション張る</p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12810655896.html</link>
<pubDate>Tue, 04 Jul 2023 13:06:21 +0900</pubDate>
</item>
<item>
<title>Floating IP</title>
<description>
<![CDATA[ <p>クラスターなどで複数の装置で使い回すIPアドレス</p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12809954915.html</link>
<pubDate>Thu, 29 Jun 2023 13:10:30 +0900</pubDate>
</item>
<item>
<title>WCF</title>
<description>
<![CDATA[ <p>Windowsで提供している通信フレームワーク</p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12809955243.html</link>
<pubDate>Wed, 28 Jun 2023 13:12:29 +0900</pubDate>
</item>
<item>
<title>メザニンカード</title>
<description>
<![CDATA[ <p>拡張ボード</p><p></p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12805571760.html</link>
<pubDate>Thu, 01 Jun 2023 14:27:00 +0900</pubDate>
</item>
<item>
<title>FWA</title>
<description>
<![CDATA[ <p>Fixed wireless access</p><p>事業者からの無線電波を直接オフィスや家庭に繋ぐ。</p><p>高周波数帯なので、障害物に弱い。</p><p></p>
]]>
</description>
<link>https://ameblo.jp/mitzoct/entry-12803666365.html</link>
<pubDate>Fri, 19 May 2023 15:34:32 +0900</pubDate>
</item>
</channel>
</rss>
