Class: Suma::Cli::ExtractTerms

Inherits:
Thor
  • Object
show all
Defined in:
lib/suma/cli/extract_terms.rb

Overview

ExtractTerms command using Expressir to extract terms into the Glossarist v2 format

Constant Summary collapse

REDUNDANT_NOTE_REGEX =

Matches patterns like “A thing is a type of {entity}.” or “An object is a type of a {entity}”

%r{
  ^An?                   # Starts with "A" or "An"
  \s.*?\sis\sa\stype\sof # Text followed by "is a type of"
  (\sa|\san)?            # Optional " a" or " an"
  \s\{\{[^\}]*\}\}       # Text in double curly braces
  \s*?\.?$               # Optional whitespace and period at the end
}x

Instance Method Summary collapse

Instance Method Details

#extract_terms(schema_manifest_file, output_path) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/suma/cli/extract_terms.rb', line 32

def extract_terms(schema_manifest_file, output_path)
  language_code = options[:language_code]
  schema_manifest_file = File.expand_path(schema_manifest_file)

  unless File.exist?(schema_manifest_file)
    raise Errno::ENOENT, "Specified SCHEMA_MANIFEST_FILE " \
                         "`#{schema_manifest_file}` not found."
  end

  run(schema_manifest_file, output_path, language_code)
end