• Jump To … +
    abbreviations.js adjectives.js convertables.js dates.js demonyms.js firstnames.js honourifics.js irregular_nouns.js irregular_verbs.js misc.js multiples.js numbers.js organisations.js phrasal_verbs.js places.js uncountables.js verbs.js fns.js index.js lexicon.js negate.js passive_voice.js contractions.js fancy_lumping.js grammar_rules.js parts_of_speech.js phrasal_verbs.js tagger.js word_rules.js question.js sentence.js statement.js tense.js adjective.js to_adverb.js to_comparative.js to_noun.js to_superlative.js adverb.js to_adjective.js is_acronym.js article.js date.js date_rules.js is_date.js parse_date.js is_plural.js is_uncountable.js noun.js is_organisation.js organisation.js gender.js is_person.js parse_name.js person.js is_place.js place.js pluralize.js pronoun.js singularize.js is_value.js numbers.js to_number.js units.js value.js term.js conjugate.js from_infinitive.js predict_form.js suffix_rules.js to_actor.js to_infinitive.js negate.js verb.js sentence_parser.js text.js
  • units.js

  • ¶
    const units = {
      'Temperature': {
        '°C': 'Celsius',
        '°F': 'Fahrenheit',
        'K': 'Kelvin',
        '°Ré': 'Reaumur',
        '°N': 'Newton',
        '°Ra': 'Rankine',
      },
      'Volume': {
        'm³': 'cubic meter',
        'dm³': 'cubic decimeter',
        'cm³': 'cubic centimeter',
        'l': 'liter',
        'dl': 'deciliter',
        'cl': 'centiliter',
        'ml': 'milliliter',
        'in³': 'cubic inch',
        'ft³': 'cubic foot',
        'yd³': 'cubic yard',
        'gal': 'gallon',
        'bbl': 'petroleum barrel',
        'pt': 'pint',
      },
      'Distance': {
        'km': 'kilometer',
        'm': 'meter',
        'dm': 'decimeter',
        'cm': 'centimeter',
        'mm': 'millimeter',
        'mi': 'mile',
        'in': 'inch',
        'ft': 'foot',
        'feet': 'foot',
        'yd': 'yard',
      },
      'Weight': {
        't': 'tonne',
        'kg': 'kilogram',
        'hg': 'hectogram',
        'g': 'gram',
        'dg': 'decigram',
        'cg': 'centigram',
        'mg': 'milligram',
        'µg': 'microgram',
        'carat': 'carat',
        'grain': 'grain',
        'oz': 'ounce',
        'lb': 'pound',
        'ton': 'tonne',
        'st': 'stone',
      },
      'Area': {
        'km²': 'square kilometer',
        'm²': 'square meter',
        'dm²': 'square decimeter',
        'cm²': 'square centimeter',
        'mm²': 'square millimeter',
        'ha': 'hectare',
        'ca': 'centiare',
        'mile²': 'square mile',
        'in²': 'square inch',
        'yd²': 'square yard',
        'ft²': 'square foot',
        'acre': 'acre',
      },
      'Frequency': {
        'Hz': 'hertz'
      },
      'Speed': {
        'km/h': 'kilometer per hour',
        'kmph': 'kilometer per hour',
        'mps': 'meter per second',
        'm/s': 'meter per second',
        'mph': 'mile per hour',
        'mi/h': 'mile per hour',
        'knot': 'knot',
      },
      'Data': {
        'b': 'bit',
        'B': 'byte',
        'KB': 'kilobyte',
        'Kb': 'kilobyte',
        'MB': 'megabyte',
        'Mb': 'megabyte',
        'GB': 'gigabyte',
        'Gb': 'gigabyte',
        'TB': 'terabyte',
        'Tb': 'terabyte',
        'PB': 'petabyte',
        'Pb': 'petabyte',
        'EB': 'exabyte',
        'Eb': 'exabyte',
        'ZB': 'zettabyte',
        'Zb': 'zettabyte',
        'YB': 'yottabyte',
        'Yb': 'yottabyte',
      },
      'Energy': {
        'J': 'joule',
        'Pa': 'pascal',
        'bar': 'bar',
        'W': 'watt',
        'N': 'newton',
        'Wb': 'weber',
        'T': 'tesla',
        'H': 'henry',
        'C': 'coulomb',
        'V': 'volt',
        'F': 'farad',
        'S': 'siemens',
        'O': 'ohm',
        'lx': 'lux',
        'lm': 'lumen'
      },
      'Time': {
        'year': 'year',
        'week': 'week',
        'day': 'day',
        'h': 'hour',
        'min': 'minute',
        's': 'second',
        'ms': 'millisecond',
        'µs': 'microsecond',
        'nanosecond': 'nanosecond',
        'picosecond': 'picosecond',
        'femtosecond': 'femtosecond',
        'attosecond': 'attosecond'
      },
      'Money': {
        'dollar': 'currency',
        'cent': 'currency',
        'penny': 'currency',
        'dime': 'currency',
        'dinar': 'currency',
        'euro': 'currency',
        'EU': 'currency',
        'lira': 'currency',
        'pound': 'currency',
        'GBP': 'currency',
        'pence': 'currency',
        'peso': 'currency',
        'sterling': 'currency',
        'rand': 'currency',
        'rouble': 'currency',
        'shekel': 'currency',
        'yen': 'currency',
        'yuan': 'currency',
        'franc': 'currency',
        'rupee': 'currency',
        'shilling': 'currency',
        'won': 'currency',
        'krona': 'currency',
        'dirham': 'currency',
        '€': 'currency',
        '$': 'currency',
        '¥': 'currency',
        '£': 'currency',
        'real': 'currency',
        'USD': 'currency',
        'AUD': 'currency',
        'CAD': 'currency',
        'BRL': 'currency',
        'EUR': 'currency',
        'CNY': 'currency',
        'EGP': 'currency',
        'MXN': 'currency'
      }
    };
    
    module.exports = Object.keys(units).reduce(function(h, k) {
      Object.keys(units[k]).forEach(function(u) {
        h[u] = {
          name: units[k][u],
          category: k
        };
        h[units[k][u]] = {
          name: units[k][u],
          category: k
        };
      });
      return h;
    }, {});