Add unit categories

This commit is contained in:
Tiffany Bennett 2016-11-10 17:14:14 -05:00
parent 212a7028db
commit 5ec3e4231f
11 changed files with 503 additions and 45 deletions

View file

@ -1,3 +1,5 @@
!category currencies "Currencies"
EUR !euro
money ? EUR
@ -281,3 +283,5 @@ slovakiakoruna 1|30.1260 euro
#USquarterweight USD 0.25 / (20 USD / lb) # Since 1965
#UShalfdollarweight USD 0.50 / (20 USD / lb) # Since 1971
#USdollarmass 8.1 grams
!endcategory

View file

@ -135,6 +135,8 @@
# SI units
#
!category base_units "SI Base Units"
?? Equal to the mass of the international prototype of the
?? kilogram. 3rd CGPM (1901, CR, 70).
kg !kilogram
@ -175,6 +177,8 @@ mol !mole
?? triple point of water. 13th CGPM (1967/68, Resolution 4; CR, 104).
K !kelvin
!endcategory
#
# The radian and steradian are defined as dimensionless primitive units.
# The radian is equal to m/m and the steradian to m^2/m^2 so these units are
@ -209,6 +213,8 @@ bit !
# #
###########################################################################
#!category prefixes "Prefixes"
yotta- 1e24 # Greek or Latin octo, "eight"
zetta- 1e21 # Latin septem, "seven"
exa- 1e18 # Greek hex, "six"
@ -275,10 +281,14 @@ a-- atto
z-- zepto
y-- yocto
#!endcategory
#
# Names of some numbers
#
!category numbers "Numbers"
one 1
two 2
double 2
@ -315,6 +325,8 @@ hundred 100
thousand 1000
million 1e6
!endcategory
# These number terms were described by N. Chuquet and De la Roche in the 16th
# century as being successive powers of a million. These definitions are still
# used in most European countries. The current US definitions for these
@ -322,6 +334,8 @@ million 1e6
# numbers are listed in the CRC Concise Encyclopedia of Mathematics by Eric
# W. Weisstein.
!category short_system "Short System"
shortbillion 1e9
shorttrillion 1e12
shortquadrillion 1e15
@ -343,9 +357,13 @@ shortoctodecillion 1e57
shortnovemdecillion 1e60
shortvigintillion 1e63
!endcategory
centillion 1e303
googol 1e100
!category long_system "Long System"
longbillion million^2
longtrillion million^3
longquadrillion million^4
@ -395,6 +413,8 @@ longnonilliard nonilliard
longnoventilliard noventilliard
longdecilliard decilliard
!endcategory
# The long centillion would be 1e600. The googolplex is another
# familiar large number equal to 10^googol. These numbers give overflows.
@ -447,6 +467,8 @@ shankh 1e17
# Named SI derived units (officially accepted)
#
!category si_derived "SI Derived Units"
newton kg m / s^2 # force
N newton
pascal N/m^2 # pressure or stress
@ -473,6 +495,8 @@ T tesla
hertz /s # frequency
Hz hertz
!endcategory
#
# Dimensions. These are here to help with dimensional analysis and
# because they will appear in the list produced by hitting '?' at the
@ -732,6 +756,8 @@ octant 0.5 pi sr
# Concentration measures
#
!category concentrations "Concentrations"
percent 0.01
% percent
mill 0.001 # Originally established by Congress in 1791
@ -756,6 +782,8 @@ gammil mg/l
basispoint 0.01 % # Used in finance
fine 1|1000 # Measure of gold purity
!endcategory
# The pH scale is used to measure the concentration of hydronium (H3O+) ions in
# a solution. A neutral solution has a pH of 7 as a result of dissociated
# water molecules.
@ -894,6 +922,8 @@ tempK K # For consistency
# Basic constants
!category constants "Physical Constants"
π 3.14159265358979323846
pi π
τ 2 pi
@ -1072,10 +1102,15 @@ invcm cminv # spectroscopy.
wavenumber cminv
kcal_mol kcal_th / mol N_A # kcal/mol is used as a unit of
# energy by physical chemists.
!endcategory
#
# CGS system based on centimeter, gram and second
#
!category cgs "CGS Units"
dyne cm gram / s^2 # force
dyn dyne
erg cm dyne # energy
@ -1203,6 +1238,9 @@ faraday_chem 96495.7 C # element. (The chemical and physical
kappline 6000 maxwell # Named by and for Gisbert Kapp
siemensunit 0.9534 ohm # Resistance of a meter long column of
# mercury with a 1 mm cross section.
!endcategory
#
# Printed circuit board units.
#
@ -1223,6 +1261,8 @@ ozcu ouncecopper # in circuitboard fabrication
# Radiometric units
#
!category radiometric "Radiometric Units"
radiant_energy J # Basic unit of radiation
radiant_energy_density J/m^3
radiant_flux W
@ -1246,11 +1286,14 @@ radiant_exposure J/m^2
spectral_exposure_frequency ? J m^-2 Hz^-1
spectral_exposure_wavelength J/m^3
!endcategory
#
# Photometric units
#
!category photometric "Photometric Units"
luminous_intensity ? candela
luminous_flux ? lumen
luminous_energy ? talbot
@ -1534,6 +1577,7 @@ C_illum C_apex1961
# pictorial still camera negative film/process systems --
# Determination of ISO Speed.
!endcategory
#
# Astronomical time measurements
@ -1735,6 +1779,8 @@ au astronomicalunit # ephemeris for the above described
# of mass (of electron), action (planck's constant), charge, and
# the coulomb constant.
!category atomic "Atomic Units"
# Fundamental units
atomicmass electronmass
@ -1750,6 +1796,8 @@ atomicvelocity atomiclength / atomictime
atomicenergy hbar / atomictime
hartree atomicenergy
!endcategory
#
# These thermal units treat entropy as charge, from [5]
#
@ -1794,6 +1842,8 @@ thermalvolt K # thermal potential difference
# Survey measures
!category us_survey "US Survey Measures"
surveyfoot 1200|3937 m
surveyfeet surveyfoot
surveyft surveyfoot
@ -1805,8 +1855,12 @@ surveyyd surveyyard
surveymile 5280 surveyfoot
surveymi surveymile
!endcategory
# International measures
!category int_customary "International Customary Length Measures"
?? International yard and pound, since July 1, 1959.
inch 2.54 cm
inches inch
@ -1849,8 +1903,12 @@ intperch perch
intfurlong furlong
intleague league
!endcategory
# surveyor's measure
!category us_survey "US Survey Measures"
surveyorschain 66 surveyft
surveychain surveyorschain
gunterschain surveyorschain
@ -1885,6 +1943,7 @@ gurleylink 1|50 gurleychain # same length
wingchain 66 feet # Chain from 1664, introduced by
winglink 1|80 wingchain # Vincent Wing, also found in a
# 33 foot length with 40 links.
# early US length standards
# The US has had four standards for the yard: one by Troughton of London
@ -1903,8 +1962,12 @@ bronzeyard11 914.39980 mm
mendenhallyard surveyyard
internationalyard yard
!endcategory
# international nautical measures
!category int_nautical "International Nautical Units"
intfathom 6 ft # Originally defined as the distance from
# fingertip to fingertip with arms fully
# extended.
@ -1923,8 +1986,12 @@ intcable 1|10 nauticalmile
cable intcable # international cable
cablelength cable
!endcategory
# survey nautical measures
!category us_nautical "US Survey Nautical Units"
surveynauticalmile 6080.20 surveyfoot # Before 1954
surveyfathom 6 surveyfoot
surveycable 100 surveyfathom
@ -1935,8 +2002,12 @@ knot nauticalmile / hr
click km # US military slang
klick click
!endcategory
# Avoirdupois weight
!category avoirdupois "Avoirdupois Weights"
?? International yard and pound, since July 1, 1959. Avoirdupois.
pound 0.45359237 kg # The one normally used
lb pound # From the latin libra
@ -1958,9 +2029,13 @@ quarterweight 1|4 uston
shortquarterweight 1|4 shortton
shortquarter shortquarterweight
!endcategory
# Troy Weight. In 1828 the troy pound was made the first United States
# standard weight. It was to be used to regulate coinage.
!category troy "Troy Weights"
troypound 5760 grain
troyounce 1|12 troypound
ozt troyounce
@ -1973,8 +2048,12 @@ usassayton mg uston / troyounce
brassayton mg brton / troyounce
fineounce troyounce # A troy ounce of 99.5% pure gold
!endcategory
# Some other jewelers units
!category jewelers "Jewelers' Units"
metriccarat 0.2 gram # Defined in 1907
metricgrain 50 mg
carat metriccarat
@ -1986,15 +2065,24 @@ momme 3.75 grams # Traditional Japanese unit based
# pearls in modern times and also for
# silk density. The definition here
# was adopted in 1891.
!endcategory
# Apothecaries' weight
!category apothecary "Apothecaries' Weights"
appound troypound
apounce troyounce
apdram 1|8 apounce
apscruple 1|3 apdram
!endcategory
# Liquid measure
!category us_volume "US Volume Measures"
usgallon 231 in^3 # US liquid measure is derived from
gal gallon # the British wine gallon of 1707.
quart 1|4 gallon # See the "winegallon" entry below
@ -2060,10 +2148,14 @@ heapedbushel 1.278 usbushel# The following explanation for this
# that value if the heap is taken to
# have an 18.5 inch diameter.
!endcategory
# Grain measures. The bushel as it is used by farmers in the USA is actually
# a measure of mass which varies for different commodities. Canada uses the
# same bushel masses for most commodities, but not for oats.
!category us_grain "US Grain Measures"
wheatbushel 60 lb
soybeanbushel 60 lb
cornbushel 56 lb
@ -2073,8 +2165,12 @@ oatbushel 32 lb
ricebushel 45 lb
canada_oatbushel 34 lb
!endcategory
# Wine and Spirits measure
!category wine "Wine and Spirits Measures"
ponyvolume 1 usfloz
jigger 1.5 usfloz # Can vary between 1 and 2 usfloz
shot jigger # Sometimes 1 usfloz
@ -2089,14 +2185,22 @@ metrictenth 375 ml
metricfifth 750 ml
metricquart 1 liter
!endcategory
# Old British bottle size
!category br_bottles "British Bottle Sizes"
reputedquart 1|6 brgallon
reputedpint 1|2 reputedquart
brwinebottle reputedquart # Very close to 1|5 winegallon
!endcategory
# French champagne bottle sizes
!category fr_bottle "French CHampagne Bottle Sizes"
split 200 ml
jeroboam 2 magnum
rehoboam 3 magnum
@ -2105,18 +2209,27 @@ salmanazar 6 magnum
balthazar 8 magnum
nebuchadnezzar 10 magnum
!endcategory
#
# Water is "hard" if it contains various minerals, expecially calcium
# carbonate.
#
!category water_hardness "Water Hardness Measures"
clarkdegree grains/brgallon # Content by weigh of calcium carbonate
gpg grains/usgallon # Divide by water's density to convert to
# a dimensionless concentration measure
!endcategory
#
# Shoe measures
#
!category shoes "Shoe Measures"
shoeiron 1|48 inch # Used to measure leather in soles
shoeounce 1|64 inch # Used to measure non-sole shoe leather
@ -2150,6 +2263,8 @@ shoe_girls0 (3+7|12) inch
europeshoesize 2|3 cm
!endcategory
#
# USA slang units
#
@ -2179,6 +2294,9 @@ marathon 26 miles + 385 yards
# Johnson found the yard to be
# 0.91439841 meters.
# Used starting in the 1930's.
!category br_length "British Length Measures"
UKSJJyard 0.91439841 meter
UKSJJfoot 1|3 UKSJJyard
UKSJJinch 1|12 UKSJJfoot
@ -2237,9 +2355,13 @@ admiraltycable brcable
seamile 6000 ft
shackle 15 fathoms # Adopted 1949 by British navy
!endcategory
# British Imperial weight is mostly the same as US weight. A few extra
# units are added here.
!category br_weight "British Weight Measures"
clove 7 lb
stone 14 lb
tod 28 lb
@ -2249,8 +2371,12 @@ longhundredweight brhundredweight
longton 20 brhundredweight
brton longton
!endcategory
# British Imperial volume measures
!category br_volume "British Volume Measures"
brminim 1|60 brdram
brscruple 1|3 brdram
fluidscruple brscruple
@ -2353,8 +2479,12 @@ imperialbeerhogshead brbeerhogshead
imperialbeerbutt brbeerbutt
imperialfirkin brfirkin
!endcategory
# obscure British lengths
!category br_length "British Length Measures"
barleycorn 1|3 UKinch # Given in Realm of Measure as the
# difference between successive shoe sizes
nail 1|16 UKyard # Originally the width of the thumbnail,
@ -2373,6 +2503,8 @@ span 9 UKinch # supposed to be distance from thumb
goad 4.5 UKft # used for cloth, possibly named after the
# stick used for prodding animals.
!endcategory
# misc obscure British units
hide 120 acre # English unit of land area dating to the 7th
@ -2404,6 +2536,8 @@ sulphur sulfur
# Units derived the human body (may not be very accurate)
#
!category human_measures "Human Body Measurements"
geometricpace 5 ft # distance between points where the same
# foot hits the ground
pace 2.5 ft # distance between points where alternate
@ -2430,10 +2564,15 @@ smoot 5 ft + 7 in # Created as part of an MIT fraternity prank.
# bridge rennovation the new sidewalk was
# scored every smooth rather than at the
# customary 6 ft spacing.
!endcategory
#
# Cooking measures
#
!category us_volume "US Volume Measures"
# Common abbreviations
tbl tablespoon
@ -2481,8 +2620,12 @@ number3can 4 uscups
number5can 7 uscups
number10can 105 usfloz
!endcategory
# British measures
!category br_volume "British Volume Measures"
brcup 1|2 brpint
brteacup 1|3 brpint
brtablespoon 15 ml # Also 5|8 brfloz, approx 17.7 ml
@ -2495,8 +2638,12 @@ brtbl brtablespoon
brtbsp brtablespoon
brtblsp brtablespoon
!endcategory
# Australian
!category au_volume "Australian Volume Measures"
australiatablespoon 20 ml
austbl australiatablespoon
austbsp australiatablespoon
@ -2504,6 +2651,8 @@ austblsp australiatablespoon
australiateaspoon 1|4 australiatablespoon
austsp australiateaspoon
!endcategory
# Italian
etto 100 g # Used for buying items like meat and
@ -2720,6 +2869,8 @@ baumeconst 145 # US value
# Units derived from imperial system
#
!category derived_customary "Derived Customary Units"
ouncedal oz ft / s^2 # force which accelerates an ounce
# at 1 ft/s^2
poundal lb ft / s^2 # same thing for a pound
@ -2802,6 +2953,8 @@ RU U # than its U measurement indicates to
# is specified in EIA RS-310-D.
count /pound # For measuring the size of shrimp
!endcategory
#
# Other units of work, energy, power, etc
#
@ -2810,6 +2963,8 @@ energy ? joule
# Calories: energy to raise a gram of water one degree celsius
!category calories "Calories"
cal_IT 4.1868 J # International Table calorie
cal_th 4.184 J # Thermochemical calorie
cal_fifteen 4.18580 J # Energy to go from 14.5 to 15.5 degC
@ -2825,6 +2980,8 @@ thermie 1e6 cal_fifteen # Heat required to raise the
# temperature of a tonne of
# water from 14.5 to 15.5 degC.
!endcategory
# btu definitions: energy to raise a pound of water 1 degF
btu cal lb degR / gram K # international table BTU
@ -2856,6 +3013,8 @@ kWh kilowatt hour
# The horsepower is supposedly the power of one horse pulling. Obviously
# different people had different horses.
!category horses "Horse Units"
horsepower 550 foot pound force / sec # Invented by James Watt
mechanicalhorsepower horsepower
hp horsepower
@ -2867,6 +3026,8 @@ brhorsepower 745.70 W
donkeypower 250 W
chevalvapeur metrichorsepower
!endcategory
#
# Heat Transfer
#
@ -3027,6 +3188,8 @@ bale 5 bundles
# Paper measures
#
!category paper "Paper Sizes"
# USA paper sizes
lettersize 8.5 inch 11 inch
@ -3211,10 +3374,14 @@ paperdensity 0.8 g/cm^3 # approximate--paper densities vary!
papercaliper in paperdensity
paperpoint pointthickness paperdensity
!endcategory
#
# Printing
#
!category printing "Printing Units"
fournierpoint 0.1648 inch / 12 # First definition of the printers
# point made by Pierre Fournier who
# defined it in 1737 as 1|12 of a
@ -3315,11 +3482,15 @@ missal 48 didotpoint
kleine_sabon 72 didotpoint
grobe_sabon 84 didotpoint
!endcategory
#
# Information theory units. Note that the name "entropy" is used both
# to measure information and as a physical quantity.
#
!category compuing "Computing Units"
information ? bit
#nat (1/ln(2)) bits # Entropy measured base e
@ -3405,6 +3576,7 @@ dvdspeed 1385 kB/s # This is the "1x" speed of a DVD using
# outside of the disc.
# See http://www.osta.org/technology/dvdqa/dvdqa4.htm
!endcategory
#
# Musical measures. Musical intervals expressed as ratios. Multiply
@ -3412,6 +3584,8 @@ dvdspeed 1385 kB/s # This is the "1x" speed of a DVD using
# musicalcent can be used to convert ratios to cents.
#
!category music "Musical Measures"
# Perfect intervals
octave 2
@ -3459,10 +3633,14 @@ demisemiquaver thirtysecondnote
hemidemisemiquaver sixtyfourthnote
semidemisemiquaver hemidemisemiquaver
!endcategory
#
# yarn and cloth measures
#
!category cloth "Yarn and Cloth Measures"
# yarn linear density
woolyarnrun 1600 yard/pound # 1600 yds of "number 1 yarn" weighs
@ -3505,10 +3683,14 @@ silkmm silkmomme # But it is also defined as
# and neither one seems likely to be
# the true source definition.
!endcategory
#
# drug dosage
#
!category dosage "Drug Dosage"
mcg microgram # Frequently used for vitamins
iudiptheria 62.8 microgram # IU is for international unit
iupenicillin 0.6 microgram
@ -3533,6 +3715,7 @@ frenchcathetersize 1|3 mm # measure used for the outer diameter
# of a catheter
charriere frenchcathetersize
!endcategory
#
# fixup units for times when prefix handling doesn't do the job
@ -3548,6 +3731,8 @@ megalerg megaerg # 'L' added to make it pronounceable [18].
# Units used for measuring volume of wood
#
!category wood "Wood Measures"
cord 4*4*8 ft^3 # 4 ft by 4 ft by 8 ft bundle of wood
facecord 1|2 cord
cordfoot 1|8 cord # One foot long section of a cord
@ -3592,16 +3777,19 @@ wholedeal 12 ft 11 in 1.25 in # If it's half as thick as the standard
# deal it's called a "whole deal"!
splitdeal 12 ft 11 in 5|8 in # And half again as thick is a split deal.
# Used for shellac mixing rate
poundcut pound / gallon
lbcut poundcut
!endcategory
#
# Gas and Liquid flow units
#
!category flow_units "Fluid Flow Units"
#FLUID_FLOW VOLUME / TIME
# Some obvious volumetric gas flow units (cu is short for cubic)
@ -3672,6 +3860,8 @@ slpm atm liter/min
slph atm liter/hour
lusec liter micron Hg / s # Used in vacuum science
!endcategory
# US Standard Atmosphere (1976)
# Atmospheric temperature and pressure vs. geometric height above sea level
# This definition covers only the troposphere (the lowest atmospheric
@ -3683,6 +3873,8 @@ lusec liter micron Hg / s # Used in vacuum science
# the definitions of "exponent" and "index." The functions below assume
# the following parameters:
!category atmospheric "Atmospheric Measures"
# temperature lapse rate, -dT/dz, in troposphere
lapserate 6.5 K/km # US Std Atm (1976)
@ -3817,6 +4009,8 @@ earthradUSAtm 6356766 m
#psig(x) units=[1;Pa] domain=[-14.6959487755135,) range=[0,) \
# gaugepressure(x psi) ; ~gaugepressure(psig) / psi
!endcategory
#
# Wire Gauge
#
@ -3832,6 +4026,8 @@ earthradUSAtm 6356766 m
# Alternatively, you can use the following units:
#
!category gauges "Wire Gauges"
g00 (-1)
g000 (-2)
g0000 (-3)
@ -3839,6 +4035,8 @@ g00000 (-4)
g000000 (-5)
g0000000 (-6)
!endcategory
# American Wire Gauge (AWG) or Brown & Sharpe Gauge appears to be the most
# important gauge. ASTM B-258 specifies that this gauge is based on geometric
# interpolation between gauge 0000, which is 0.46 inches exactly, and gauge 36
@ -4221,6 +4419,8 @@ g0000000 (-6)
# http://dmtsharp.com/products/colorcode.htm
#
!category grits "Grit Sizes"
dmtxxcoarse 120 micron # 120 mesh
dmtsilver dmtxxcoarse
dmtxx dmtxxcoarse
@ -4265,6 +4465,8 @@ hardblackarkansas 6 micron
hardwhitearkansas 11 micron
washita 35 micron
!endcategory
#
# Ring size. All ring sizes are given as the circumference of the ring.
#
@ -4292,6 +4494,8 @@ washita 35 micron
# The new sizes are close to the old ones. Sometimes it's necessary to go
# beyond size Z to Z+1, Z+2, etc.
!category ring_sizes "Ring Sizes"
sizeAring 37.50 mm
sizeBring 38.75 mm
sizeCring 40.00 mm
@ -4319,6 +4523,8 @@ sizeXring 66.25 mm
sizeYring 67.50 mm
sizeZring 68.75 mm
!endcategory
# Japanese sizes start with size 1 at a 13mm inside diameter and each size is
# 1|3 mm larger in diameter than the previous one. They are multiplied by pi
# to give circumference.
@ -4381,6 +4587,8 @@ coul C
# Radioactivity units
#
!category radioactivity "Radioactivity Units"
becquerel /s # Activity of radioactive source
Bq becquerel #
curie 3.7e10 Bq # Defined in 1910 as the radioactivity
@ -4437,6 +4645,8 @@ sievertunit 8.38 rontgen # Unit of gamma ray dose delivered in one
eman 1e-7 Ci/m^3 # radioactive concentration
mache 3.7e-7 Ci/m^3
!endcategory
#
# population units
#
@ -4451,6 +4661,8 @@ percapita /capita
# http://www.dozenalsociety.org.uk/apps/tgm.htm. These units are
# proposed as an allegedly more rational alternative to the SI system.
!category dozenal "Dozenal Units"
Tim 12^-4 hour # Time
Grafut gravity Tim^2 # Length based on gravity
Surf Grafut^2 # area
@ -4496,6 +4708,8 @@ Dexi- 12^-10
Lefi- 12^-11
Zennili- 12^-12
!endcategory
#
# Traditional Japanese units (shakkanhou)
#
@ -4517,6 +4731,8 @@ Zennili- 12^-12
# Japanese Proportions. These are still in everyday use. They also
# get used as units to represent the proportion of the standard unit.
!category japanese "Traditional Japanese Units"
wari_proportion 1|10
wari wari_proportion
bu_proportion 1|100 # The character bu can also be read fun or bun
@ -4646,8 +4862,13 @@ kwan kan # This was the old pronounciation of the unit.
# longer and was not changed until around
# 1950.
!endcategory
# http://en.wikipedia.org/wiki/Taiwanese_units_of_measurement
# says: "Volume measure in Taiwan is largely metric".
!category taiwan "Taiwanese Units"
taijin kin # http://zh.wikipedia.org/wiki/台斤
tailiang 10 monme # http://zh.wikipedia.org/wiki/台斤
taiqian monme # http://zh.wikipedia.org/wiki/台制
@ -4657,6 +4878,8 @@ taiqian monme # http://zh.wikipedia.org/wiki/台制
台錢 taiqian
!endutf8
!endcategory
#
# Australian unit
#
@ -4676,6 +4899,8 @@ pfund 500 g
# Some traditional Russian measures
#
!category russian "Traditional Russian Units"
# length
точка 1|10 линия
@ -4774,12 +4999,16 @@ uncia унция
апфунт 12 унция
apfunt фунт
!endcategory
#
# Old French distance measures, from French Weights and Measures
# Before the Revolution by Zupko
#
!category french "French Old Measures"
frenchfoot 144|443.296 m # pied de roi, the standard of Paris.
pied frenchfoot # Half of the hashimicubit,
frenchfeet frenchfoot # instituted by Charlemagne.
@ -4803,11 +5032,15 @@ frenchgrain 1|18827.15 kg # Weight of a wheat grain, hence
# smaller than the British grain.
frenchpound 9216 frenchgrain
!endcategory
#
# Before the Imperial Weights and Measures Act of 1824, various different
# weights and measures were in use in different places.
#
!category scots "Scotland Measures"
# Scots linear measure
scotsinch 1.00540054 UKinch
@ -4825,8 +5058,12 @@ scotsmile 8 scotsfurlong
scotsrood 40 scotsfall^2
scotsacre 4 scotsrood
!endcategory
# Irish linear measure
!category irish "Ireland Measures"
irishinch UKinch
irishpalm 3 irishinch
irishspan 3 irishpalm
@ -4848,8 +5085,12 @@ irishmile 8 irishfurlong #
irishrood 40 irishpole^2
irishacre 4 irishrood
!endcategory
# English wine capacity measures (Winchester measures)
!category winchester_wine "Winchester Wine Measures"
winepint 1|2 winequart
winequart 1|4 winegallon
winegallon 231 UKinch^3 # Sometimes called the Winchester Wine Gallon,
@ -4882,8 +5123,11 @@ winebutt 2 winehogshead
winepipe winebutt
winetun 2 winebutt
# English beer and ale measures used 1803-1824 and used for beer before 1688
!endcategory
!category wine "Wine and Spirits Measures"
# English beer and ale measures used 1803-1824 and used for beer before 1688
beerpint 1|2 beerquart
beerquart 1|4 beergallon
beergallon 282 UKinch^3
@ -4898,6 +5142,10 @@ alegallon beergallon
alebarrel 34 alegallon
alehogshead 1.5 alebarrel
!endcategory
!category scots "Scotland Measures"
# Scots capacity measure
scotsgill 1|4 mutchkin
@ -4932,6 +5180,10 @@ tronounce 1|20 tronpound
tronpound 9520 grain
tronstone 16 tronpound
!endcategory
!category irish "Ireland Measures"
# Irish liquid capacity measure
irishnoggin 1|4 irishpint
@ -4955,6 +5207,10 @@ irishstrike 2 irishbushel
irishdrybarrel 2 irishstrike
irishquarter 2 irishbarrel
!endcategory
!category english "English Measurements"
# English Tower weights, abolished in 1528
towerpound 5400 grain
@ -4992,6 +5248,8 @@ woolsack 2 woolwey
woolsarpler 2 woolsack
woollast 6 woolsarpler
!endcategory
#
# Ancient history units: There tends to be uncertainty in the definitions
# of the units in this section
@ -5002,6 +5260,8 @@ woollast 6 woolsarpler
# regions without distinguishing among them so that there are half a dozen
# different Roman "standard" weight systems.
!category roman "Roman Measures"
romanfoot 296 mm # There is some uncertainty in this definition
romanfeet romanfoot # from which all the other units are derived.
pes romanfoot # This value appears in numerous sources. In "The
@ -5113,8 +5373,12 @@ romanobol 1|2 scrupula
romanaspound 4210 grain # Old pound based on bronze coinage, the
# earliest money of Rome BC 338 to BC 268.
!endcategory
# Egyptian length measure
!category egyptian "Egyptian Measures"
egyptianroyalcubit 20.63 in # plus or minus .2 in
egyptianpalm 1|7 egyptianroyalcubit
egyptiandigit 1|4 egyptianpalm
@ -5126,8 +5390,12 @@ remendigit 1|40 doubleremen # side length of 1 royal egyptian cubit.
# not the same size as the digits based on
# the royal cubit.
!endcategory
# Greek length measures
!category greek "Greek Measures"
greekfoot 12.45 in # Listed as being derived from the
greekfeet greekfoot # Egyptian Royal cubit in [11]. It is
greekcubit 1.5 greekfoot # said to be 3|5 of a 20.75 in cubit.
@ -5190,11 +5458,15 @@ atticmina 50 atticstaters
attictalent 60 atticmina # Supposedly the mass of a cubic foot
# of water (whichever foot was in use)
!endcategory
# "Northern" cubit and foot. This was used by the pre-Aryan civilization in
# the Indus valley. It was used in Mesopotamia, Egypt, North Africa, China,
# central and Western Europe until modern times when it was displaced by
# the metric system.
!category northern_cubic "Northern Cubic and Foot"
northerncubit 26.6 in # plus/minus .2 in
northernfoot 1|2 northerncubit
@ -5209,10 +5481,13 @@ assyriansusi 1|20 assyrianpalm
susi assyriansusi
persianroyalcubit 7 assyrianpalm
!endcategory
# Arabic measures. The arabic standards were meticulously kept. Glass weights
# accurate to .2 grains were made during AD 714-900.
!category arabic "Arabic Measures"
hashimicubit 25.56 in # Standard of linear measure used
# in Persian dominions of the Arabic
# empire 7-8th cent. Is equal to two
@ -5238,6 +5513,8 @@ tradewukiyeh 10 tradedirhem
traderotl 12 tradewukiyeh
arabictradepound traderotl
!endcategory
# Miscellaneous ancient units
parasang 3.5 mile # Persian unit of length usually thought
@ -5487,6 +5764,8 @@ röntgen roentgen
# Assorted
#
!category substances "Substances"
water {
density mass gram / volume cm^3
pressure_column pressure gram force cm^-2 / column cm
@ -6650,6 +6929,8 @@ air 78.08 % nitrogen 2 \
+ 1.14 ppm krypton \
+ 0.55 ppm hydrogen 2
!endcategory
############################################################################
#
# Unit list aliases

View file

@ -102,12 +102,21 @@ pub enum Def {
Unit(Expr),
Quantity(Expr),
Substance(Vec<Property>),
Category(String),
Error(String),
}
#[derive(Debug)]
pub struct DefEntry {
pub name: String,
pub def: Rc<Def>,
pub doc: Option<String>,
pub category: Option<String>,
}
#[derive(Debug)]
pub struct Defs {
pub defs: Vec<(String, Rc<Def>, Option<String>)>,
pub defs: Vec<DefEntry>,
}
impl fmt::Display for Conversion {

View file

@ -4,7 +4,7 @@
use std::fs::File;
use std::time::Duration;
use ast::{Defs, Def, Expr};
use ast::{Defs, Def, Expr, DefEntry};
use std::io::Read;
use std::rc::Rc;
use json;
@ -24,11 +24,16 @@ pub fn parse(mut f: File) -> Result<Defs, String> {
let (sign, mantissa, exp) = avg.as_parts();
let integer = format!("{}{}", if sign { "" } else { "-" }, mantissa);
if let Ok(num) = ::Number::from_parts(&*integer, None, Some(&*format!("{}", exp))) {
out.push((name, Rc::new(Def::Unit(
Expr::Mul(vec![
Expr::Const(num),
Expr::Unit("USD".to_owned())
]))), Some(format!("Sourced from BTC-E exchange."))));
out.push(DefEntry {
name: name,
def: Rc::new(Def::Unit(
Expr::Mul(vec![
Expr::Const(num),
Expr::Unit("USD".to_owned())
]))),
doc: Some(format!("Sourced from BTC-E exchange.")),
category: Some("currencies".to_owned()),
});
}
}
}

View file

@ -21,6 +21,8 @@ pub struct Context {
pub prefixes: Vec<(String, Number)>,
pub definitions: BTreeMap<String, Expr>,
pub docs: BTreeMap<String, String>,
pub categories: BTreeMap<String, String>,
pub category_names: BTreeMap<String, String>,
pub datepatterns: Vec<Vec<DatePattern>>,
pub substances: BTreeMap<String, Substance>,
pub temporaries: BTreeMap<String, Number>,
@ -40,6 +42,8 @@ impl Context {
prefixes: Vec::new(),
definitions: BTreeMap::new(),
docs: BTreeMap::new(),
categories: BTreeMap::new(),
category_names: BTreeMap::new(),
datepatterns: Vec::new(),
substances: BTreeMap::new(),
temporaries: BTreeMap::new(),

View file

@ -6,7 +6,7 @@ use std::fs::File;
use std::time::Duration;
use xml::EventReader;
use xml::reader::XmlEvent;
use ast::{Defs, Def, Expr};
use ast::{Defs, Def, Expr, DefEntry};
use std::rc::Rc;
use num::Num;
@ -38,12 +38,17 @@ pub fn parse(f: File) -> Result<Defs, String> {
let integer = iter.next().unwrap();
let frac = iter.next();
if let Ok(num) = ::number::Number::from_parts(integer, frac, None) {
out.push((currency.to_owned(), Rc::new(Def::Unit(
Expr::Mul(vec![
Expr::Frac(Box::new(Expr::Const(Num::one())),
Box::new(Expr::Const(num))),
Expr::Unit("EUR".to_string())
]))), Some(format!("Sourced from European Central Bank."))));
out.push(DefEntry {
name: currency.to_owned(),
def: Rc::new(Def::Unit(
Expr::Mul(vec![
Expr::Frac(Box::new(Expr::Const(Num::one())),
Box::new(Expr::Const(num))),
Expr::Unit("EUR".to_string())
]))),
doc: Some(format!("Sourced from European Central Bank.")),
category: Some("currencies".to_owned()),
});
}
}
},

View file

@ -13,7 +13,8 @@ use value::{Value, Show};
use reply::{
DefReply, ConversionReply, FactorizeReply, UnitsForReply,
QueryReply, ConformanceError, QueryError, UnitListReply,
DurationReply, SearchReply, DateReply, ExprReply
DurationReply, SearchReply, DateReply, ExprReply,
UnitsInCategory
};
use search;
use context::Context;
@ -888,19 +889,58 @@ impl Context {
},
Some(val) => val
};
let dim_name;
let mut out = vec![];
for (name, unit) in self.units.iter() {
if let Some(&Expr::Unit(_)) = self.definitions.get(name) {
continue
}
let category = self.categories.get(name);
if val.unit == unit.unit {
out.push(name);
out.push((category, name));
}
}
out.sort();
if val.unit.len() == 1 {
let ref n = *val.unit.iter().next().unwrap().0 .0;
dim_name = self.canonicalize(n).unwrap_or_else(|| n.to_owned());
let category = self.categories.get(&dim_name);
out.push((category, &dim_name));
}
out.sort_by(|&(ref c1, ref n1), &(ref c2, ref n2)| {
use std::cmp::Ordering;
match (c1, c2) {
(&None, &None) => Ordering::Equal,
(&Some(_), &None) => Ordering::Less,
(&None, &Some(_)) => Ordering::Greater,
(&Some(ref a), &Some(ref b)) => (a, n1).cmp(&(b, n2)),
}
});
let mut categories = vec![];
let mut cur = vec![];
let mut cur_cat = None;
for (category, name) in out {
if category != cur_cat {
if cur.len() > 0 {
let cat_name = cur_cat.and_then(|x| self.category_names.get(x));
categories.push(UnitsInCategory {
category: cat_name.map(ToOwned::to_owned),
units: cur.drain(..).collect(),
});
}
cur_cat = category;
}
cur.push(name.clone());
}
if cur.len() > 0 {
let cat_name = cur_cat.and_then(|x| self.category_names.get(x));
categories.push(UnitsInCategory {
category: cat_name.map(ToOwned::to_owned),
units: cur
});
}
let parts = val.to_parts(self);
Ok(QueryReply::UnitsFor(UnitsForReply {
units: out.into_iter().cloned().collect(),
units: categories,
of: NumberParts {
dimensions: parts.dimensions,
quantity: parts.quantity,

View file

@ -294,14 +294,41 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
let mut map = vec![];
let mut line = 1;
let mut doc = None;
let mut category = None;
loop {
match iter.next().unwrap() {
Token::Newline => line += 1,
Token::Eof => break,
Token::Bang => loop {
Token::Bang => {
match iter.next().unwrap() {
Token::Eof | Token::Newline => break,
_ => ()
Token::Ident(ref s) if s == "category" => {
match (iter.next().unwrap(), iter.next().unwrap()) {
(Token::Ident(s), Token::Ident(d)) => {
map.push(DefEntry {
name: s.clone(),
def: Rc::new(Def::Category(d)),
doc: None,
category: None
});
category = Some(s);
},
_ => println!("Malformed category directive"),
}
},
Token::Ident(ref s) if s == "endcategory" => {
if category.is_none() {
println!("Stray endcategory directive");
}
category = None
},
_ => loop {
match iter.peek().cloned().unwrap() {
Token::Newline | Token::Eof => break,
_ => {
iter.next();
}
}
},
}
},
Token::Doc(line) => {
@ -318,9 +345,19 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
name.pop();
if name.ends_with("-") {
name.pop();
map.push((name, Rc::new(Def::Prefix(expr)), doc.take()));
map.push(DefEntry {
name: name,
def: Rc::new(Def::Prefix(expr)),
doc: doc.take(),
category: category.clone(),
});
} else {
map.push((name, Rc::new(Def::SPrefix(expr)), doc.take()));
map.push(DefEntry {
name: name,
def: Rc::new(Def::SPrefix(expr)),
doc: doc.take(),
category: category.clone(),
});
}
} else {
// unit
@ -329,17 +366,36 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
iter.next();
if let Some(Token::Ident(ref long)) = iter.peek().cloned() {
iter.next();
map.push((name.clone(), Rc::new(Def::Dimension), doc.take()));
map.push((long.clone(), Rc::new(Def::Canonicalization(name.clone())),
doc.take()));
map.push(DefEntry {
name: name.clone(),
def: Rc::new(Def::Dimension),
doc: doc.take(),
category: category.clone(),
});
map.push(DefEntry {
name: long.clone(),
def: Rc::new(Def::Canonicalization(name.clone())),
doc: doc.take(),
category: category.clone(),
});
} else {
map.push((name.clone(), Rc::new(Def::Dimension), doc.take()));
map.push(DefEntry {
name: name.clone(),
def: Rc::new(Def::Dimension),
doc: doc.take(),
category: category.clone(),
});
}
} else if let Some(&Token::Question) = iter.peek() {
// quantity
iter.next();
let expr = parse_expr(iter);
map.push((name, Rc::new(Def::Quantity(expr)), doc.take()));
map.push(DefEntry {
name: name,
def: Rc::new(Def::Quantity(expr)),
doc: doc.take(),
category: category.clone(),
});
} else if let Some(&Token::LeftBrace) = iter.peek() {
// substance
iter.next();
@ -420,14 +476,21 @@ pub fn parse(mut iter: &mut Iter) -> Defs {
doc: prop_doc.take()
});
}
map.push((
name,
Rc::new(Def::Substance(props)),
doc.take()));
map.push(DefEntry {
name: name,
def: Rc::new(Def::Substance(props)),
doc: doc.take(),
category: category.clone(),
});
} else {
// derived
let expr = parse_expr(iter);
map.push((name, Rc::new(Def::Unit(expr)), doc.take()));
map.push(DefEntry {
name: name,
def: Rc::new(Def::Unit(expr)),
doc: doc.take(),
category: category.clone(),
});
}
}
},

View file

@ -5,7 +5,7 @@
use std::collections::{BTreeMap, BTreeSet};
use number::{Number, Dim};
use num::Num;
use ast::{Expr, Def, Defs};
use ast::{Expr, Def, Defs, DefEntry};
use substance::{Substance, Property, Properties};
use std::rc::Rc;
use value::Value;
@ -20,6 +20,7 @@ impl Context {
Unit(Rc<String>),
Prefix(Rc<String>),
Quantity(Rc<String>),
Category(Rc<String>),
}
struct Resolver {
@ -29,6 +30,7 @@ impl Context {
unmarked: BTreeSet<Name>,
temp_marks: BTreeSet<Name>,
docs: BTreeMap<Name, String>,
categories: BTreeMap<Name, String>,
}
impl Resolver {
@ -165,24 +167,32 @@ impl Context {
unmarked: BTreeSet::new(),
temp_marks: BTreeSet::new(),
docs: BTreeMap::new(),
categories: BTreeMap::new(),
};
for (name, def, doc) in defs.defs.into_iter() {
for DefEntry { name, def, doc, category } in defs.defs.into_iter() {
let name = resolver.intern(&name);
let unit = match *def {
Def::Prefix(_) | Def::SPrefix(_) => Name::Prefix(name),
Def::Quantity(_) => Name::Quantity(name),
Def::Category(_) => Name::Category(name),
_ => Name::Unit(name)
};
if let Some(doc) = doc {
resolver.docs.insert(unit.clone(), doc);
}
if let Some(category) = category {
resolver.categories.insert(unit.clone(), category);
}
if resolver.input.insert(unit.clone(), def).is_some() {
let (ty, name) = match unit {
Name::Prefix(ref name) => ("prefixes", name),
Name::Quantity(ref name) => ("quantities", name),
Name::Unit(ref name) => ("units", name),
Name::Category(ref name) => ("category", name),
};
println!("warning: multiple {} named {}", ty, name);
if ty != "category" {
println!("warning: multiple {} named {}", ty, name);
}
}
resolver.unmarked.insert(unit);
}
@ -221,6 +231,7 @@ impl Context {
Name::Unit(name) => (*name).clone(),
Name::Prefix(name) => (*name).clone(),
Name::Quantity(name) => (*name).clone(),
Name::Category(name) => (*name).clone(),
};
match *def {
Def::Dimension => {
@ -361,6 +372,9 @@ impl Context {
Err(e) => println!("Substance {} is malformed: {}", name, e),
}
},
Def::Category(ref desc) => {
self.category_names.insert(name.clone(), desc.clone());
},
Def::Error(ref err) => println!("Def {}: {}", name, err),
};
}
@ -370,10 +384,23 @@ impl Context {
Name::Unit(name) => (*name).clone(),
Name::Prefix(name) => (*name).clone(),
Name::Quantity(name) => (*name).clone(),
Name::Category(name) => (*name).clone(),
};
if self.docs.insert(name.clone(), val).is_some() {
println!("Doc conflict for {}", name);
}
}
for (name, val) in resolver.categories {
let name = match name {
Name::Unit(name) => (*name).clone(),
Name::Prefix(name) => (*name).clone(),
Name::Quantity(name) => (*name).clone(),
Name::Category(name) => (*name).clone(),
};
if self.categories.insert(name.clone(), val).is_some() {
println!("Category conflict for {}", name);
}
}
}
}

View file

@ -47,8 +47,15 @@ pub struct FactorizeReply {
#[derive(Debug, Clone)]
#[cfg_attr(feature = "nightly", derive(Serialize, Deserialize))]
pub struct UnitsForReply {
pub struct UnitsInCategory {
pub category: Option<String>,
pub units: Vec<String>,
}
#[derive(Debug, Clone)]
#[cfg_attr(feature = "nightly", derive(Serialize, Deserialize))]
pub struct UnitsForReply {
pub units: Vec<UnitsInCategory>,
/// Dimensions and quantity are set.
pub of: NumberParts,
}
@ -394,7 +401,13 @@ impl Display for FactorizeReply {
impl Display for UnitsForReply {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
write!(fmt, "Units for {}: {}", self.of.format("D w"), self.units.join(", "))
write!(fmt, "Units for {}: {}", self.of.format("D w"), self.units.iter().map(|cat| {
if let Some(ref category) = cat.category {
format!("{}: {}", category, cat.units.join(", "))
} else {
cat.units.join(", ")
}
}).collect::<Vec<_>>().join("; "))
}
}

View file

@ -87,11 +87,18 @@
</div>
<div class="panel-body">
{{#if units}}
<ul>
{{#each units}}
<li><a href="/?q={{this}}">{{this}}</a></li>
{{/each}}
</ul>
{{#each units}}
{{#if category}}
<h5>{{category}}</h5>
{{else}}
<h4>Uncategorized</h4>
{{/if}}
<ul>
{{#each units}}
<li><a href="/?q={{this}}">{{this}}</a></li>
{{/each}}
</ul>
{{/each}}
{{else}}
<p>No units found.</p>
{{/if}}