Skip to content

Instantly share code, notes, and snippets.

View ikegami-yukino's full-sized avatar

IKEGAMI Yukino ikegami-yukino

View GitHub Profile
@ikegami-yukino
ikegami-yukino / matrix.py
Created October 19, 2026 13:12
MeCabのmatrix.binを読み込むスクリプト
# -*- coding: utf-8 -*-
"""MeCabのmatrix.binを読み込むスクリプト"""
import mmap
import struct
import sys
_HEADER = struct.Struct("<HH") # lsize, rsize
_COST = struct.Struct("<h") # int16
_HEADER_SIZE = _HEADER.size
@ikegami-yukino
ikegami-yukino / nfkc_compare.txt
Created December 30, 2013 19:32
Pythonのunicodedata.normalize('NFKC')で正規化される文字の一覧
# -*- coding: utf-8 -*-
import unicodedata
for unicode_id in xrange(65536):
char = unichr(unicode_id)
normalized_char = unicodedata.normalize('NFKC', char)
if char != normalized_char:
if len(normalized_char) == 1:
print u'[%d] %s -> [%d] %s' % (unicode_id, char, ord(normalized_char), normalized_char)
else:
@ikegami-yukino
ikegami-yukino / google_login.py
Created June 12, 2015 09:26
Automatically Google login by selenium
mail_address = ''
password = ''
from selenium import webdriver
UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:25.0) Gecko/20100101 Firefox/25.0'
PHANTOMJS_ARG = {'phantomjs.page.settings.userAgent': UA}
driver = webdriver.PhantomJS(desired_capabilities=PHANTOMJS_ARG)
url = 'https://www.google.com/accounts/Login?hl=ja&continue=http://www.google.co.jp/'
@ikegami-yukino
ikegami-yukino / fb_categories.json
Created August 4, 2015 07:43
Facebook page category list
{
"Airline": "Airline Industry Services",
"American Restaurant": "New American Restaurant",
"Amusement Park Ride": "Roller Coaster",
"Amusement": "Arcade",
"Amusement": "Bingo Hall",
"Amusement": "Go Karting",
"Amusement": "Laser Tag",
"Antiques & Vintage": "Antique Store",
"Antiques & Vintage": "Auction House",
@ikegami-yukino
ikegami-yukino / gist:851383b40668fbe41a112b90d2963dbe
Created August 19, 2025 15:08
Find out what Python packages from are
>>> from importlib import metadata
>>> metadata.packages_distributions()
{'pip': ['pip'], 'MeCab': ['mecab'], '_MeCab': ['mecab']}
@ikegami-yukino
ikegami-yukino / .pre-commit-config.yaml
Created December 27, 2024 15:50
Git pre-commit for ruff
files: ^backend/.*$
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.7
hooks:
# Run the linter.
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix]
@ikegami-yukino
ikegami-yukino / speech_install.sh
Last active October 23, 2024 00:46
Install hts_engine, hts_voice and open_jtalk
HTS_ENGINE_VERSION=1.10
HTS_VOICE_VERSION=1.05
OPENJTALK_VERSION=1.10
pushd .
cd /tmp
wget http://downloads.sourceforge.net/hts-engine/hts_engine_API-${HTS_ENGINE_VERSION}.tar.gz
tar xzf hts_engine_API-${HTS_ENGINE_VERSION}.tar.gz
cd hts_engine_API-${HTS_ENGINE_VERSION}
@ikegami-yukino
ikegami-yukino / gil_pandas.py
Last active October 19, 2024 17:29
Pyladies Tokyo 10th Aniv. Party
import os
import time
import urllib.request
import zipfile
import pandas as pd
from pandarallel import pandarallel
URL = "https://www.post.japanpost.jp/zipcode/dl/utf/zip/utf_ken_all.zip"
ZIP_FILE_NAME = URL.split("/")[-1]
@ikegami-yukino
ikegami-yukino / julius.py
Created November 18, 2017 07:37
Python script of Julius on Windows
# coding:utf-8
import re
import socket
import subprocess
import time
HOST = "127.0.0.1"
PORT = 10500
JULIUS_DIR = 'C:\Program Files (x86)\julius-4.4.2-win32bin\\'
@ikegami-yukino
ikegami-yukino / levenshtein.py
Created February 5, 2014 07:02
重み付きレーベンシュタイン距離 Weighted Levenshtein Distance
def weighted_levenshtein(a, b, insert=1, delete=1, substitute=1):
len_a = len(a)
len_b = len(b)
m = [ [0] * (len_b + 1) for i in xrange(len_a + 1) ]
for i in xrange(len_a + 1):
m[i][0] = i * delete
for j in xrange(len_b + 1):
m[0][j] = j * insert