Skip to content

Commit

Permalink
fixed hound linting suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
HassanAkbar committed Feb 20, 2024
1 parent 82814b2 commit b27bdac
Showing 1 changed file with 35 additions and 28 deletions.
63 changes: 35 additions & 28 deletions lib/tc211/termbase/term.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ def initialize(options={})
6 => "unspecified",
}.freeze

CARRY_REGEX =

def add_example(example)
c = clean_prefixed_string(example, EXAMPLE_PREFIXES)
@examples << c unless c.empty?
Expand All @@ -132,28 +134,22 @@ def add_note(note)
def clean_prefixed_string(string, criterion_map)
carry = string.to_s.strip
criterion_map.values.flatten.each do |mat|
# puts "example string: #{carry}, mat: #{mat}"

# puts "note string: #{carry}, mat: #{mat}"
# if @id == 318 and mat == "Nota" and string == "NOTA 1 Una operación tiene un nombre y una lista de parámetros."
# require "pry"
# binding.pry
# end

# Arabic notes/examples sometimes use parantheses around numbers
carry = carry.sub(
Regexp.new(
"^#{mat}\s*[#{STRIP_PUNCTUATION.join('')}]?" +
"\s*\\(?#{ALL_FULL_HALF_WIDTH_NUMBERS}*\\)?\s*"+
"[#{STRIP_PUNCTUATION.join('')}]?\s*",
Regexp::IGNORECASE
),
'')
carry = carry.sub(carry_regex(mat), "")
end

carry
end

def carry_regex(mat)
Regexp.new(
[
"^#{mat}\s*[#{STRIP_PUNCTUATION.join}]?",
"\s*\\(?#{ALL_FULL_HALF_WIDTH_NUMBERS}*\\)?\s*",
"[#{STRIP_PUNCTUATION.join}]?\s*",
].join,
)
end

# The termid should ALWAYS be an integer.
# https://github.com/riboseinc/tc211-termbase/issues/1
Expand All @@ -167,11 +163,11 @@ def definition=(definition)

def to_hash
OUTPUT_ATTRIBS.inject({}) do |acc, attrib|
value = self.send(attrib)
unless value.nil?
acc.merge(attrib.to_s => value)
else
value = send(attrib)
if value.nil?
acc
else
acc.merge(attrib.to_s => value)
end
end
end
Expand All @@ -186,8 +182,7 @@ def entry_status=(value)
value = "superseded"
when "информация отсутствует" # "information absent"!?
value = "retired"
when %w(notValid valid superseded retired)
# do nothing
when %w(notValid valid superseded retired) # do nothing
end
@entry_status = value
end
Expand All @@ -196,9 +191,7 @@ def entry_status=(value)
## Must be one of the following: preferred admitted deprecated
def classification=(value)
case value
when ""
value = "admitted"
when "认可的", "допустимый", "admitido", "adminitido"
when "", "认可的", "допустимый", "admitido", "adminitido"
value = "admitted"
when "首选的", "suositettava", "suositeltava", "рекомендуемый", "preferente"
value = "preferred"
Expand All @@ -209,7 +202,9 @@ def classification=(value)
end

# review-indicator
## Must be one of the following <empty field> Under Review in Source Document",
# Must be one of the following
# <empty field>
# Under Review in Source Document
def review_indicator=(value)
unless ["", "Under Review in Source Document"].include?(value)
value = ""
Expand All @@ -218,7 +213,13 @@ def review_indicator=(value)
end

# authoritative-source-similarity
# ## Must be one of the following codes: identical = 1 restyled = 2 context added = 3 generalisation = 4 specialisation = 5 unspecified = 6",
# Must be one of the following codes:
# identical = 1
# restyled = 2
# context added = 3
# generalisation = 4
# specialisation = 5
# unspecified = 6
def authoritative_source_similarity=(value)
unless SOURCE_STATUSES.key?(value)
value = 6
Expand All @@ -227,7 +228,13 @@ def authoritative_source_similarity=(value)
end

# lineage-source-similarity
# ## Must be one of the following codes: identical = 1 restyled = 2 context added = 3 generalisation = 4 specialisation = 5 unspecified = 6",
# Must be one of the following codes:
# identical = 1
# restyled = 2
# context added = 3
# generalisation = 4
# specialisation = 5
# unspecified = 6
def lineage_source_similarity=(value)
unless SOURCE_STATUSES.key?(value)
value = 6
Expand Down

0 comments on commit b27bdac

Please sign in to comment.