グラフデータベースは如何に
自然言語を理解するか?
D1 Session
AI/BI(データ分析)
2019.9.25 (水) 13:00 - 13:40
Neo4jユーザーグループ
案浦浩二 (Koji Annoura)
@kojiannoura
データから知恵へ
●情報の活用
–Data
–Information
–Knowledge (知識)
●認識によって得られた成果、あるいは、人間や物
事について抱いている考えや、技能のことであ
る。
–Insight (洞察)
●鋭い観察力で物事を見通すこと。
–Wisdom (知恵)
Agenda
●1: 自己紹介とNeo4jユーザーグループ
●2: 日本語を見てみよう
●3: 翻訳をグラフにする
●4: 知識を追加する
●5: デモ
自己紹介
●Neo4j
–One of founders Neo4j UsersGroup Tokyo
–Neo4j Ambassador
–Neo4j Speaker Program
–Certificate Neo4j Professional
●Agile
–Certified Scrum Master
–Certified Scrum Product Owner
–LeSS Practitioner
Neo4jユーザーグループ
●目的
–Neo4j社が提供するグラフデータベースNeo4jに
ついて情報共有
2013
●2013年2月に勉強会を開始
活動はボランティア
●活動は完全にボランティアです
●会場は開催時に探しています
●参加は無料です
Graph Databaseはトレンドです
●https://db-engines.com/
Neo4j
●OpenSource
–https://github.com/neo4j/neo4j
●Free
–Community edition
–Neo4j Desktop with Enterprise edition (local pc)
●Edition
–Community and Enterprise edition
Neo4j Desktop
●Mac, Linux, Windows
–https://neo4j.com/download-center/#desktop
Graph Database
●Graph databases
–NoSQLに分類されます
–下記で構成されています
●ノード (nodes)
●リレーションシップ (relationships) (エッジ edges)
●プロパティ (properties)
●ラベル (labels)
Neo4j
●OpenSource
–https://github.com/neo4j/neo4j
●Free
–Community edition
–Neo4j Desktop with Enterprise edition (local pc)
●Edition
–Community and Enterprise edition
Neo4j Desktop
●Mac, Linux, Windows
–https://neo4j.com/download-center/#desktop
Neo4jの日本語書籍
●グラフデーターベース、オライリー
●Cypherクエリー言語の事例で学ぶグラフデータ
ベースNeo4j
●グラフ型データベース入門、リックテレコム
放送大学 教養学部
●データベース('17)
–14回、データベースの発展技術(2)
●グラフデータベース
●リレーショナルモデルとは大きく異なるデータモ
デルを採用するグラフデータベースについて説明
する。データモデルや問い合わせ言語について述
べる。
●データ構造とプログラミング('18)
–15回、グラフ
●グラフのデータ構造について学習する。グラフに
NODES 2019
●Neo4j Online Developer Expo & Summit
–10月10日
Agenda
●1: 自己紹介とNeo4jユーザーグループ
●2: 日本語を見てみよう
●3: 翻訳をグラフにする
●4: 知識を追加する
●5: デモ
言葉は時代と共に変わります
●Computer
–電子計算機 (Old)
–電算機 (Old)
–コンピュータ (before 2008)
–コンピューター
コンピュータ
●JIS Z 8301:1951
–末尾に長音が付く言葉は、3文字までならその
まま記述する。3文字を超える場合は、末尾の長
音を省く
–3文字まで
●キー
●フロー
–カナ3文字を超える例
●コンピューターは、コンピュータ
●プリンターは、プリンタ
コンピューター
●JIS Z 8301:2011
–長音符号を付けるか,付けないかについて厳格
に一定にすることは困難であると認め,各用語集
の表記をそれぞれの専門分野の標準とするが,長
音符号は,用いても略しても誤りでないことにし
ている。
翻訳は翻訳者に依存しています
●Graph Database
–グラフ型データベース
–グラフ型データーベース
–グラフデータベース
–グラフデーターベース
–グラフ・データベース
–グラフ・データーベース
SVO, SOV
●Subject–verb–object (? %)
–I like Coffee.
●English, Chinese, French, Italian...
●Subject–object–verb
–私は珈琲が好きです。
(私:I, 珈琲:Coffee, 好き: love) (? %)
●Japanese, Korean, Hindi…
●SVOとSOVはそれぞれ何%だと思いますか?
SVO, SOV (%)
●Subject–verb–object (42%)
–I like Coffee.
●English, Chinese, French, Italian...
●Subject–object–verb (45%)
–私は珈琲が好きです。
(私:I, 珈琲:Coffee, 好き: love)
●Japanese, Korean, Hindi...
文字 (Letter)
●中国語 (Chinese)
–繁体字 (はんたいじ、Traditional Chinese
characters)
–簡体字 (かんたいじ、Simplified Chinese
characters)
●日本語 (Japanese)
–漢字 (Chinese characters)
–カナ (Kana)
●ひらがな (hiragana)
●カタカナ (katakana)
常用漢字 (regular-use Kanji)
●first compiled in 1946
–1,850
●It was revised in 1981
–1,945
●2010
–Updated Kanji list totals 2,136
Google Translate
●https://en.wikipedia.org/wiki/Google_Translate
●Statistical machine translation (SMT)
–April 28, 2006
●Neural machine translation (NMT)
–November 15, 2016
Google Translate
●Google translateはそれなりの翻訳ができます
●でも時々全く意味が違う翻訳をします
–コンピューターはどうやって考えますか?
How do computers think?
–How do you think about computers?
GraphのNLP
●GraphでNLP(自然言語処理)はどうするのか?
●テキストをノードに登録 (NHK World Japanのテ
キスト)
–CREATE (n:News)
SET n.text = "Kabuki star Ichikawa Ebizo says he
will assume his family's prestigious stage name of
Danjuro next year.Ebizo told reporters at the
Kabukiza theater in Tokyo on Monday that he will
become the 13th actor to use the name Ichikawa
Danjuro, beginning with a performance in May
next year.The stage name has been handed down
through generations since the 17th century.
GraphのNLP
●4つのセンテンスに別れている
GraphのNLP
●最初のセンテンスを見ると多くの単語が見える
歌舞伎座は場所
●KabukizaはLocationのラベルが付いている
LibreOfficeの翻訳事例
●1: 自己紹介とNeo4jユーザーグループ
●2: 日本語を見てみよう
●3: 翻訳をグラフにする
●4: 知識を追加する
●5: デモ
日本語翻訳の例
●LibreOfficeの日本語翻訳から何かを見つけたい
–どうやって?
–とにかくGraph Databaseを使ってみよう
LibOConf 2019
●Almeria, Spain
Pootle (Online translation tool)
●https://translations.documentfoundation.org/ja/
LibreOffice master – UI
●Browse
–ブラウズ (Browse)
–検索 (Search)
LibreOffice master – UI
●Check
–チェック
–チェックする
手順
●Pootle
–https://translations.documentfoundation.org/ja/
●Calc
–PoからCalcにデーターを作る (.po data to Calc)
●CSV
–Kanji code to UTF-8
●Neo4j
–グラフを作成して翻訳を共有する (CSV to
Graph)
翻訳を取得する
●LibreOffice master – UI / cui / messages.po
Pattern
●基本パターンは四角っぽい
–英単語: Yellow
–日本語の単語: Red
–英語の文章: Green
–日本語の文章: Blue
inside of po file
●po file は下記のデータを持っています
–単語と文章
–英語と日本語
#. Ewn6K
#: hyperlinkdocpage.ui:82
msgctxt "hyperlinkdocpage|label2"
msgid "Document"
msgstr "ドキュメント"
#. CQrvm
#: colorconfigwin.ui:33
msgctxt "colorconfigwin|doccolor"
msgid "Document background"
msgstr "ドキュメントの背景"
po fileをcsvに変換
●csv
Graph Databaseにロード
●こうつながっている
–English Word -- Japanese Word
–English Sentence -- Japanese Sentence
–English Sentence -- English Words
–Japanese Sentence -- Japanese Words
●Graphではどう実装されるか
–(Document)-[:TRANSLATE]->(ドキュメント)
–(Document background)-[:TRANSLATE]->(ドキュ
メントの背景)
The graph
●英単語: Yellow, 日本語の単語: Red
●英語の文章: Green, 日本語の文章: Blue
“document”という単語を使ってい
る
●英単語: Yellow, 日本語の単語: Red
●英語の文章: Green
“Document” と “ドキュメント”
●英単語: Yellow, 日本語の単語: Red
●英語の文章: Green, 日本語の文章: Blue
Maybe Good
Translation
日本語と英語の文章は
同じ単語を使っている。
●英単語: Yellow, 日本語の単語: Red
●英語の文章: Green, 日本語の文章: Blue
同じ訳語を使っていない文章は?
●Japanese translation of the word (“Document”)
–MATCH (:EnWord {text:'Document'})--(e:En)--
(j:Ja)
RETURN e.text, j.text
Document
●Japanese translation of the word (“Document”)
–3つの異なった翻訳が見つかった
●文書
–"Document copy has been created","文書のコピ
ーを作った時"
–"New Document","新規文書の開始時"
●ドキュメント
–"New Document","新しいドキュメント"
–"My Documents","マイドキュメント"
make good translations.
●Check synonyms and make good translations.
–if you unify to ”文書”
●"新しいドキュメント"、"新しい文書"
●"マイドキュメント"、"マイ文書" (これは微妙)
–if you unify to ”ドキュメント”
●"文書のコピーを作った時"、"ドキュメントのコピーを作った時"
●"新規文書の開始時"、"新規ドキュメントの開始時"
Agenda
●1: 自己紹介とNeo4jユーザーグループ
●2: 日本語を見てみよう
●3: 翻訳をグラフにする
●4: 知識を追加する
●5: デモ
Text graph
●Sentence
–I like Coffee.
–私は珈琲が好きです。
–我喜欢咖啡。(Wǒ xǐhuān kāfēi.)
Text graph
●Sentence
–I like Coffee.
–私は珈琲が好きです。
–我喜欢咖啡。
●Let's take a look at the text.
–Japanese and Chinese need to be divided into
words.
Text graph
●Sentence
–I like Coffee.
–私は珈琲が好きです。
–我喜欢咖啡。
●Morphological analysis (形态分析)
(internal structure of words)
–I like Coffee. (Already divided into words.)
–私 / は / 珈琲 / が / 好き / です / 。
–我 / 喜欢 / 咖啡 / 。(correct??)
Text graph
●Sentence
–I like Coffee.
–私は珈琲が好きです。
–我喜欢咖啡。
●Dependency analysis
–(Stanford CoreNLP)
●http://corenlp.run
–私は → 好きです。珈琲が → 好きです。
Graph
●Sentence
–I like Coffee.
–私は珈琲が好きです。
●Basic Graph Model
–It’s like RDF
考える
●どうやって考えるか?
●これって矛盾した事を言っていますか?
–I don't like cakes.
–I like this cake.
文章をNeo4jに格納する
●CREATE
知識ベースとは
●ConceptNet (One of knowledge base)
–ConceptNet is a freely-available semantic
network, designed to help computers understand
the meanings of words that people use.
–Relationships
●is a
●Is used for
●made of
●has a
●Similar to
ConceptNet
●Search “Cake”
ConceptNetを使うには
●JSON format
小さな知識ベースを作る
●Cake
–Types of
●Cookie
●Chocolate cake
●Honey cake
●Cheesecake
–Has
●Chocolate (Chocolate cake)
●Honey (Honey cake)
文章と知識をつなぐ
●Cake
–Cakes
–This cake
質問をCreateしてみる
●Create questions
–Do you like Cheesecake?
●No
–Do you like Honey cake?
●No
–Do you like Chocolate cake?
●Yes
–Do you like Cookie?
Connect
●Find details
–He likes only chocolate cake.
どんなケーキが好きか分かる
●Don’t like cakes
–Cheesecake
–Honey cake
–Cookie
●Like this cake
–Chocolate
Agenda
●1: 自己紹介とNeo4jユーザーグループ
●2: 日本語を見てみよう
●3: 翻訳をグラフにする
●4: 知識を追加する
●5: デモ
Thanks
●Please ask me!
–koji@annoura.com

グラフデータベースは如何に自然言語を理解するか?