termium 0.1.0 → 0.1.1

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: 9f242a07fdedab976941acc1580ca44d301ab96e3b3c5f70bf17704fabf39f0e
4
- data.tar.gz: 9b650e4b6d9786014c09ada236f5d369c5a9138616d77083b14f121b881cb2eb
3
+ metadata.gz: 67894dc9503115a270183203cec5bf556adbef6de7e91603363398f59fee6601
4
+ data.tar.gz: f95954755b496799dc4a563c05e9e2d5161d38911d51e8f71bb419a92d5c3c2a
5
5
  SHA512:
6
- metadata.gz: 98d930ad1aab03405b14561d17cd14b76531d3a65381362b3a2822e1c8f4244bb49a9f4074a3d189fc8049a6bccbd43d40d02f9766ec00bfe78070c1950c0c5c
7
- data.tar.gz: 904748c40e59b69efeb8d2c9355ac9523b005f39b89ca03f2fac18384780e2bba4e87d2b5a441b9c725ed2c9aff426a4c588ef4cb72956199fa92aa371e099c0
6
+ metadata.gz: ab19d943d236d7737b3145a7ea0c76e68ca4a553b879dea44ef421da09bbe6cfb96c8dfdc09ea4b635cf1db904d617c2c3e322ec2ace6f42110578417aa93308
7
+ data.tar.gz: 9157b3203796559c6c7fe5ed86dc52772716b3c1c89c1b6ff6ed94db92032ee739d1e54734516cf6edec5a256d768d6552a275d5d32e11a37e9aa84d538b51f5
data/lib/termium/cli.rb CHANGED
@@ -5,53 +5,59 @@ require_relative "../termium"
5
5
  module Termium
6
6
  # Command-line interface
7
7
  class Cli < Thor
8
- desc "convert", "Convert Termium entries into a Glossarist dataset"
8
+ desc "convert", "Convert TERMIUM entries into a Glossarist dataset"
9
9
 
10
10
  option :input_file, aliases: :i, required: true, desc: "Path to TERMIUM Plus XML extract"
11
11
  option :output_file, aliases: :o, desc: "Output file path"
12
12
 
13
- def input_file_as_path
14
- input_path = Pathname.new(Dir.pwd).join(Pathname.new(options[:input_file]))
13
+ no_commands do
14
+ def input_file_as_path(input_file)
15
+ input_path = Pathname.new(Dir.pwd).join(Pathname.new(input_file))
15
16
 
16
- unless input_path.exist?
17
- error "Input file `#{options[:input_file]}` does not exist."
18
- exit 1
19
- end
20
-
21
- input_path
22
- end
17
+ unless input_path.exist?
18
+ error "TERMIUM export file `#{options[:input_file]}` does not exist."
19
+ exit 1
20
+ end
23
21
 
24
- def output_path_ready
25
- output_path = options[:output_file]
26
- output_path ||= input_path.dirname.join(input_path.basename(input_path.extname))
22
+ input_path
23
+ end
27
24
 
28
- output_path = Pathname.new(Dir.pwd).join(Pathname.new(output_path))
25
+ def output_dir_as_path(output_path, input_path)
26
+ output_path ||= input_path.dirname.join(input_path.basename(input_path.extname))
29
27
 
30
- if output_path.exist?
31
- puts "Using existing directory: #{output_path.relative_path_from(Dir.pwd)}"
32
- else # and is directory
33
- puts "Created directory: #{output_path.relative_path_from(Dir.pwd)}"
34
- output_path.mkdir
28
+ output_path = Pathname.new(Dir.pwd).join(output_path)
29
+ create_or_use_output_path(output_path)
30
+ output_path
35
31
  end
36
32
 
37
- output_path
33
+ def create_or_use_output_path(output_path)
34
+ output_path_rel = output_path.relative_path_from(Dir.pwd)
35
+ if output_path.exist?
36
+ puts "Using existing directory: #{output_path_rel}"
37
+ else # and is directory
38
+ puts "Created directory: #{output_path_rel}"
39
+ output_path.mkdir
40
+ end
41
+ end
38
42
  end
39
43
 
40
44
  def convert
41
- input_path = input_file_as_path
42
- puts "Reading input file: #{input_path.relative_path_from(Dir.pwd)}"
45
+ input_path = input_file_as_path(options[:input_file])
46
+
47
+ puts "Reading TERMIUM export file: #{input_path.relative_path_from(Dir.pwd)}"
43
48
  termium_extract = Termium::Extract.from_xml(IO.read(input_path.expand_path))
44
49
 
45
- puts "Size of dataset: #{termium_extract.core.size}"
50
+ puts "Size of TERMIUM dataset: #{termium_extract.core.size}"
46
51
 
47
52
  puts "Converting to Glossarist..."
48
53
  glossarist_col = termium_extract.to_concept
49
54
  # pp glossarist_col.first
50
55
 
51
- output_path = output_path_ready
52
- puts "Writing Glossarist dataset..."
56
+ output_path = output_dir_as_path(options[:output_file], input_path)
57
+ puts "Writing Glossarist dataset to: #{output_path.relative_path_from(Dir.pwd)}"
53
58
  glossarist_col.save_to_files(output_path.expand_path)
54
- puts "Written Glossarist dataset to: #{output_path.relative_path_from(Dir.pwd)}"
59
+ puts "Done."
60
+ exit 0
55
61
  end
56
62
 
57
63
  def method_missing(*args)
data/lib/termium/core.rb CHANGED
@@ -28,10 +28,17 @@ module Termium
28
28
 
29
29
  # TODO: In Termium XML, each definition per lang or note can be linked to a
30
30
  # particular source via the sourceRef number.
31
+ # We should utilize "source" order ID in the Glossarist object:
32
+ # <source order="1" details="ISO-2382-6 * 1987 * * * " />
33
+ # <source order="2"
34
+ # details="Ranger, Natalie * 2006 * Bureau de la traduction..." />
31
35
  def concept_sources
32
36
  source.map(&:to_concept_source)
33
37
  end
34
38
 
39
+ # TODO: Utilize "subject" in the Glossarist object:
40
+ # <subject abbreviation="YBB"
41
+ # details="Compartment - ISO/IEC JTC 1 Information Technology Vocabulary" />
35
42
  def to_concept
36
43
  concept = Glossarist::ManagedConcept.new(id: identification_number)
37
44
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Termium
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: termium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-15 00:00:00.000000000 Z
11
+ date: 2023-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glossarist