BeautifulSoupの使い方
BeautifulSoupを使ったスクレイピング
from BeautifulSoup import BeautifulSoup import re doc = ['<html><head><title>Page title</title></head>', '<body><p id="firstpara" align="center">This is paragraph <b>one</b>.', '<p id="secondpara" align="blah">This is paragraph <b>two</b>.', '</html>'] soup = BeautifulSoup(''.join(doc)) print soup.prettify() print soup.contents[0].name # u'html' soup.findAll('p', align="center") # [<p id="firstpara" align="center">This is paragraph <b>one</b>. </p>] soup.find('p', align="center") # <p id="firstpara" align="center">This is paragraph <b>one</b>. </p> soup('p', align="center")[0]['id'] # u'firstpara'
参考:
`apt-get install`するまえに`apt-cache` でバージョンを調べる方法 - Qiita
正規表現
Emacsの使い方
設定読み込み順
一括コメントアウト
- Mark set
- M-;
一括インデント
- Mark set
- C-c > or C-c <
対話置換
- M-%
- OK: y , NO: n , ALL: ! , EXIT: q
位置画面上・下
上. C-v 下. M-v
随時便利だと思うものを追記していきますヽ(´ー`)ノ
参考:
EmacsでPythonソースコードのインデントを深くor浅くする技 | 三鷹台でひきこもるプログラマの日記
init.el設定
参考: Emacs のおすすめ基本設定 | プログラマーズ雑記帳
pyflakesの設定
(defun flymake-xml-init ())
参考: emacs+pyflakes+flymakeでpythonの構文チェックを勝手にしてもらう - yukke::note
How to disable Emacs-Flymake for html mode - Stack Overflow
flymakeでファイルが開けない時
(delete '("\\.html?\\'" flymake-xml-init) flymake-allowed-file-name-masks)
参考:How to disable Emacs-Flymake for html mode - Stack Overflow
行数設定
(require 'linum) ;\左に行番号表示 (global-linum-mode) (column-numb [https://stackoverflow.com/questions/4095153/how-to-disable-emacs-flymake-for-html-mode:title] [https://stackoverflow.com/questions/4095153/how-to-disable-emacs-flymake-for-html-mode] er-mode t) ; 行番号と列番号を表示する
対応する括弧を光らせる
;; 対応する括弧を光らせる (show-paren-mode 1)
自動補完
~/.emacs.d/init.el に以下を追加
(require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) (add-to-list 'package-archives '("marmalade" . "http://marmalade-repo.org/packages/")) (package-initialize)
M-x list-packages でauto-completeをiで選択xでインストール
(require 'auto-complete-config) (ac-config-default)
参考:
Emacs24のパッケージ管理機能を使う - 計算物理屋の研究備忘録
Emacs初心者だがオススメ設定を晒させてくれ - Qiita
プロキシ環境下でEmacsを使う - 計算物理屋の研究備忘録
ロードパスの設定
;; ロードパスの設定 (setq load-path (append '("~/.emacs.d" "~/.emacs.d/packages")
参考:
Emacsのオススメ基本設定まとめ(.emacs.el) - Qiita
Emacs ビギナーに贈る、これからバリバリ使い隊!!人のための設定講座 その1。 - 日々、とんは語る。
python設定
参考: Emacs で Python 開発環境を構築 | Futurismo
lintの設定
el-getのインストール
- ~/.emacs.d/.に以下をクローン
$ git clone https://github.com/dimitri/el-get.git
- ~/.emacs.d/init.elに以下を追記
;; load-path で ~/.emacs.d とか書かなくてよくなる (when load-file-name (setq user-emacs-directory (file-name-directory load-file-name))) ;; el-get (add-to-list 'load-path (locate-user-emacs-file "el-get")) (require 'el-get) ;; el-getでダウンロードしたパッケージは ~/.emacs.d/ に入るようにする (setq el-get-dir (locate-user-emacs-file ""))
fly-checkのインストール
(el-get 'sync 'flycheck) (require 'python) (defun tnoda/turn-on-flycheck-mode () (flycheck-mode 1)) (add-hook 'python-mode-hook 'tnoda/turn-on-flycheck-mode)
参考:
音声認識の原理のお勉強
連続音声認識と一般的なパターン認識の違い
- 連続音声認識は特徴抽出部の出力がひとつのベクトルではなく、ベクトル系列になる
- 音素や単語を一つのクラスに対応付け
- 文はそれらの系列として表現
- 認識結果もクラスの系列となる
- 連続音声認識は特徴ベクトルの系列を入力として長さが未知のクラス系列を認識する問題
音声認識手法
ベイズの定理より、
“単語列からの特徴ベクトル系列が発生する確率” と “単語列の観測される確率”
の積を最大とするような単語列を求める問題に落とし込める
これらの確率を求めるため、前者は音響モデル、後者は言語モデルを利用する
以下を考えることで問題が解くことができる
- 音響モデルを用いた確率
- 言語モデルを用いた確率
- 2つの積を最大化する単語列を探索
言語モデルの作成方法は大きく2つの方法がある
- 文法記述
- 統計から単語列の生成確率を求める方法
音響モデル
によって音響モデルを作り鍛えていく
また、精度を良くする場合、調音結合を考慮して隠れマルコフモデルの単位はトライフォンを用いるのが良い
言語モデル
進み次第 追記していきます
必要な知識
- ベイズ推定
- 最尤推定
- GMM(Gaussian Mixture Model)
- HMM(Hidden Markov Model)
- RNN(Recurrent Neural Network)
- DNN(Deep Neural Network)
- EMアルゴリズム
- パターン認識
- 尤度
- 伝達関数
- スペクトル分析
- フーリエ変換
- ケプストラム分析
- 回帰分析
- ビタビアルゴリズム
- 多次元正規分布
- DAE(Denoising AutoEncoder)
- RBM(Restricted Boltzmann Machine)
- LSTM(Long Short-Term Memory)
参考
一次元の正規分布から多次元正規分布へ - "機械学習","信号解析","ディープラーニング"の勉強
http://www.ms.k.u-tokyo.ac.jp/2015/IPSJ-math-jp.pdf
makeの理解
例
all: install.hoge
install.hoge:
wget 〜
touch install.hoge
参考:
automake
./configure;make;make installにはどんな意味がある? - ITmedia エンタープライズ
Linuxコマンド集 - 【configure】Makefileを生成する:ITpro
自分でソフトウェアをビルド・インストールするときに/usrや/usr/localへインストールしない - Qiita
debパッケージ作成方法をステップバイステップでまとめました
ダウンロードしたファイルが正常かどうかをチェックする方法 | アットマークテクノ ユーザーズサイト
独自のDebパッケージやaptリポジトリを作ってみよう | OSDN Magazine
Linuxのお勉強
プロンプト
[robonchu@localhost~]$
ユーザ名 ホスト名
コマンドラインの編集
コマンド | 内容 |
---|---|
Ctrl+b | 1back |
Ctrl+f | 1go |
Ctrl+a | text first |
Ctrl+e | text end |
Ctrl+h | 1back delete |
Ctrl+k | cut from text first to end |
Ctrl+u | cut from text end to first |
Ctrl+y | yank |
コマンド履歴
コマンド | 内容 |
---|---|
Ctrl+p | 1back command |
Ctrl+n | 1go command |
Ctrl+r | search back command |
Ctrl+r | ↑search back command next |
Enter | ↑search back command execute |
Ctrl+g | ↑search back command end |
文字コード変更
ファイルとディレクトリ
コマンド | 内容 |
---|---|
pwd | current directory display |
ls -l | detail |
ls -a | all |
ls -F | file type |
mkdir [dir name] | make dir |
mkdir -p [dir name] / [dir name] / [dir name] | ↑search back command end |
touch [file name] | create file |
rm [file name] | delete file |
rm -r [dir name] | delete dir |
rm -i [file name] | check delete |
cat [file name] | display file |
cat -n [file name] | display file with num |
less [file name] | display file & can scroll |
space | ↑ down scroll |
b | ↑ up scroll |
q | ↑ exit |
\ [word] | ↑ search down |
? [word] | ↑ search up |
n | ↑↑ next |
N | ↑↑ pre |
cp [file name] [file name] | copy file |
cp -r [dir name] [dir name] | copy dir |
mv [file name] [file name] | file name change |
mv [file name] [dir name] | file location change |
ln -s [file name] [file or dir name] | symbolic link |
探す
コマンド | 内容 |
---|---|
find [start dir] [search type] [action] | find location (ex: find . -name test.txt a -type f -print) |
updatedb & locate [file name] | find location |
locate -b [file name] | find file name only location |
調べる
コマンド | 内容 |
---|---|
[command] –help | display how to use command |
man [command] | mannual display |
man -k [key word] | find man including keyword (ex: man -k copy) |
which [command] | find command path |
bashの設定
コマンド | 内容 |
---|---|
alias [new command name]=‘[command name]’ | new name touch |
type [command] | check origin or alias |
シェル変数と環境変数
コマンド | 内容 |
---|---|
printenv | display env |
env | display env |
export [env name]=[setting name] | set env |
パーミッション
ls -l [dir] -rrrwwwxxx. ~
-:通常ファイル , d:ディレクトリ , l:シンボリックリンク
rrr(read): オーナー
www(write): グループ
xxx(execute): その他
に対するパーミッション
コマンド | 内容 |
---|---|
chmod [ex: u+x] or [ex: 777] | file mode chane |
su - [user name] | init env & user switch |
su [user name] | keep env & user switch |
sudo -u [user name] [command] | execute command on user name |
プロセスとジョブ
コマンド | 内容 |
---|---|
ps aux | display process detail |
Ctrl + z | stop job |
jobs -l | display jobs with PID |
fg %[job num] | to for ground |
bg %[job num] | to back ground |
kill %[job num] | kill job |
kill [PID] | kill process |
kill -KILL [PID] | kill process |
フィルタ
コマンド | 内容 |
---|---|
head -n [num] | display file top |
tail -n [num] | display file end |
grep [pattern] [file name] | pick up word |
ws | output line num |
テキスト処理
コマンド | 内容 |
---|---|
diff [origin file] [file] | display diff |
diff -u [origin file] [file] | display diff on unified format |
diff -ur [origin dir] [dir] | display diff on unified format |
アーカイブと圧縮
コマンド | 内容 |
---|---|
tar czf [file name].tar.gz [file name] | tar + gz make |
tar xzf [file name].tar.gz | tar + gz open |
パッケージ
コマンド | 内容 |
---|---|
sudo apt-get install [pkg name] | install pkg |
sudo apt-get remove [pkg name] | remove pkg |
sudo apt-get purge [pkg name] | remove pkg with setting |
sudo apt-cache search (–name-only) [key word] | search pkg |
sudo apt-cache policy [pkg name] | display version |
リモート
コマンド | 内容 |
---|---|
ssh [username]@[IP or name] | remote login |
ダウンロード
コマンド | 内容 |
---|---|
wget [URL] | download file |
その他のコマンド
コマンド | 内容 |
---|---|
du [file or dir] | display file size |
参考:
音声認識のいろいろ
N-gram
N-gramモデルを利用したテキスト分析 ―インデックスページ―
第5回 N-gramのしくみ:検索エンジンを作る|gihyo.jp … 技術評論社
形態素解析
第6回 N-gramと形態素解析との比較:検索エンジンを作る|gihyo.jp … 技術評論社
ツール
Python3で形態素解析エンジンMeCabを使えるようにする(2016年3月版) - Qiita
音源定位
MainPage - HARK Wiki - Open Source Robot Audition Software
HARK Document Version 2.3.0. (Revision: 8561)
dnn
Deep Learningと音声認識 | Preferred Research
deep learning
OpenJTalk
Ubuntu 14.04+julius+OpenJTalkで音声アシスタントを作ろうとした素人がハマった点と解決方法 - Qiita
パラチュン用dynamic_reconfigureの使い方
dynamic_reconfigureの使い方
- Tutorial.cfgファイルの作成
#!/usr/bin/env python PACKAGE = "dynamic_tutorials" # package name from dynamic_reconfigure.parameter_generator_catkin import * gen = ParameterGenerator() gen.add("int_param", int_t, 0, "An Integer parameter", 50, 0, 100) # name , type , level ,description , default ,min ,max gen.add("double_param", double_t, 0, "A double parameter", .5, 0, 1) gen.add("str_param", str_t, 0, "A string parameter", "Hello World") gen.add("bool_param", bool_t, 0, "A Boolean parameter", True) size_enum = gen.enum([ gen.const("Small", int_t, 0, "A small constant"), gen.const("Medium", int_t, 1, "A medium constant"), gen.const("Large", int_t, 2, "A large constant"), gen.const("ExtraLarge", int_t, 3, "An extra large constant") ], "An enum to set size") gen.add("size", int_t, 0, "A size parameter which is edited via an enum", 1, 0, 3, edit_method=size_enum) exit(gen.generate(PACKAGE, "dynamic_tutorials", "Tutorials")) # 2:package_name 3:cfg_file_name
- 実行可能な状態に
chmod a+x cfg/Tutorials.cfg
- CmakeLists.txtに以下を追加
#add dynamic reconfigure api find_package(catkin REQUIRED dynamic_reconfigure) generate_dynamic_reconfigure_options(relative_path_to_file1 relative_path_to_file2 ...) # make sure configure headers are build before node using them add_dependencies(example_node dynamic_tutorials_gencfg)
- package.xmlにもgenerate_dynamic_reconfigureを追記
nodeの作り方
python
#!/usr/bin/env python import rospy from dynamic_reconfigure.server import Server from dynamic_tutorials.cfg import TutorialsConfig def callback(config, level): rospy.loginfo("""Reconfigure Request: {int_param}, {double_param},\ {str_param}, {bool_param}, {size}""".format(**config)) return config if __name__ == "__main__": rospy.init_node("dynamic_tutorials", anonymous = True) srv = Server(TutorialsConfig, callback) rospy.spin()
参考
# ディクショナリで指定する場合はアンパックすればよい >>> d = {"name": "John", "age": 20} >>> "My name is {name}. I'm {age} years old.".format(**d) #アンパックしてキーワード引数に "My name is John. I'm 20 years old."
- configは辞書?
dict = {"yamada":75, "endou":82} value = dict["yamada"]
C++
#include <ros/ros.h> #include <dynamic_reconfigure/server.h> #include <dynamic_tutorials/TutorialsConfig.h> void callback(dynamic_tutorials::TutorialsConfig &config, uint32_t level) { ROS_INFO("Reconfigure Request: %d %f %s %s %d", config.int_param, config.double_param, config.str_param.c_str(), config.bool_param?"True":"False", config.size); } int main(int argc, char **argv) { ros::init(argc, argv, "dynamic_tutorials"); dynamic_reconfigure::Server<dynamic_tutorials::TutorialsConfig> server; dynamic_reconfigure::Server<dynamic_tutorials::TutorialsConfig>::CallbackType f; f = boost::bind(&callback, _1, _2); server.setCallback(f); ROS_INFO("Spinning node"); ros::spin(); return 0; }
- 実行
$ rosrun rqt_reconfigure rqt_reconfigure
参考
ja/dynamic_reconfigure/Tutorials/HowToWriteYourFirstCfgFile - ROS Wiki