Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide register information by default through new glossarist version #12

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/termium/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def convert
puts "Converting to Glossarist..."
convert_options = {}
if options[:date_accepted]
convert_options[:date_accepted] = Date.parse(options[:date_accepted])
convert_options[:date_accepted] = Date.parse(options[:date_accepted]).iso8601
end
glossarist_col = termium_extract.to_concept(convert_options)
# pp glossarist_col.first
Expand Down
10 changes: 7 additions & 3 deletions lib/termium/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def concept_sources
end

# Deterministic v4 UUID by using the number string
def uuid
UUIDTools::UUID.md5_create(UUIDTools::UUID_DNS_NAMESPACE, identification_number).to_s
def uuid(str = identification_number)
UUIDTools::UUID.md5_create(UUIDTools::UUID_DNS_NAMESPACE, str).to_s
end

# TODO: Utilize "subject" in the Glossarist object:
Expand All @@ -60,11 +60,15 @@ def to_concept(options = {})
concept.date_accepted = options[:date_accepted]
end

language_module.map(&:to_concept).each do |localized_concept|
language_module.map do |lang_mod|
localized_concept = lang_mod.to_concept(options)

# TODO: This is needed to skip the empty french entries of 10031781 and 10031778
next if localized_concept.nil?

localized_concept.id = identification_number
localized_concept.uuid = uuid("#{identification_number}-#{lang_mod.language}")

universal_entry.each do |entry|
localized_concept.notes << entry.value
end
Expand Down
13 changes: 11 additions & 2 deletions lib/termium/language_module.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,27 @@ def to_h
"definition" => [{ content: definition }],
"notes" => notes,
"examples" => examples,
"entry_status" => "valid",
}

src["domain"] = domain if domain

src
end

def to_concept
def to_concept(options = {})
x = to_h
return nil unless x

Glossarist::LocalizedConcept.new(x)
Glossarist::LocalizedConcept.new(x).tap do |concept|
# Fill in register parameters
if options[:date_accepted]
puts options[:date_accepted].inspect
concept.date_accepted = options[:date_accepted]
end

puts concept.inspect
end
end
end
end
Loading