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 / anti_lou
Created March 27, 2012 08:04
Bilingual Emacspeak Project(BEP)辞書からルー語臭さをなるべく取り除く
perl -pe 's/(?=[ドト])ゥ(?<!ー)//g;s/(?<=[キシチニヒミリィ])イ/ー/g;s/(?<=[ァゥェォ])ィ/イ/g;s/イション/ーション/g;s/ォウ/ォー/g;s/スィ/シー/g;s/ロウ/ロー/g;s/゛//g;s/ウカ/ーカ/g;s/トギャザー/トゥゲザー/g;s/ボキャビュラリー/ボキャブラリー/g;' < bep-eng.dic.txt
@ikegami-yukino
ikegami-yukino / atoi.py
Created June 27, 2012 11:43
キャストしないでInt to Ascii
# -*- coding: utf-8 -*-
MAX_DIGIT = 10 # 最大桁数(intなら10桁)
NUMS = ['0','1','2','3','4','5','6','7','8','9']
def itoa(num):
result = ''
previous = 0
for i in range(MAX_DIGIT,-1,-1):
temp = num / (10**i)
@ikegami-yukino
ikegami-yukino / syobocal.py
Last active June 22, 2016 06:06
しょぼかるからアニメのタイトルと読み仮名、キャラクター名を取得する
# -*- coding: utf-8 -*-
"""
しょぼかるからアニメのタイトルと読み仮名、キャラクター名を取得する
引数で結果を書き込むファイルを指定します
"""
import sys, urllib2, re, codecs, time
base_url = 'http://cal.syoboi.jp'
@ikegami-yukino
ikegami-yukino / train.patch
Last active February 5, 2018 16:20
LIBLINEAR1.93のcross validationオプションでprecision/recallを出力する
--- train.c 2012-10-29 01:46:32.000000000 +0900
+++ train-new.c 2013-02-12 19:53:21.000000000 +0900
@@ -135,10 +135,14 @@
void do_cross_validation()
{
int i;
- int total_correct = 0;
double total_error = 0;
double sumv = 0, sumy = 0, sumvv = 0, sumyy = 0, sumvy = 0;
double *target = Malloc(double, prob.l);
@ikegami-yukino
ikegami-yukino / trendword.py
Created October 1, 2012 07:05
複数サイトから注目キーワードを取得する
# -*- coding: utf-8 -*-
import urllib, re, os
from BeautifulSoup import BeautifulSoup
urls = (\
'http://search.biglobe.ne.jp/rss/ranking.xml',\
'http://trackword.rssfeed.cc/index.xml',\
'http://www.jtb.co.jp/ranking/keyword/rss.aspx',\
'http://www.nilab.info/buzztube/buzztube.xml',\
'http://ranking.goo.ne.jp/rss/keyword/keyrank_all1/index.rdf',\
@ikegami-yukino
ikegami-yukino / jaconv.md
Last active June 22, 2016 05:41
Pythonで少し速くひらがな←→カタカナおよび半角←→全角変換する
@ikegami-yukino
ikegami-yukino / extract1500tercsv.php
Created February 12, 2013 20:47
1500ったーのCSVから本文だけ取り出す(RTは除外)
<?php
/**
* 1500ったーのCSVから余分な情報をカット
*
* RTを含むツイート、行頭の1500ったーのナンバーとユーザー名と投稿日、行末の引用元URL
* 文中のURL、返信宛先(@fooとか)をカット
*
* USAGE
* このスクリプトと同じディレクトリに1500ったーのCSVを置き
* コマンドプロンプトやターミナルから以下のとおり入力
@ikegami-yukino
ikegami-yukino / randomsplit.sh
Last active July 31, 2018 03:01
ファイルを行ごとにランダムにソートして、指定した数のファイルに分割する。randomly sort and split given file in given number.
#!/bin/bash
# usage:
# ./randomsplit.sh [FILE] [division number]
#
# Check the number of parameters
if [ $# -ne 2 ]; then
echo "usage: ./randomsplit.sh [FILE] [division number]" 1>&2
exit 1
@ikegami-yukino
ikegami-yukino / crossvalidation.sh
Created March 13, 2013 01:52
交差検定検定用スクリプト (ファイルを行ごとにランダムに分割してトレーニング用コマンドと検定用コマンドを実行する) For N-fold cross validation, execute given commands, for training and testing, after randomize and split data.
#!/bin/bash
# Check the number of parameters
if [ $# -ne 4 ]; then
echo "usage: ./cv.sh [FILE] [division number] [train command] [test command]" 1>&2
echo "The file for training is named as trainfile" 1>&2
echo "The file for testing is named as testfile" 1>&2
echo "for example:" 1>&2
echo './cv.sh data 5 "opal trainfile train.model -" "opal - train.model testfile"' 1>&2
exit 1
@ikegami-yukino
ikegami-yukino / reverse.c
Created March 13, 2013 02:47
インプレイス処理で文字列を反転する
#include<stdio.h>
#define NULL_LENGTH 4
char* reverse(char* text){
int i, length = sizeof text - NULL_LENGTH;
for(i = length;i > (length / 2);i--){
*(text+(i)) = *(text+(i)) ^ *(text+(length-i));
*(text+(length-i)) = *(text+(i)) ^ *(text+(length-i));
*(text+(i)) = *(text+(i)) ^ *(text+(length-i));
}