View gist:6b97c3e9e328f3cfc47e2b4bc513bde9
# -*- coding: utf-8 -*-
from nltk.tree import Tree
from nltk.tree import ParentedTree
from nltk.tree import ImmutableParentedTree
def main():
tree = ImmutableParentedTree.fromstring("(ROOT (S (NP (NNP Dog)) (VP (VBZ likes) (NP (NN cat))) (. .)))")
t = tree.leaf_treeposition(1)
x = tree.leaf_treeposition(2)
View parse_shift_jis_xml.py
text = open("00001.dict", encoding="shift-jis").read()
tree = etree.fromstring(text.encode("shift-jis"))
print(etree.tostring(tree, encoding="utf-8", xml_declaration=True, doctype="<!DOCTYPE gda>").decode("utf8"))
View Weight_Sum.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View docomo_entityAPI_sample.py
# -*- coding: utf-8 -*-
"""
docomoの言語解析API(固有表現抽出)を叩くサンプルコード
"""
import requests
import json
BASEURL = "https://api.apigw.smt.docomo.ne.jp/gooLanguageAnalysis/v1/entity?APIKEY="
APIKEY = "YOUR APIKEY" #ここにAPIKEYを入力
View xor.py
# -*- coding: utf-8 -*-
"""
Chainerを用いた多層パーセプトロンの実装
多分に参考にしました: https://github.com/ichiroex/xor-mlp-chainer
"""
import sys
import numpy as np
import chainer
from chainer import cuda, Function, gradient_check, Variable, optimizers, serializers, utils
from chainer import Link, Chain, ChainList
View my_mlp_with_chainer.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View my_mlp_tutorial.py
# -*- coding: utf-8 -*-
"""
お手製のニューラルネットワーク
トレーニング編
"""
import sys
import numpy as np
from collections import defaultdict
def create_features(line, ids):
View my_mlp.py
# -*- coding: utf-8 -*-
"""
"""
import numpy as np
def sigmoid(x):
return 1./(1.+np.exp(-x))
def sigmoid_deriv(x):
return x * (1.0 - x)
View Avenir Next and HIragino Kaku Gothic.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<a:fontScheme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="ヒラギノ角ゴ+Avenir"><a:majorFont><a:latin typeface="Avenir Next"/><a:ea typeface="Hiragino Kaku Gothic ProN W3"/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="Avenir Next"/><a:ea typeface="Hiragino Kaku Gothic ProN W3"/><a:cs typeface=""/></a:minorFont></a:fontScheme>
View parse_iTunes_XML.py
# -*- coding: utf-8 -*-
"""
Parse iTunes Library and Generate Word Cloud
"""
"""
Copy "iTunes Music Library.xml" to the same directory as Python script
"""
import matplotlib.pyplot as plt
from lxml import etree
from collections import defaultdict