Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pn11
pn11 / how-to-use-giza-pp.md
Last active July 8, 2022 05:59 — forked from mosmeh/how-to-use-giza-pp.md
GIZA++ の使い方

GIZA++ の使い方

GIZA++ は、統計的機械翻訳に使われるアライメントツールで、 IBM Model 1-5 と HMM を実装しています。今回は、Europarl Parallel Corpus で配布されている英独対訳コーパスのアライメントの尤度を推定させてみます。

セットアップ

# GIZA++ の準備
$ git clone https://github.com/moses-smt/giza-pp.git
$ cd giza-pp

$ make

@pn11
pn11 / pandas_font_color.ipynb
Last active April 19, 2022 10:53
pandas_font_color.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pn11
pn11 / emacs-wrapper.sh
Created June 18, 2021 05:13
Do not open Emacs in VSCode Terminal
#!/bin/bash
if [ $TERM_PROGRAM = 'vscode' ]; then
code $*
else
exec emacsclient -t -a "" $*
fi
@pn11
pn11 / covid-19-Wako.ipynb
Last active May 2, 2021 12:02
covid-19-Wako.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pn11
pn11 / colab-ssh.ipynb
Last active January 23, 2021 12:04
ngrok を使って Google Colab に SSH ログインする。 cf. https://qiita.com/hazigin/items/c291adf5dc9ccc13d11f
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pn11
pn11 / tab_json2md.py
Last active September 29, 2022 15:09
Convert Chrome tab list extracted from Android into a Markdown and a OneTab-importable format.
# In advance, tabs.json have to be extracted via ADB by following way. (See https://android.stackexchange.com/a/199496/340082 for detail.)
# adb forward tcp:9222 localabstract:chrome_devtools_remote
# wget -O tabs.json http://localhost:9222/json/list
import json
with open('tabs.json') as f:
tabs = json.load(f)
with open('tabs.md', 'w') as f:
f.write(f"# {len(tabs)} tabs in your Android Chrome\n\n")
@pn11
pn11 / 20210108-covid19-tokyo.ipynb
Created January 7, 2021 15:15
20210108-covid19-tokyo.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pn11
pn11 / count_files.sh
Created August 30, 2020 04:52
Count files in a directory recursively with Bash
#!/bin/bash
# For Mac (Homebrew), use aliases below
#alias find=gfind
#alias sed=gsed
function count_files () {
num_files=$(gfind "$1" -maxdepth 1 -type f | wc -l)
echo "$1 ${num_files}"
@pn11
pn11 / hatenaoauth_example_py3.py
Last active April 6, 2020 02:54 — forked from soy-curd/hatenaoauth_example_py3.py
Pythonではてなの OAuth 対応 API を利用する(python3版)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
フレームワークとして Flask(http://flask.pocoo.org/) を、OAuth ライブラリとして oauth2(http://pypi.python.org/pypi/oauth2/) を利用したサンプルプログラムです。
下のコードを保存して (oauth_consumer.py とします)、YOUR_CONSUMER_KEY, YOUR_CONSUMER_SECRET となっている部分を自分の consumer_key, consumer_secret で置き換えます。(settings.pyに保存してください)
$ python oauth_consumer.py
... で起動してから http://localhost:5000 に Web ブラウザでアクセスして下さい。
+ 2015/10/25 python3用に書き換えました。
"""
@pn11
pn11 / download_images.py
Last active August 30, 2020 04:53
Download images from a website. keywords: scraping, requests, python
import requests
import time
from tqdm import tqdm
base_url = 'http://xxxxx.xxx/{image_id}.jpg'
def get_image(image_id):
r = requests.get(base_url.format(image_id=image_id))
with open(f"{image_id}.jpg", 'wb') as f:
f.write(r.content)