- これをcloneする
- virtualenvを用意する
pip install -r requirements.txt
で依存パッケージをインストールするpython server.py
でサーバーを起動する- ブラウザで、サーバーにアクセスして、フォームにテキストと言語を指定して「喋る」ボタンを押す
- Google Homeが喋った!
This file contains hidden or 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
# for Python 3.6 | |
import unicodedata | |
# from 0 through 1,114,111 (https://docs.python.org/3.6/library/functions.html#chr) | |
for unicode_id in range(1114111): | |
char = chr(unicode_id) | |
normalized_char = unicodedata.normalize("NFKC", char) | |
if char != normalized_char: | |
if len(normalized_char) == 1: | |
code_point = ord(normalized_char) |
This file contains hidden or 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
# usage (single sentence): | |
# ref = ['This', 'is', 'a', 'pen', '.'] | |
# hyp = ['There', 'is', 'a', 'pen', '.'] | |
# stats = get_bleu_stats(ref, hyp) | |
# bleu = calculate_bleu(stats) # => 0.668740 | |
# | |
# usage (multiple sentences): | |
# stats = defaultdict(int) | |
# for ref, hyp in zip(refs, hyps): | |
# for k, v in get_bleu_stats(ref, hyp).items(): |
This file contains hidden or 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
"""Information Retrieval metrics | |
Useful Resources: | |
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt | |
http://www.nii.ac.jp/TechReports/05-014E.pdf | |
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf | |
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf | |
Learning to Rank for Information Retrieval (Tie-Yan Liu) | |
""" | |
import numpy as np |
This file contains hidden or 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
""" | |
Implementation of pairwise ranking using scikit-learn LinearSVC | |
Reference: | |
"Large Margin Rank Boundaries for Ordinal Regression", R. Herbrich, | |
T. Graepel, K. Obermayer 1999 | |
"Learning to rank from medical imaging data." Pedregosa, Fabian, et al., | |
Machine Learning in Medical Imaging 2012. |
This file contains hidden or 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
#!/usr/bin/env python | |
# encoding: utf-8 | |
import sys | |
import sqlite3 | |
from collections import namedtuple | |
conn = sqlite3.connect("wnjpn.db") | |
Word = namedtuple('Word', 'wordid lang lemma pron pos') |