wordnet_japan_diagram 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4145d51875511103723ee93644ecadc5928b5e982eb05a5fcd962757cb49ae20
4
- data.tar.gz: fb261b20e10cb7e94b10162d2a35efe41a5419544efb8ce2a5c0b2dc7048c65f
3
+ metadata.gz: 150dbe4fda2512307197d07428fbbcefb68c90800d30aa23082f26ac5bd8e634
4
+ data.tar.gz: 43c1e41f5565170eb028767510a1fc8b0b916a1bf4998da1f7bab877be3ca1fd
5
5
  SHA512:
6
- metadata.gz: 896da652b626b66d3a8cc8ad6bab2bdf8a561afb8746be85f430f89f5a73b6b7d0dc077bce8a83469743d4bff1479413df2aac45387e9a65d48f3ccf09ef3a23
7
- data.tar.gz: 941153880f615cd18d2a70f81a53b5656fa4345fb96fbe7390c96c2333047d99c7a75d01e62f8fafafbac27be1f6a2f4bb3a2e300808a0178dd52565ab737325
6
+ metadata.gz: a6eb1855cd58e5ec4e0740b057337cb7f068704d98487ca8b220276246d951b5b0949f91bbe32568e9165d9811a1c555b07934d2a186d44df3b6f7f76b0df8df
7
+ data.tar.gz: 4224c2ae5f4babc4643b0d7cf4e14c35e930391e5f60bde22df8d3b0062b3c424b13d10aa10a4d979c3750e34066e61391eefca01fd65a25086959ed055ed11a
data/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
 
12
12
  gem "rubocop", "~> 1.21"
13
+
14
+ gem "pry-byebug"
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # WordnetJapanDiagram
2
2
 
3
- Draw a diagram of [Japanese WordNet](https://bond-lab.github.io/wnja/jpn/index.html) about the hypernyms and hyponyms of the search word.
3
+ [日本語 WordNet](https://bond-lab.github.io/wnja/jpn/index.html)を利用して、検索キーワードの上位語・下位語を可視化します。
4
4
 
5
- example: search プログラミング
5
+ 例えば、「プログラミング」を可視化した結果は以下になります。
6
6
 
7
7
  ![wordnet_japan_diagram_20240218193942](https://github.com/tommy-012/wordnet_japan_diagram/assets/46615665/d5c58962-f1e4-4174-9a9f-47407b72f3e1)
8
8
 
@@ -18,11 +18,15 @@ If bundler is not being used to manage dependencies, install the gem by executin
18
18
 
19
19
  ## Usage
20
20
 
21
- ### 1. Prepare Japanese WordNet SQLite3 file
22
- Download [Japanese WordNet SQLite3 file](https://github.com/bond-lab/wnja/releases/download/v1.1/wnjpn.db.gz), unzip the file.
21
+ ### 1. 「日本語 WordNetSQLite3)」を用意します
22
+ [Japanese WordNet SQLite3 file](https://github.com/bond-lab/wnja/releases/download/v1.1/wnjpn.db.gz) をダウンロードして解凍します。
23
23
 
24
- ### 2. Execute the command using the above file
25
- If the above file path is `./tmp/wnjpn.db`, specify the path with `--wordnet_japan_db_file_path` option.
24
+ 解凍したファイルを適切なパスに移動します。
25
+
26
+ ### 2. コマンドを実行します
27
+ 「日本語 WordNet(SQLite3)」のデフォルトパスは、`./wnjpn.db` になります。
28
+
29
+ もしパスを指定したい場合は、`--wordnet_japan_db_file_path` オプションで指定します。
26
30
 
27
31
  ```
28
32
  $ wordnet_japan_diagram --wordnet_japan_db_file_path ./tmp/wnjpn.db --search_word サウナ
@@ -31,19 +35,19 @@ $ wordnet_japan_diagram --wordnet_japan_db_file_path ./tmp/wnjpn.db --search_wor
31
35
  $ bundle exec wordnet_japan_diagram --wordnet_japan_db_file_path ./tmp/wnjpn.db --search_word サウナ
32
36
  ```
33
37
 
34
- ### 3. Check the diagram that is the result of the command execution
35
- The diagram is located under the same path as the command execution.
38
+ ### 3. コマンド実行結果を確認します
39
+ 可視化した画像は、コマンド実行したパス配下に作られます。
36
40
 
37
- The diagram name is `wordnet_japan_diagram_[%Y%m%d%H%M%S].png`.
41
+ もしパスを指定したい場合は、`--output_diagram_path` オプションで指定します。
38
42
 
39
- ※ If you want to specify the diagram path, use `--output_diagram_path` option.
43
+ 画像の名前フォーマットは、`wordnet_japan_diagram_[%Y%m%d%H%M%S].png` になります。
40
44
 
41
45
  ![wordnet_japan_diagram_20240218193545](https://github.com/tommy-012/wordnet_japan_diagram/assets/46615665/afbe25cd-2c3b-4662-a1d0-4bc16517b6a0)
42
46
 
43
- ### 4. As needed, use options for the command
47
+ ### 4. (必要に応じて) 他オプションを確認できます
44
48
  ```
45
49
  $ wordnet_japan_diagram --help
46
- Usage: wordnet_japan_diagram
50
+ Usage: wordnet_japan_diagram [-v]
47
51
 
48
52
  Specific options:
49
53
  --wordnet_japan_db_file_path=text
@@ -63,7 +67,10 @@ Specific options:
63
67
  --depth_from_target=number Sets depth from target node
64
68
  --output_diagram_path=text Sets output diagram path (The file extension is either .pdf, .png, .jpg, or .svg)
65
69
  default: wordnet_japan_diagram_[%Y%m%d%H%M%S].png
70
+
71
+ Common options:
66
72
  --help Show this options information
73
+ -v, --version Show version and quit.
67
74
  ```
68
75
 
69
76
  ## Development
@@ -1,5 +1,84 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'choice'
4
+
3
5
  require 'wordnet_japan_diagram'
4
6
 
5
- WordnetJapanDiagram::CLI.execute
7
+ Choice.options do
8
+ header ''
9
+ header 'Specific options:'
10
+
11
+ option :wordnet_japan_db_file_path do
12
+ long '--wordnet_japan_db_file_path=text'
13
+ desc "Sets wordnet japan db file path\n" \
14
+ ' default: ./wnjpn.db'
15
+ default 'wnjpn.db'
16
+ end
17
+
18
+ option :search_word, required: true do
19
+ long '--search_word=text'
20
+ desc '[Required] Sets japanese word to search'
21
+ validate /\p{Hiragana}+|\p{Katakana}+|\p{Han}+/
22
+ end
23
+
24
+ option :graph_rankdir do
25
+ long '--graph_rankdir=[TB|BT|LR|RL]'
26
+ desc "Sets direction of graph layout\n" \
27
+ " default: BT\n" \
28
+ " TB: Top to bottom\n" \
29
+ " BT: Bottom to top\n" \
30
+ " LR: Left to right\n" \
31
+ ' RL: Right to left'
32
+ default 'BT'
33
+ valid %w(TB BT LR RL)
34
+ end
35
+
36
+ option :node_contents do
37
+ long '--node_contents=[synset|synset_and_words]'
38
+ desc "Sets node contents\n" \
39
+ ' default: synset_and_words'
40
+ default 'synset_and_words'
41
+ valid %w(synset synset_and_words)
42
+ end
43
+
44
+ option :height_from_target do
45
+ long '--height_from_target=number'
46
+ desc 'Sets height from target node'
47
+ validate /\d+/
48
+ end
49
+
50
+ option :depth_from_target do
51
+ long '--depth_from_target=number'
52
+ desc 'Sets depth from target node'
53
+ validate /\d+/
54
+ end
55
+
56
+ option :output_diagram_path do
57
+ long '--output_diagram_path=text'
58
+ desc "Sets output diagram path (The file extension is either .pdf, .png, .jpg, or .svg)\n" \
59
+ ' default: wordnet_japan_diagram_[%Y%m%d%H%M%S].png'
60
+ default "wordnet_japan_diagram_#{Time.current.strftime('%Y%m%d%H%M%S')}.png"
61
+ validate /[pdf|png|jpg|svg]$/
62
+ end
63
+
64
+ separator ''
65
+ separator 'Common options: '
66
+
67
+ option :help do
68
+ long '--help'
69
+ desc 'Show this options information'
70
+ end
71
+
72
+ option :version do
73
+ short '-v'
74
+ long '--version'
75
+ desc 'Show version and quit.'
76
+ action do
77
+ require 'wordnet_japan_diagram/version'
78
+ puts WordnetJapanDiagram::BANNER
79
+ exit
80
+ end
81
+ end
82
+ end
83
+
84
+ WordnetJapanDiagram::CLI.execute(options: Choice.choices)
@@ -1,101 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'choice'
3
+ require_relative "command_options"
4
+ require_relative "diagram_creater"
4
5
 
5
- require_relative 'command_options'
6
- require_relative 'diagram_creater'
7
-
8
- require_relative 'wordnet_japan/database'
9
- require_relative 'wordnet_japan/sense'
10
- require_relative 'wordnet_japan/synlink'
11
- require_relative 'wordnet_japan/synset'
12
- require_relative 'wordnet_japan/synset_def'
13
- require_relative 'wordnet_japan/word'
14
-
15
- Choice.options do
16
- header ''
17
- header 'Specific options:'
18
-
19
- option :wordnet_japan_db_file_path do
20
- long '--wordnet_japan_db_file_path=text'
21
- desc "Sets wordnet japan db file path\n" \
22
- ' default: ./wnjpn.db'
23
- default 'wnjpn.db'
24
- end
25
-
26
- option :search_word, required: true do
27
- long '--search_word=text'
28
- desc '[Required] Sets japanese word to search'
29
- validate /\p{Hiragana}+|\p{Katakana}+|\p{Han}+/
30
- end
31
-
32
- option :graph_rankdir do
33
- long '--graph_rankdir=[TB|BT|LR|RL]'
34
- desc "Sets direction of graph layout\n" \
35
- " default: BT\n" \
36
- " TB: Top to bottom\n" \
37
- " BT: Bottom to top\n" \
38
- " LR: Left to right\n" \
39
- ' RL: Right to left'
40
- default 'BT'
41
- valid %w(TB BT LR RL)
42
- end
43
-
44
- option :node_contents do
45
- long '--node_contents=[synset|synset_and_words]'
46
- desc "Sets node contents\n" \
47
- ' default: synset_and_words'
48
- default 'synset_and_words'
49
- valid %w(synset synset_and_words)
50
- end
51
-
52
- option :height_from_target do
53
- long '--height_from_target=number'
54
- desc 'Sets height from target node'
55
- validate /\d+/
56
- end
57
-
58
- option :depth_from_target do
59
- long '--depth_from_target=number'
60
- desc 'Sets depth from target node'
61
- validate /\d+/
62
- end
63
-
64
- option :output_diagram_path do
65
- long '--output_diagram_path=text'
66
- desc "Sets output diagram path (The file extension is either .pdf, .png, .jpg, or .svg)\n" \
67
- ' default: wordnet_japan_diagram_[%Y%m%d%H%M%S].png'
68
- default "wordnet_japan_diagram_#{Time.current.strftime('%Y%m%d%H%M%S')}.png"
69
- validate /[pdf|png|jpg|svg]$/
70
- end
71
-
72
- option :help do
73
- long '--help'
74
- desc 'Show this options information'
75
- end
76
- end
6
+ require "wordnet_japan"
77
7
 
78
8
  module WordnetJapanDiagram
79
9
  class CLI
80
10
  class << self
81
- def execute
82
- connect_database
83
- create_diagram
11
+ def execute(options:)
12
+ new(options).execute
84
13
  end
14
+ end
15
+
16
+ def initialize(options)
17
+ @command_options = CommandOptions.new(options: options)
18
+ end
85
19
 
86
- private
20
+ def execute
21
+ connect_database
87
22
 
88
- def connect_database
89
- WordnetJapan::Database.connect(command_options)
90
- end
23
+ create_diagram
24
+ end
91
25
 
92
- def create_diagram
93
- DiagramCreater.new(command_options).create
94
- end
26
+ private
95
27
 
96
- def command_options
97
- @command_options ||= CommandOptions.new(options: Choice.choices)
98
- end
28
+ def connect_database
29
+ WordnetJapan::Database.connect(database: @command_options.wordnet_japan_db_options[:database])
30
+ end
31
+
32
+ def create_diagram
33
+ DiagramCreater.new(@command_options).create
99
34
  end
100
35
  end
101
36
  end
@@ -18,7 +18,7 @@ module WordnetJapanDiagram
18
18
  output_diagram_path: @options[:output_diagram_path],
19
19
  node_contents: @options[:node_contents],
20
20
  height_from_target: @options[:height_from_target].nil? ? nil : @options[:height_from_target].to_i,
21
- depth_from_target: @options[:depth_from_target].nil? ? nil : @options[:depth_from_target].to_i,
21
+ depth_from_target: @options[:depth_from_target].nil? ? nil : @options[:depth_from_target].to_i
22
22
  }
23
23
  end
24
24
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'graph_viz'
3
+ require_relative "graph_viz"
4
4
 
5
5
  module WordnetJapanDiagram
6
6
  class DiagramCreater
@@ -10,25 +10,22 @@ module WordnetJapanDiagram
10
10
  end
11
11
 
12
12
  def create
13
- word = WordnetJapan::Word.find_by(lemma: @options[:search_word], pos: 'n')
13
+ draw_diagram
14
14
 
15
- word.synsets.each do |synset|
16
- draw(synset)
17
- end
18
-
19
- @graph_viz.output(
20
- file_type: File.extname(@options[:output_diagram_path]).delete('.').to_sym,
21
- file_path: @options[:output_diagram_path]
22
- )
15
+ output_diagram
23
16
  end
24
17
 
25
18
  private
26
19
 
27
- def draw(synset)
28
- draw_target(synset)
20
+ def draw_diagram
21
+ word = WordnetJapan::Word.find_by(lemma: @options[:search_word], pos: "n")
22
+
23
+ word.synsets.each do |synset|
24
+ draw_target(synset)
29
25
 
30
- draw_hype(synset, @options[:height_from_target])
31
- draw_hypo(synset, @options[:depth_from_target])
26
+ draw_hype(synset, @options[:height_from_target])
27
+ draw_hypo(synset, @options[:depth_from_target])
28
+ end
32
29
  end
33
30
 
34
31
  def draw_target(synset)
@@ -36,8 +33,9 @@ module WordnetJapanDiagram
36
33
  end
37
34
 
38
35
  def draw_hype(synset, height)
39
- dest_synsets = synset.synlinks.where(link: '上位語').map(&:dest_synset)
36
+ dest_synsets = synset.synlinks.where(link: "上位語").map(&:dest_synset)
40
37
 
38
+ # NOTE: オプション指定がない場合は height が nil になる
41
39
  return if (height.present? && height <= 0) || dest_synsets.blank?
42
40
 
43
41
  dest_synsets.each do |dest_synset|
@@ -49,8 +47,9 @@ module WordnetJapanDiagram
49
47
  end
50
48
 
51
49
  def draw_hypo(synset, depth)
52
- dest_synsets = synset.synlinks.where(link: '下位語').map(&:dest_synset)
50
+ dest_synsets = synset.synlinks.where(link: "下位語").map(&:dest_synset)
53
51
 
52
+ # NOTE: オプション指定がない場合は depth が nil になる
54
53
  return if (depth.present? && depth <= 0) || dest_synsets.blank?
55
54
 
56
55
  dest_synsets.each do |dest_synset|
@@ -62,13 +61,20 @@ module WordnetJapanDiagram
62
61
  end
63
62
 
64
63
  def node_contents(synset)
65
- synset_def = synset.synset_defs.where(lang: 'jpn').first&.def
64
+ synset_def = synset.synset_defs.where(lang: "jpn").first&.def
66
65
 
67
- return synset_def if @options[:node_contents] == 'synset'
66
+ return synset_def if @options[:node_contents] == "synset"
68
67
 
69
- words = synset.words.where(pos: "noun").map(&:lemma).join(',')
68
+ words = synset.words.where(pos: "noun").map(&:lemma).join(",")
70
69
 
71
70
  "#{synset_def}\n(#{words})"
72
71
  end
72
+
73
+ def output_diagram
74
+ @graph_viz.output(
75
+ file_type: File.extname(@options[:output_diagram_path]).delete(".").to_sym,
76
+ file_path: @options[:output_diagram_path]
77
+ )
78
+ end
73
79
  end
74
80
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WordnetJapanDiagram
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
+ BANNER = "WordnetJapanDiagram #{VERSION}"
5
6
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "wordnet_japan_diagram/version"
3
+ require_relative 'wordnet_japan_diagram/version'
4
4
 
5
- require_relative "wordnet_japan_diagram/cli"
5
+ require_relative 'wordnet_japan_diagram/cli'
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
6
6
  spec.name = "wordnet_japan_diagram"
7
7
  spec.version = WordnetJapanDiagram::VERSION
8
8
  spec.authors = ["tommy-012"]
9
- spec.email = ["lonnlilonn@googlemail.com"]
9
+ spec.email = ["lonnlilonn@gmail.com"]
10
10
 
11
11
  spec.summary = "Draw a diagram of Japanese WordNet."
12
12
  spec.description = "Draw a diagram of Japanese WordNet about the hypernyms and hyponyms of the search word."
@@ -35,8 +35,7 @@ Gem::Specification.new do |spec|
35
35
  # For more information and examples about making a new gem, check out our
36
36
  # guide at: https://bundler.io/guides/creating_gem.html
37
37
 
38
- spec.add_dependency "activerecord", "~> 7.0.4"
39
- spec.add_dependency "sqlite3", "~> 1.5.4"
40
- spec.add_dependency "ruby-graphviz", "~> 1.2.5"
41
38
  spec.add_dependency "choice", "~> 0.2.0"
39
+ spec.add_dependency "ruby-graphviz", "~> 1.2.5"
40
+ spec.add_dependency "wordnet_japan"
42
41
  end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordnet_japan_diagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - tommy-012
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-19 00:00:00.000000000 Z
11
+ date: 2024-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activerecord
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 7.0.4
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 7.0.4
27
- - !ruby/object:Gem::Dependency
28
- name: sqlite3
14
+ name: choice
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
- version: 1.5.4
19
+ version: 0.2.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
- version: 1.5.4
26
+ version: 0.2.0
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: ruby-graphviz
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,23 +39,23 @@ dependencies:
53
39
  - !ruby/object:Gem::Version
54
40
  version: 1.2.5
55
41
  - !ruby/object:Gem::Dependency
56
- name: choice
42
+ name: wordnet_japan
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - "~>"
45
+ - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: 0.2.0
47
+ version: '0'
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
- - - "~>"
52
+ - - ">="
67
53
  - !ruby/object:Gem::Version
68
- version: 0.2.0
54
+ version: '0'
69
55
  description: Draw a diagram of Japanese WordNet about the hypernyms and hyponyms of
70
56
  the search word.
71
57
  email:
72
- - lonnlilonn@googlemail.com
58
+ - lonnlilonn@gmail.com
73
59
  executables:
74
60
  - wordnet_japan_diagram
75
61
  extensions: []
@@ -90,12 +76,6 @@ files:
90
76
  - lib/wordnet_japan_diagram/diagram_creater.rb
91
77
  - lib/wordnet_japan_diagram/graph_viz.rb
92
78
  - lib/wordnet_japan_diagram/version.rb
93
- - lib/wordnet_japan_diagram/wordnet_japan/database.rb
94
- - lib/wordnet_japan_diagram/wordnet_japan/sense.rb
95
- - lib/wordnet_japan_diagram/wordnet_japan/synlink.rb
96
- - lib/wordnet_japan_diagram/wordnet_japan/synset.rb
97
- - lib/wordnet_japan_diagram/wordnet_japan/synset_def.rb
98
- - lib/wordnet_japan_diagram/wordnet_japan/word.rb
99
79
  - sig/wordnet_japan_diagram.rbs
100
80
  - wordnet_japan_diagram.gemspec
101
81
  homepage: https://github.com/tommy-012/wordnet_japan_diagram
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_record'
4
-
5
- module WordnetJapanDiagram
6
- module WordnetJapan
7
- class Database < ActiveRecord::Base
8
- self.abstract_class = true
9
-
10
- def self.connect(command_options)
11
- establish_connection(
12
- adapter: 'sqlite3',
13
- **command_options.wordnet_japan_db_options
14
- )
15
- end
16
- end
17
- end
18
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WordnetJapanDiagram
4
- module WordnetJapan
5
- class Sense < Database
6
- self.table_name = 'sense'
7
-
8
- belongs_to :word, foreign_key: :wordid, primary_key: :wordid
9
- belongs_to :synset, foreign_key: :synset, primary_key: :synset
10
- end
11
- end
12
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WordnetJapanDiagram
4
- module WordnetJapan
5
- class Synlink < Database
6
- self.table_name = 'synlink'
7
-
8
- enum :link, {
9
- '上位語' => 'hype',
10
- '下位語' => 'hypo',
11
- '被構成要素(部分)' => 'mprt',
12
- '構成要素(部分)' => 'hprt',
13
- '被構成要素(構成員)' => 'mmem',
14
- '構成要素(構成員)' => 'hmem',
15
- '被構成要素(物質・材料)' => 'msub',
16
- '構成要素(物質・材料)' => 'hsub',
17
- '被包含領域(カテゴリ)' => 'dmnc',
18
- '包含領域(カテゴリ)' => 'dmtc',
19
- '被包含領域(語法)' => 'dmnu',
20
- '包含領域(語法)' => 'dmtu',
21
- '被包含領域(地域)' => 'dmnr',
22
- '包含領域(地域)' => 'dmtr',
23
- '例' => 'inst',
24
- '例あり' => 'hasi',
25
- '含意' => 'enta',
26
- '引き起こし' => 'caus',
27
- '関連' => 'also',
28
- '属性' => 'attr',
29
- '近似' => 'sim',
30
- }
31
-
32
- has_one :src_synset, class_name: 'Synset', foreign_key: :synset, primary_key: :synset1
33
- has_one :dest_synset, class_name: 'Synset', foreign_key: :synset, primary_key: :synset2
34
- has_many :senses, through: :dest_synset
35
- has_many :words, through: :senses
36
- end
37
- end
38
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WordnetJapanDiagram
4
- module WordnetJapan
5
- class Synset < Database
6
- self.table_name = 'synset'
7
-
8
- has_many :synset_defs, foreign_key: :synset, primary_key: :synset
9
- has_many :senses, foreign_key: :synset, primary_key: :synset
10
- has_many :words, through: :senses
11
- has_many :synlinks, foreign_key: :synset1, primary_key: :synset
12
- end
13
- end
14
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WordnetJapanDiagram
4
- module WordnetJapan
5
- class SynsetDef < Database
6
- self.table_name = 'synset_def'
7
-
8
- belongs_to :synset, foreign_key: :synset, primary_key: :synset
9
- end
10
- end
11
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module WordnetJapanDiagram
4
- module WordnetJapan
5
- class Word < Database
6
- self.table_name = 'word'
7
-
8
- enum :pos, {
9
- noun: 'n', # NOTE 名詞
10
- verb: 'v', # NOTE 動詞
11
- adjective: 'a', # NOTE 形容詞
12
- adverb: 'r' # NOTE 副詞
13
- }
14
-
15
- has_many :senses, foreign_key: :wordid, primary_key: :wordid
16
- has_many :synsets, through: :senses
17
- end
18
- end
19
- end