Project

glossarist

0.0
The project is in a healthy, maintained state
Concept models for terminology glossaries conforming ISO 10241-1.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.14.0
~> 13.0
~> 3.10

Runtime

~> 1.16
>= 0
 Project Readme

Glossarist

Glossarist gem implements the Glossarist model in ruby. All the entities in the model are available as classes and all the attributes are available as methods of those classes. This gem also allows you to read/write data to concept dataset or create your own collection and save that to glossarist model V2 dataset.

The YAML schema for concept and localized_concept is available at Concept model/yaml_schemas

Installation

Add this line to your application’s Gemfile:

gem 'glossarist'

And then execute:

bundle install

Or install it yourself as:

gem install glossarist

Usage

Reading a Glossarist model V2 from files

To load the glossarist model V2 dataset

collection = Glossarist::ManagedConceptCollection.new
collection.load_from_files("path/to/glossarist-v2-dataset")

Writing a Glossarist model V2 to files

To wite the glossarist model V2 dataset to files

collection = Glossarist::ManagedConceptCollection.new
collection.load_from_files("path/to/glossarist-v2-dataset")

# ... Update the collection ...

collection.save_to_files("path/to/glossarist-v2-dataset")

ManagedConceptCollection

This is a collection for managed concepts. It includes the ruby 'Enumerable' module.

collection = Glossarist::ManagedConceptCollection.new

ManagedConcept

Following fields are available for ManagedConcept:

id

String identifier for the concept

uuid

UUID for the concept

related

Array of RelatedConcept

status

Enum for the normative status of the term.

dates

Array of ConceptDate

localized_concepts

Hash of all localizations where keys are language codes and values are uuid of the localized concept.

groups

Array of groups in string format

localizations

Hash of all localizations for this concept where keys are language codes and values are instances of LocalizedConcept.

There are two ways to initialize and populate a managed concept

  1. Setting the fields by using a hash while initializing

    concept = Glossarist::ManagedConcept.new({
      "data" => {
        "id" => "123",
        "localized_concepts" => {
          "ara" => "<uuid>",
          "eng" => "<uuid>"
        },
        "localizations" => <Array of localized concepts or localized concept hashes>,
        "groups" => [
          "foo",
          "bar",
        ],
      },
    })
  2. Setting the fields after creating an object

    concept = Glossarist::ManagedConcept.new
    concept.id = "123"
    concept.groups = ["foo", "bar"]
    concept.localizations = <Array of localized concepts or localized concept hashes>

LocalizedConcept

Localizations of the term to different languages.

Localized concept has the following fields

id

An optional identifier for the term, to be used in cross-references.

uuid

UUID for the concept

designations

Array of Designations under which the term being defined is known. This method will also accept an array of hashes for designation and will convert them to their respective classes.

domain

An optional semantic domain for the term being defined, in case the term is ambiguous between several semantic domains.

subject

Subject of the term.

definition

Array of Detailed Definition of the term.

non_verb_rep

Array of non-verbal representations used to help define the term.

notes

Zero or more notes about the term. A note is in Detailed Definition format.

examples

Zero or more examples of how the term is to be used in Detailed Definition format.

language_code

The language of the localization, as an ISO-639 3-letter code.

entry_status

Entry status of the concept. Must be one of the following: notValid, valid, superseded, retired.

classification

Classification of the concept. Must be one of the following: preferred, admitted, deprecated.

Designation::Base

A name under which a managed term is known.

Methods
from_h(options)

Creates a new designation instance based on the specified type.

Parameters
  • options (Hash) - The options for creating the designation.

  • "type" (String) - The type of designation (expression, symbol, abbreviation, graphical_symbol, letter_symbol). Note: type key should be string and not a symbol so { type: "expression" } will not work.

  • Additional options depend on the specific designation type.

Returns
Designation::{type}

A new instance of specified type. e.g Glossarist::Designation::Base.from_h("type" ⇒ "expression") will return Glossarist::Designation::Expression

Example

# Example usage of Designation::Base class

attributes_for_expression = { designation: "foobar", geographical_area: "abc", normative_status: "status" }
designation_expression = Designation::Base.from_h({ "type" => "expression" }.merge(attributes_for_expression))

attributes_for_abbreviation = { designation: "foobar", geographical_area: "abc", normative_status: "status", international: true }
designation_abbreviation = Designation::Base.from_h({ "type" => "abbreviation" }.merge(attributes_for_abbreviation))

RelatedConcept

A term related to the current term.

Following fields are available for the Related Concept

type

An enum to denote the relation of the term to the current term.

content

The designation of the related term.

ref

A citation of the related term, in a Termbase.

There are two ways to initialize and populate a related concept

  1. Setting the fields by using a hash while initializing

    related_concept = Glossarist::RelatedConcept.new({
      content: "Test content",
      type: :supersedes,
      ref: <concept citation>
    })
  2. Setting the fields after creating an object

    related_concept = Glossarist::RelatedConcept.new
    related_concept.type = "supersedes"
    related_concept.content = "designation of the related concept"
    related_concept.ref = <Citation object>

Concept Date

A date relevant to the lifecycle of the managed term.

Following fields are available for the Concept Date

  • date: The date associated with the managed term in Iso8601Date format.

  • type: An enum to denote the event which occured on the given date and associated with the lifecycle of the managed term.

There are two ways to initialize and populate a concept date

  1. Setting the fields by using a hash while initializing

    concept_date = Glossarist::ConceptDate.new({
      date: "2010-11-01T00:00:00.000Z",
      type: :accepted,
    })
  2. Setting the fields after creating an object

    concept_date = Glossarist::ConceptDate.new
    concept_date.type = :accepted
    concept_date.date = "2010-11-01T00:00:00.000Z"

DetailedDefinition

A definition of the managed term.

It has the following attributes:

content

The text of the definition of the managed term.

sources

List of Bibliographic references(Citation) for this particular definition of the managed term.

There are two ways to initialize and populate a detailed definition

  1. Setting the fields by using a hash while initializing

    detailed_definition = Glossarist::DetailedDefinition.new({
      content: "plain text reference",
      sources: [<list of citations>],
    })
  2. Setting the fields after creating an object

    detailed_definition = Glossarist::DetailedDefinition.new
    detailed_definition.content = "plain text reference",
    detailed_definition.sources = [<list of citations>]

Citation

Citation can be either structured or unstructured. A citation is structured if its reference contains one or all of the following keys { id: "id", source: "source", version: "version"} and is unstructured if its reference is plain text. This also has 2 methods structured? and plain? to check if citation is structured or not.

Citation has the following attributes.

ref

A hash or string based on type of citation. Hash if citation is structured or string if citation is plain.

clause

Referred clause of the document.

link

Link to document.

There are two ways to initialize and populate a Citation

  1. Setting the fields by using a hash while initializing

    # Unstructured Citation
    citation = Glossarist::Citation.new({
      ref: "plain text reference",
      clause: "clause",
      link: "link",
    })
    
    # Structured Citation
    citation = Glossarist::Citation.new({
      ref: { id: "123", source: "source", version: "1.1" },
      clause: "clause",
      link: "link",
    })
  2. Setting the fields after creating an object

    citation = Glossarist::Citation.new
    citation.ref = <plain or structured ref>
    citation.clause = "some clause"

NonVerbRep

Non-verbal Representation have the following fields

image

An image used to help define a term.

table

A table used to help define a term.

formula

A formula used to help define a term.

sources

Bibliographic concept source for the non-verbal representation of the term.

ConceptSource

Concept Source has the following fields

status

The status of the managed term in the present context, relative to the term as found in the bibliographic source.

type

The type of the managed term in the present context.

origin

The bibliographic citation for the managed term. This is also aliased as ref.

modification

A description of the modification to the cited definition of the term, if any, as it is to be applied in the present context.

Commands

generate_latex

Convert Concepts to Latex format

Usage:

glossarist generate_latex p, --concepts-path=CONCEPTS_PATH

Options:

p, --concepts-path

Path to yaml concepts directory

l, --latex-concepts

File path having list of concepts that should be converted to LATEX format. If not provided all the concepts will be converted to the latex format

o, --output-file

Output file path. By default the output will pe printed to the console

e, --extra-attributes

List of extra attributes that are not in standard Glossarist Concept model. eg -e one two three

Credits

This gem is developed, maintained and funded by Ribose Inc.

License

The gem is available as open source under the terms of the 2-Clause BSD License.