activefacts 0.7.3 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/LICENSE +19 -0
  2. data/Manifest.txt +24 -2
  3. data/Rakefile +25 -3
  4. data/bin/afgen +1 -1
  5. data/bin/cql +13 -2
  6. data/css/offline.css +3 -0
  7. data/css/orm2.css +24 -0
  8. data/css/print.css +8 -0
  9. data/css/style-print.css +357 -0
  10. data/css/style.css +387 -0
  11. data/download.html +85 -0
  12. data/examples/CQL/Address.cql +3 -3
  13. data/examples/CQL/Blog.cql +13 -14
  14. data/examples/CQL/CompanyDirectorEmployee.cql +4 -4
  15. data/examples/CQL/Death.cql +3 -2
  16. data/examples/CQL/Genealogy.cql +13 -11
  17. data/examples/CQL/Marriage.cql +2 -2
  18. data/examples/CQL/Metamodel.cql +136 -93
  19. data/examples/CQL/MultiInheritance.cql +2 -2
  20. data/examples/CQL/OilSupply.cql +14 -10
  21. data/examples/CQL/Orienteering.cql +22 -19
  22. data/examples/CQL/PersonPlaysGame.cql +3 -2
  23. data/examples/CQL/SchoolActivities.cql +4 -2
  24. data/examples/CQL/SimplestUnary.cql +1 -1
  25. data/examples/CQL/SubtypePI.cql +6 -7
  26. data/examples/CQL/Warehousing.cql +16 -19
  27. data/examples/CQL/unit.cql +584 -0
  28. data/examples/index.html +276 -0
  29. data/examples/intro.html +497 -0
  30. data/examples/local.css +20 -0
  31. data/index.html +96 -0
  32. data/lib/activefacts/api/concept.rb +48 -46
  33. data/lib/activefacts/api/constellation.rb +43 -23
  34. data/lib/activefacts/api/entity.rb +2 -2
  35. data/lib/activefacts/api/instance.rb +6 -2
  36. data/lib/activefacts/api/instance_index.rb +5 -0
  37. data/lib/activefacts/api/value.rb +8 -2
  38. data/lib/activefacts/api/vocabulary.rb +15 -10
  39. data/lib/activefacts/cql/CQLParser.treetop +109 -88
  40. data/lib/activefacts/cql/Concepts.treetop +32 -10
  41. data/lib/activefacts/cql/Context.treetop +34 -0
  42. data/lib/activefacts/cql/Expressions.treetop +9 -9
  43. data/lib/activefacts/cql/FactTypes.treetop +30 -31
  44. data/lib/activefacts/cql/Language/English.treetop +50 -0
  45. data/lib/activefacts/cql/LexicalRules.treetop +2 -1
  46. data/lib/activefacts/cql/Terms.treetop +117 -0
  47. data/lib/activefacts/cql/ValueTypes.treetop +152 -0
  48. data/lib/activefacts/cql/compiler.rb +1718 -0
  49. data/lib/activefacts/cql/parser.rb +124 -57
  50. data/lib/activefacts/generate/absorption.rb +1 -1
  51. data/lib/activefacts/generate/cql.rb +111 -100
  52. data/lib/activefacts/generate/cql/html.rb +5 -5
  53. data/lib/activefacts/generate/oo.rb +3 -3
  54. data/lib/activefacts/generate/ordered.rb +51 -19
  55. data/lib/activefacts/generate/ruby.rb +10 -8
  56. data/lib/activefacts/generate/sql/mysql.rb +14 -10
  57. data/lib/activefacts/generate/sql/server.rb +29 -24
  58. data/lib/activefacts/input/cql.rb +9 -1264
  59. data/lib/activefacts/input/orm.rb +213 -200
  60. data/lib/activefacts/persistence/columns.rb +11 -10
  61. data/lib/activefacts/persistence/index.rb +15 -18
  62. data/lib/activefacts/persistence/reference.rb +17 -17
  63. data/lib/activefacts/persistence/tables.rb +50 -51
  64. data/lib/activefacts/version.rb +1 -1
  65. data/lib/activefacts/vocabulary/extensions.rb +79 -8
  66. data/lib/activefacts/vocabulary/metamodel.rb +183 -114
  67. data/spec/absorption_ruby_spec.rb +99 -0
  68. data/spec/absorption_spec.rb +3 -4
  69. data/spec/api/constellation.rb +1 -1
  70. data/spec/api/entity_type.rb +3 -1
  71. data/spec/api/instance.rb +4 -2
  72. data/spec/api/roles.rb +8 -6
  73. data/spec/api_spec.rb +1 -2
  74. data/spec/cql/context_spec.rb +71 -0
  75. data/spec/cql/samples_spec.rb +154 -0
  76. data/spec/cql/unit_spec.rb +375 -0
  77. data/spec/cql_cql_spec.rb +31 -21
  78. data/spec/cql_mysql_spec.rb +70 -0
  79. data/spec/cql_parse_spec.rb +15 -9
  80. data/spec/cql_ruby_spec.rb +27 -13
  81. data/spec/cql_sql_spec.rb +42 -16
  82. data/spec/cql_symbol_tables_spec.rb +2 -3
  83. data/spec/cqldump_spec.rb +7 -7
  84. data/spec/helpers/file_matcher.rb +39 -0
  85. data/spec/norma_cql_spec.rb +20 -12
  86. data/spec/norma_ruby_spec.rb +6 -3
  87. data/spec/norma_sql_spec.rb +6 -3
  88. data/spec/norma_tables_spec.rb +6 -4
  89. data/spec/spec_helper.rb +27 -8
  90. data/status.html +69 -0
  91. data/why.html +60 -0
  92. metadata +34 -11
  93. data/lib/activefacts/cql/DataTypes.treetop +0 -81
  94. data/spec/cql_unit_spec.rb +0 -330
@@ -3,8 +3,8 @@ vocabulary MultiInheritance;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- EmployeeID is written as AutoCounter();
7
- PersonName is written as VariableLengthText();
6
+ EmployeeID is written as AutoCounter;
7
+ PersonName is written as VariableLengthText;
8
8
  TFN is written as FixedLengthText(9);
9
9
 
10
10
  /*
@@ -3,14 +3,14 @@ vocabulary OilSupply;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- Cost is written as Money();
7
- MonthCode is written as FixedLengthText();
8
- ProductName is written as VariableLengthText();
6
+ Cost is written as Money;
7
+ MonthCode is written as FixedLengthText;
8
+ ProductName is written as VariableLengthText;
9
9
  Quantity is written as UnsignedInteger(32);
10
10
  RefineryName is written as VariableLengthText(80);
11
- RegionName is written as VariableLengthText();
11
+ RegionName is written as VariableLengthText;
12
12
  Season is written as VariableLengthText(6) restricted to {'Autumn', 'Spring', 'Summer', 'Winter'};
13
- TransportMethod is written as VariableLengthText() restricted to {'Rail', 'Road', 'Sea'};
13
+ TransportMethod is written as VariableLengthText restricted to {'Rail', 'Road', 'Sea'};
14
14
  YearNr is written as SignedInteger(32);
15
15
 
16
16
  /*
@@ -20,13 +20,11 @@ Month is identified by its Code;
20
20
  Month is in one Season;
21
21
 
22
22
  Product is identified by its Name;
23
- AcceptableSubstitutes is where
24
- Product may be substituted by alternate-Product in Season [acyclic, intransitive],
25
- alternate-Product is an acceptable substitute for Product in Season;
26
23
 
27
24
  Refinery is identified by its Name;
28
25
 
29
26
  Region is identified by its Name;
27
+
30
28
  TransportRoute is where
31
29
  TransportMethod transportation is available from Refinery to Region,
32
30
  TransportMethod transportation is available to Region from Refinery;
@@ -34,14 +32,20 @@ TransportRoute incurs at most one Cost per kl;
34
32
 
35
33
  Year is identified by its Nr;
36
34
 
35
+ AcceptableSubstitutes is where
36
+ Product may be substituted by alternate-Product in Season [acyclic, intransitive],
37
+ alternate-Product is an acceptable substitute for Product in Season;
38
+
37
39
  SupplyPeriod is identified by Year and Month where
38
40
  SupplyPeriod is in one Year,
39
41
  SupplyPeriod is in one Month;
42
+
40
43
  ProductionForecast is where
41
44
  Refinery forecasts production of Product in SupplyPeriod;
42
- RegionalDemand is where
43
- Region will need Product in SupplyPeriod;
44
45
  ProductionForecast predicts at most one Cost;
45
46
  ProductionForecast is for one Quantity;
47
+
48
+ RegionalDemand is where
49
+ Region will need Product in SupplyPeriod;
46
50
  RegionalDemand is for at most one Quantity;
47
51
 
@@ -8,27 +8,27 @@ ClubCode is written as VariableLengthText(6);
8
8
  ClubName is written as VariableLengthText(32);
9
9
  ControlNumber is written as UnsignedInteger(32) restricted to {1..1000};
10
10
  Course is written as VariableLengthText(16) restricted to {'A'..'E', 'PW'};
11
- EntryID is written as AutoCounter();
12
- EventID is written as AutoCounter();
11
+ EntryID is written as AutoCounter;
12
+ EventID is written as AutoCounter;
13
13
  EventName is written as VariableLengthText(50);
14
14
  FamilyName is written as VariableLengthText(48);
15
15
  Gender is written as FixedLengthText(1) restricted to {'F', 'M'};
16
16
  GivenName is written as VariableLengthText(48);
17
17
  Location is written as VariableLengthText(200);
18
- MapID is written as AutoCounter();
18
+ MapID is written as AutoCounter;
19
19
  MapName is written as VariableLengthText(80);
20
20
  Number is written as UnsignedInteger(32) restricted to {1..100};
21
- PersonID is written as AutoCounter();
21
+ PersonID is written as AutoCounter;
22
22
  Placing is written as UnsignedInteger(32);
23
23
  PointValue is written as UnsignedInteger(32);
24
24
  PostCode is written as UnsignedInteger(32);
25
- PunchID is written as AutoCounter();
25
+ PunchID is written as AutoCounter;
26
26
  Score is written as SignedInteger(32);
27
27
  ScoringMethod is written as VariableLengthText(32) restricted to {'Scatter', 'Score', 'Special'};
28
- SeriesID is written as AutoCounter();
28
+ SeriesID is written as AutoCounter;
29
29
  SeriesName is written as VariableLengthText(40);
30
- StartTime is written as DateAndTime();
31
- Time is written as DateAndTime();
30
+ StartTime is written as DateAndTime;
31
+ Time is written as DateAndTime;
32
32
  Year is written as UnsignedInteger(32) restricted to {1900..3000};
33
33
 
34
34
  /*
@@ -47,12 +47,14 @@ Event has at most one Number;
47
47
  Event is held on one StartTime;
48
48
  Event starts at one start-Location,
49
49
  Location is where Event starts;
50
+
50
51
  EventControl is where
51
52
  Event includes at least one ControlNumber;
53
+ EventControl has at most one PointValue;
54
+
52
55
  EventScoringMethod is where
53
56
  ScoringMethod is used for Course of Event,
54
57
  Course of Event uses at most one ScoringMethod;
55
- EventControl has at most one PointValue;
56
58
 
57
59
  Map is identified by its ID;
58
60
  Club (as Owner) owns Map,
@@ -72,32 +74,33 @@ Person has one GivenName,
72
74
  GivenName is name of Person;
73
75
  Person has at most one PostCode;
74
76
  Person was born in at most one birth-Year;
75
- Entry is identified by its ID where
76
- Person entered Course of Event,
77
- Person entered Event in at most one Course;
78
- Entry received at most one Score;
79
- Entry finished in at most one finish-Placing;
80
77
 
81
78
  Punch is identified by its ID;
79
+
82
80
  PunchPlacement is where
83
81
  Punch is placed at EventControl;
84
- Visit is where
85
- Punch was visited by Entry at Time;
86
82
 
87
83
  Series is identified by its ID;
88
84
  Event is in at most one Series;
89
85
  Series has one SeriesName (as Name),
90
86
  Name is of at most one Series;
91
87
 
88
+ Entry is identified by its ID where
89
+ Person entered Course of Event,
90
+ Person entered Event in at most one Course;
91
+ Entry received at most one Score;
92
+ Entry finished in at most one finish-Placing;
93
+
94
+ Visit is where
95
+ Punch was visited by Entry at Time;
96
+
92
97
  /*
93
98
  * Constraints:
94
99
  */
95
100
  Event is in Series
96
101
  if and only if
97
102
  Event has Number;
98
- each Event occurs at least one time in
99
- Event is called EventName,
100
- Event is in Series;
103
+ either Event is called EventName or Event is in Series;
101
104
  each EventControl occurs at least one time in
102
105
  Punch is placed at EventControl;
103
106
  each combination GivenName, FamilyName occurs at most one time in
@@ -3,8 +3,8 @@ vocabulary PersonPlaysGame;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- GameCode is written as FixedLengthText();
7
- PersonName is written as VariableLengthText();
6
+ GameCode is written as FixedLengthText;
7
+ PersonName is written as VariableLengthText;
8
8
 
9
9
  /*
10
10
  * Entity Types
@@ -12,6 +12,7 @@ PersonName is written as VariableLengthText();
12
12
  Game is identified by its Code;
13
13
 
14
14
  Person is identified by its Name;
15
+
15
16
  Playing is where
16
17
  Person plays Game;
17
18
 
@@ -4,8 +4,8 @@ vocabulary SchoolActivities;
4
4
  * Value Types
5
5
  */
6
6
  ActivityName is written as VariableLengthText(32);
7
- SchoolName is written as VariableLengthText();
8
- StudentName is written as VariableLengthText();
7
+ SchoolName is written as VariableLengthText;
8
+ StudentName is written as VariableLengthText;
9
9
 
10
10
  /*
11
11
  * Entity Types
@@ -13,11 +13,13 @@ StudentName is written as VariableLengthText();
13
13
  Activity is identified by its Name;
14
14
 
15
15
  School is identified by its Name;
16
+
16
17
  SchoolActivity is where
17
18
  School sanctions Activity;
18
19
 
19
20
  Student is identified by its Name;
20
21
  Student is enrolled in one School;
22
+
21
23
  StudentParticipation is where
22
24
  Student represents School in Activity,
23
25
  Student participates in Activity which is sanctioned by at most one School;
@@ -3,7 +3,7 @@ vocabulary SimplestUnary;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- SomeString is written as VariableLengthText();
6
+ SomeString is written as VariableLengthText;
7
7
 
8
8
  /*
9
9
  * Fact Types
@@ -3,15 +3,16 @@ vocabulary SubtypePI;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- EntrantID is written as AutoCounter();
7
- FamilyName is written as VariableLengthText();
8
- GivenName is written as VariableLengthText();
9
- TeamID is written as AutoCounter();
6
+ EntrantID is written as AutoCounter;
7
+ FamilyName is written as VariableLengthText;
8
+ GivenName is written as VariableLengthText;
9
+ TeamID is written as AutoCounter;
10
10
 
11
11
  /*
12
12
  * Entity Types
13
13
  */
14
14
  Entrant is identified by its ID;
15
+
15
16
  EntrantHasGivenName is where
16
17
  Entrant has at least one GivenName,
17
18
  GivenName is of Entrant;
@@ -24,9 +25,7 @@ Competitor has one FamilyName;
24
25
  /*
25
26
  * Constraints:
26
27
  */
27
- for each Entrant exactly one of these holds:
28
- Competitor is a subtype of Entrant,
29
- Team is a subtype of Entrant;
28
+ either Entrant is a Competitor or Entrant is a Team but not both;
30
29
  each combination FamilyName, GivenName occurs at most one time in
31
30
  Competitor has FamilyName,
32
31
  Entrant has GivenName;
@@ -3,18 +3,18 @@ vocabulary Warehousing;
3
3
  /*
4
4
  * Value Types
5
5
  */
6
- BinID is written as AutoCounter();
7
- DispatchID is written as AutoCounter();
8
- DispatchItemID is written as AutoCounter();
9
- PartyID is written as AutoCounter();
10
- ProductID is written as AutoCounter();
11
- PurchaseOrderID is written as AutoCounter();
6
+ BinID is written as AutoCounter;
7
+ DispatchID is written as AutoCounter;
8
+ DispatchItemID is written as AutoCounter;
9
+ PartyID is written as AutoCounter;
10
+ ProductID is written as AutoCounter;
11
+ PurchaseOrderID is written as AutoCounter;
12
12
  Quantity is written as UnsignedInteger(32);
13
- ReceiptID is written as AutoCounter();
14
- ReceivedItemID is written as AutoCounter();
15
- SalesOrderID is written as AutoCounter();
16
- TransferRequestID is written as AutoCounter();
17
- WarehouseID is written as AutoCounter();
13
+ ReceiptID is written as AutoCounter;
14
+ ReceivedItemID is written as AutoCounter;
15
+ SalesOrderID is written as AutoCounter;
16
+ TransferRequestID is written as AutoCounter;
17
+ WarehouseID is written as AutoCounter;
18
18
 
19
19
  /*
20
20
  * Entity Types
@@ -62,8 +62,6 @@ SalesOrderItem is identified by SalesOrder and Product where
62
62
  SalesOrderItem is for one Product;
63
63
  DispatchItem is for at most one SalesOrderItem;
64
64
  SalesOrderItem is in one Quantity;
65
- DirectOrderMatch is where
66
- PurchaseOrderItem matches SalesOrderItem;
67
65
 
68
66
  Supplier is a kind of Party;
69
67
  PurchaseOrder is to one Supplier,
@@ -84,15 +82,14 @@ Customer is a kind of Party;
84
82
  Customer made SalesOrder,
85
83
  SalesOrder was made by one Customer;
86
84
 
85
+ DirectOrderMatch is where
86
+ PurchaseOrderItem matches SalesOrderItem;
87
+
87
88
  /*
88
89
  * Constraints:
89
90
  */
90
- for each DispatchItem exactly one of these holds:
91
- DispatchItem is for TransferRequest,
92
- DispatchItem is for SalesOrderItem;
93
- for each ReceivedItem exactly one of these holds:
94
- ReceivedItem is for PurchaseOrderItem,
95
- ReceivedItem is for TransferRequest;
91
+ either DispatchItem is for TransferRequest or DispatchItem is for SalesOrderItem but not both;
92
+ either ReceivedItem is for PurchaseOrderItem or ReceivedItem is for TransferRequest but not both;
96
93
  PurchaseOrderItem matches SalesOrderItem
97
94
  only if PurchaseOrderItem is for Product and SalesOrderItem is for Product;
98
95
  each Bin occurs at most one time in
@@ -0,0 +1,584 @@
1
+ vocabulary Units;
2
+
3
+ // primitive units:
4
+ // m kg sec coul candela dollar bit erlang K
5
+
6
+ // prefixes
7
+ 1e24 converts to yotta;
8
+ 1e21 converts to zetta;
9
+ 1e18 converts to exa;
10
+ 1e15 converts to peta;
11
+ 1e12 converts to tera;
12
+ 1e9 converts to giga;
13
+ 1e6 converts to mega;
14
+ 1e4 converts to myria;
15
+ 1e3 converts to kilo;
16
+ 1e2 converts to hecto;
17
+ 1e1 converts to deka;
18
+ 1e-1 converts to deci;
19
+ 1e-2 converts to centi;
20
+ 1e-3 converts to milli;
21
+ 1e-6 converts to micro;
22
+ 1e-9 converts to nano;
23
+ 1e-12 converts to pico;
24
+ 1e-15 converts to femto;
25
+ 1e-18 converts to atto;
26
+ 1e-21 converts to zopto;
27
+ 1e-24 converts to yocto;
28
+ 0.5 converts to semi;
29
+ 0.5 converts to demi;
30
+
31
+ 1 yotta converts to Y;
32
+ 1 zetta converts to Z;
33
+ 1 exa converts to E;
34
+ 1 peta converts to P;
35
+ 1 tera converts to T;
36
+ 1 giga converts to G;
37
+ 1 mega converts to M;
38
+ 1 kilo converts to k;
39
+ 1 hecto converts to h;
40
+ 1 deka converts to da;
41
+ 1 deci converts to d;
42
+ 1 centi converts to c;
43
+ 1 milli converts to m;
44
+ 1 nano converts to n;
45
+ 1 pico converts to p;
46
+ 1 femto converts to f;
47
+ 1 atto converts to a;
48
+ 1 zopto converts to z;
49
+ 1 yocto converts to y;
50
+
51
+ // binary prefixes introduced in 1999
52
+ 1152921504606846976 converts to exbi;
53
+ 1125899906842624 converts to pebi;
54
+ 1099511627776 converts to tebi;
55
+ 1073741824 converts to gibi;
56
+ 1048576 converts to mebi;
57
+ 1024 converts to kibi;
58
+ 1 exbi converts to Ei;
59
+ 1 pebi converts to Pi;
60
+ 1 tebi converts to Ti;
61
+ 1 gibi converts to Gi;
62
+ 1 mebi converts to Mi;
63
+ 1 kibi converts to Ki;
64
+
65
+ // Dimensionless Constants
66
+ 13 converts to bakersdozen;
67
+ 1/24 converts to caratgold;
68
+ 12 converts to dozen;
69
+ 144 converts to gross;
70
+ 1/24 converts to karat;
71
+ 6.022169e+23 converts to mole approximately;
72
+ 3.14159265358979 converts to pi;
73
+ 1/200 converts to proof;
74
+ 25 converts to quire;
75
+ 500 converts to ream;
76
+ 0.5 pi converts to radian;
77
+ 1/180 pi radian converts to degree;
78
+ 2 pi radian converts to circle;
79
+ 1 circle converts to turn;
80
+ 1 turn converts to revolution;
81
+ 1 turn converts to rev;
82
+ 0.9 degree converts to grade;
83
+
84
+ // Dimensional constants
85
+ 9.80665 m sec^-2 converts to g; // Average gravitational pull at sea level
86
+ 6.6739e-11 m^3 kg^-1 sec^-2 converts to bigG; // The gravtational constant
87
+ 299792458.0 m sec^-1 converts to lightspeed approximately; // Speed of light
88
+ 149597871000.0 m converts to au approximately; // Astronomical unit
89
+ 1.6021917e-19 coul converts to e approximately; // Charge on an electron
90
+ 1 lightspeed^2 converts to energy; // Thanks Einstein!
91
+ 133322.0 kg m^-2 sec^-2 converts to mercury; // Atmospheric pressure
92
+ 1.0e-15 m converts to fermi;
93
+ 1 g converts to force;
94
+ 1 mercury converts to hg;
95
+ 1 degree converts to arcdeg;
96
+ 1/60 arcdeg converts to arcmin;
97
+ 1/60 arcmin converts to arcsec;
98
+ 1/36 erlang converts to ccs;
99
+ 1 radian^2 converts to steradian;
100
+ 4 pi steradian converts to sphere;
101
+ 1 steradian converts to sr;
102
+
103
+ // Time
104
+ 1 sec converts to second;
105
+ 1 sec converts to s;
106
+ 60 sec converts to minute;
107
+ 1 minute converts to min;
108
+ 60 min converts to hour;
109
+ 1 hour converts to hr;
110
+ 24 hr converts to day;
111
+ 7 day converts to week;
112
+ 14 day converts to fortnight;
113
+ 365.24219879 day converts to year approximately;
114
+ 1 year converts to yr;
115
+ 1/12 year converts to month;
116
+ 1 month converts to mo;
117
+ 1.0e-06 sec converts to us;
118
+ 10 yr converts to decade;
119
+ 100 year converts to century;
120
+ 1000 year converts to millennium;
121
+ 1 rev minute^-1 converts to rpm;
122
+ 1 rev sec^-1 converts to rps;
123
+
124
+ // Mass
125
+ 0.001 kg converts to gram;
126
+ 1 gram converts to gm;
127
+ 1 gram converts to gramme;
128
+ 100 kg converts to quintal;
129
+ 1000.0 kg converts to metricton;
130
+ 1000000.0 gm converts to tonne;
131
+
132
+ // Avoirdupois and Apothecary
133
+ 0.45359237 kg converts to lb;
134
+ 1 lb converts to pound;
135
+ 1 lb g converts to lbf;
136
+ 1/16 lb converts to ounce;
137
+ 1 ounce converts to oz;
138
+ 1/16 oz converts to dram;
139
+ 1 dram converts to dr;
140
+ 1/7000 lb converts to grain;
141
+ 60 grain converts to drachm;
142
+ 1 grain converts to gr;
143
+ 2000 lb converts to shortton;
144
+ 1 shortton converts to ton;
145
+ 2240 lb converts to longton;
146
+ 14 lb converts to stone;
147
+ 100 lb converts to shorthundredweight;
148
+ 25 lb converts to shortquarter;
149
+ 112 lb converts to longhundredweight;
150
+ 28 lb converts to longquarter;
151
+ 252 lb converts to weymass;
152
+ 94 lb converts to bag;
153
+ 100 lb converts to cental;
154
+ 20 grain converts to scruple;
155
+ 60 grain converts to apdram;
156
+ 480 grain converts to apounce;
157
+ 5760 grain converts to appound;
158
+ 1 appound converts to troypound;
159
+
160
+ // Length, Area and Volume
161
+ 1 m converts to meter;
162
+ 1 meter converts to metre;
163
+ 0.001 m converts to mm;
164
+ 1.0e-06 meter converts to micron;
165
+ 1.0e-10 meter converts to angstrom;
166
+ 0.01 m^3 converts to cc;
167
+ 1000.0 cc converts to liter;
168
+ 1 liter converts to litre;
169
+ 0.001 liter converts to ml;
170
+ 100.0 m^2 converts to are;
171
+ 10000.0 m^2 converts to hectare;
172
+ 0.0003 m^3 converts to drop;
173
+
174
+ 25.4 mm converts to inch/inches;
175
+ 1 inch converts to in;
176
+ 12 in converts to foot/feet;
177
+ 1 foot converts to ft;
178
+ 3 ft converts to yard;
179
+ 1 yard converts to yd;
180
+ 5.5 yd converts to rod;
181
+ 1 rod converts to rd;
182
+ 1 rd converts to perch;
183
+ 1 rd converts to pole;
184
+ 5280 ft converts to mile;
185
+ 1 mile converts to mi;
186
+ 100 ft^2 converts to square;
187
+ 1210.0 yd converts to rood;
188
+ 33/50 ft converts to link;
189
+ 4840 yd^2 converts to acre;
190
+ 0.001 in converts to mil;
191
+ 0.01 in converts to caliber;
192
+ 1/40 in converts to bottommeasure;
193
+ 1/12 in converts to line;
194
+ 1/3 in converts to barleycorn;
195
+ 3 in converts to palm;
196
+ 4 in converts to hand;
197
+ 9 in converts to quarter;
198
+ 9 in converts to span;
199
+ 18 in converts to cubit;
200
+ 45 in converts to ell;
201
+ 7/8 in converts to finger;
202
+ 1.5 ft^3 min^-1 converts to minersinch;
203
+ 16/15 ft converts to frenchfoot;
204
+ 1 frenchfoot converts to frenchfeet;
205
+ 6 frenchfeet converts to toise;
206
+ 36 in converts to pace;
207
+ 2.5 feet converts to militarypace;
208
+ 1 ft converts to engineerslink;
209
+ 100 ft converts to engineerschain;
210
+
211
+ 331.46 m sec^-1 converts to mach;
212
+ 1 mile hr^-1 converts to mph;
213
+
214
+ // Nautical
215
+ 3 mi converts to league;
216
+ 1852 m converts to nmile;
217
+ 3 nmile converts to marineleague;
218
+ 1 nmile converts to nauticalmile;
219
+ 6 ft converts to fathom;
220
+ 1 nmile hr^-1 converts to knot;
221
+ 6080 ft hr^-1 converts to admiraltyknot;
222
+ 100 ft^3 converts to registerton;
223
+ 40 ft^3 converts to shippington;
224
+ 35 ft^3 converts to displacementton;
225
+
226
+ // US Liquid
227
+ 231 in^3 converts to gallon;
228
+ 1.20095 converts to imperial;
229
+ 1 gallon converts to gal;
230
+ 1/4 gal converts to quart;
231
+ 1 quart converts to qt;
232
+ 1/2 qt converts to pint;
233
+ 1 pint converts to pt;
234
+ 1/16 pt converts to floz;
235
+ 1/8 floz converts to fldr;
236
+ 3/2 floz converts to shot;
237
+
238
+ // US dry measures
239
+ 268.8025 in^3 gallon^-1 converts to dry approximately;
240
+ 8 dry quart converts to peck;
241
+ 1 peck converts to pk;
242
+ 4 peck converts to bushel;
243
+ 1 bushel converts to bu;
244
+ 36 bushel converts to chaldron;
245
+ 4 bu converts to coomb;
246
+ 80 bu converts to last;
247
+ 3 bu converts to sack;
248
+ 8 bu converts to seam;
249
+ 2 bu converts to strike;
250
+ 40 bu converts to wey;
251
+
252
+ // British dry
253
+ 277.42 in^3 converts to brgallon approximately;
254
+ 1/4 brgallon converts to brquart;
255
+ 1/2 brquart converts to brpint;
256
+ 1/20 brpint converts to brfloz;
257
+ 554.84 in^3 converts to brpeck approximately;
258
+ 4 brpeck converts to brbushel;
259
+ 37.5 brgallon converts to cran;
260
+
261
+ // Energy and Work
262
+ 1 kg m sec^-2 converts to newton;
263
+ 1 newton converts to nt;
264
+ 1 newton converts to N;
265
+ 1 nt m converts to joule;
266
+ 4.1868 joule converts to cal;
267
+ 1000000.0 cal converts to thermie;
268
+ 550 ft lb g sec^-1 converts to horsepower;
269
+ 1 horsepower converts to hp;
270
+ 0.01 m gm sec^-2 converts to dyne;
271
+ 0.01 m^2 gm sec^-2 converts to erg;
272
+ 1 cal converts to calorie;
273
+ 1055.06 joule converts to britishthermalunit approximately;
274
+ 1 britishthermalunit converts to btu;
275
+ 100000.0 btu converts to therm;
276
+ 1000.0 cal converts to frigorie;
277
+
278
+ // Electrical
279
+ 1 coul converts to coulomb;
280
+ 1 coul converts to C;
281
+ 3.336e-30 coul m converts to debye;
282
+ 1 coul sec^-1 converts to ampere;
283
+ 1 ampere converts to amp;
284
+ 1 joule sec^-1 converts to watt;
285
+ 1 watt amp^-1 converts to volt;
286
+ 1 volt amp^-1 converts to ohm;
287
+ 1 ohm^-1 converts to siemens;
288
+ 1 ohm^-1 converts to mho;
289
+ 1 coul volt^-1 converts to farad;
290
+ 1 sec^2 farad^-1 converts to henry;
291
+ 0.001 henry converts to mh;
292
+ 1 volt sec converts to weber;
293
+ 1 weber m^-2 converts to tesla;
294
+ 1 volt converts to V;
295
+ 1000.0 ohm converts to kilohm;
296
+ 1000000.0 ohm converts to megohm;
297
+ 0.0001 weber m^-2 converts to gauss;
298
+ 1.0e-08 weber converts to maxwell;
299
+ 1.0e-12 farad converts to pf;
300
+ 3.33564095198152e-10 coul converts to statcoul;
301
+ 1 statcoul converts to statcoulomb;
302
+ 96520.0 coul converts to faraday;
303
+ 3.33564e-10 coul converts to franklin;
304
+ 10 amp converts to biot;
305
+ 0.795775 amp converts to gilbert;
306
+ 250.0 pi amp m^-1 converts to oersted;
307
+ 1 oersted converts to oe;
308
+ 3.33564095198152e-10 amp converts to statamp;
309
+ 1 statamp converts to statampere;
310
+ 299.792458 volt converts to statvolt;
311
+
312
+ // Frequency
313
+ 1 sec^-1 converts to hertz;
314
+ 1 hertz converts to Hz;
315
+ 1 sec^-1 converts to hz;
316
+ 1000.0 sec^-1 converts to khz;
317
+ 1000000.0 sec^-1 converts to mhz;
318
+ 1000000.0 sec^-1 converts to rutherford;
319
+ 1000000000000.0 hertz converts to fresnel;
320
+
321
+ // Light
322
+ 1 candela converts to cd;
323
+ 1.02 candela converts to candle;
324
+ 1 cd sr converts to lumen;
325
+ 1 cd sr m^-2 converts to lux;
326
+ 1 lumen ft^-2 converts to footcandle;
327
+ 1 cd pi^-1 ft^-2 converts to footlambert;
328
+ 1 cd m^-2 converts to nit;
329
+ 0.92 cd converts to hefnercandle;
330
+ 100.0 cd m^-2 converts to stilb;
331
+ 1 cd pi^-1 m^-2 converts to apostilb;
332
+ 1 cd pi^-1 m^-2 converts to blondel;
333
+ 100.0 cd pi^-1 m^-2 converts to equivalentphot;
334
+ 100.0 cd pi^-1 m^-2 converts to lambert;
335
+ 1 lumen pi^-1 ft^-2 converts to equivalentfootcandle;
336
+ 100.0 lumen m^-2 converts to phot;
337
+ 1 lumen pi^-1 m^-2 converts to equivalentlux;
338
+ 0.001 lux converts to nox;
339
+
340
+ // Computer terms
341
+ 1 bit sec^-1 converts to baud;
342
+ 8 bit converts to byte;
343
+ 512 byte converts to block;
344
+ 1024 byte converts to kbyte;
345
+ 1024 kbyte converts to megabyte;
346
+ 1024 megabyte converts to gigabyte;
347
+ 1 megabyte converts to meg;
348
+
349
+ // Temperature
350
+ 1 K + 273.15 converts to degC;
351
+ 5/9 degC + 32 converts to degF;
352
+ 1 K converts to kelvin;
353
+ 5/4 degC converts to degreaumur;
354
+ 1 degF converts to degreerankine;
355
+ 1 degF converts to degreesrankine;
356
+ 1 degreesrankine converts to degrankine;
357
+
358
+ // Astronomical
359
+ 23.934469444 hour converts to siderealday;
360
+ 1/24 siderealday converts to siderealhour;
361
+ 27.32152777 day converts to siderealmonth;
362
+ 365.256360417 day converts to siderealyear;
363
+ 29.5305555 day converts to lunarmonth;
364
+ 12 lunarmonth converts to lunaryear;
365
+ 1 lunarmonth converts to synodicmonth;
366
+ 1 lightspeed yr converts to lightyear;
367
+ 1 year converts to solaryear;
368
+ 1 year converts to tropicalyear;
369
+ 5.97223e+24 kg converts to m_earth;
370
+ 7.34e+22 kg converts to m_moon;
371
+ 1.98843e+30 kg converts to m_sun;
372
+ 1 au radian arcsec^-1 converts to parsec;
373
+ 1 parsec converts to pc;
374
+ 1 au converts to astronomicalunit;
375
+
376
+ // Atomic
377
+ 1.6606e-27 kg converts to neutronmass;
378
+ 1.6726e-27 kg converts to protonmass;
379
+ 9.1095e-31 kg converts to electronmass;
380
+ 1.055e-34 joule sec converts to hbar;
381
+ 1.1125945705385e-10 hbar^2 C^2 N^-1 m^-2 e^-2 electronmass^-1 converts to bohrradius;
382
+ 1.66044e-27 kg converts to atomicmassunit approximately;
383
+ 1 atomicmassunit converts to amu;
384
+ 1 amu converts to dalton;
385
+ 6.626e-34 joule sec converts to planck; // The Planck constant
386
+ 1000000000.0 e volt converts to bev;
387
+ 1 e V converts to eV;
388
+ 1 e volt converts to electronvolt;
389
+ 1 e volt converts to ev;
390
+
391
+ // British and surveying
392
+ 220 yd converts to furlong;
393
+ 22 yd converts to gunterschain;
394
+ 1200/3937 m ft^-1 converts to british;
395
+ 66 ft converts to chain;
396
+ 1 british ft converts to geodeticfoot;
397
+ 1 british ft converts to surveyfoot;
398
+ 3 surveyfoot converts to surveyyard;
399
+ 66 ft converts to surveyorschain;
400
+ 33/50 ft converts to surveyorslink;
401
+ 720 ft converts to cable;
402
+ 40 yd converts to bolt;
403
+ 20 ft converts to rope;
404
+ 1852 m converts to geographicalmile;
405
+
406
+ // Pressure
407
+ 101325.0 nt m^-2 converts to atmosphere;
408
+ 100000.0 nt m^-2 converts to bar;
409
+ 1 lb g in^-2 converts to psi;
410
+ 1 atmosphere converts to atm;
411
+ 0.001 m hg converts to torr;
412
+ 0.1 nt m^-2 converts to barie;
413
+ 0.1 nt m^-2 converts to barye;
414
+ 1 nt m^-2 converts to pascal;
415
+ 1000.0 nt m^-2 converts to pieze;
416
+
417
+ // Printers
418
+ 1/6 in converts to pica;
419
+ 1/72 in converts to point;
420
+
421
+ // Alcohol and wine
422
+ 1/8 qt converts to noggin;
423
+ 1/4 pt converts to gill;
424
+ 4/5 qt converts to fifth;
425
+ 42 gal converts to barrel;
426
+ 2 barrel converts to hogshead;
427
+ 4/5 gal converts to jeroboam;
428
+ 1 hogshead converts to hd;
429
+ 4 barrel converts to pipe;
430
+ 8 barrel converts to tun;
431
+ 9 gal converts to firkin;
432
+ 2 qt converts to magnum;
433
+ 18 gal converts to kilderkin;
434
+ 156 floz converts to rehoboam;
435
+
436
+ // Cooking measures
437
+ 1/60 fldr converts to minim;
438
+ 4 fldr converts to tablespoon;
439
+ 1 tablespoon converts to tbl;
440
+ 1 tablespoon converts to tbsp;
441
+ 4/3 fldr converts to teaspoon;
442
+ 1 teaspoon converts to tsp;
443
+ 1/2 pt converts to cup;
444
+
445
+ // Radiation
446
+ 37000000000.0 sec^-1 converts to curie;
447
+ 2.7027027027027e-11 curie converts to becquerel;
448
+ 0.000258 curie kg^-1 converts to rontgen;
449
+ 8.4 rontgen converts to sievert;
450
+
451
+ // Flow rate and consumption
452
+ 1 ft^3 sec^-1 converts to cfs;
453
+ 1000000.0 gal day^-1 converts to mgd;
454
+ 1 mile gal^-1 converts to mpg;
455
+
456
+ // Lumber
457
+ 144 in^3 converts to boardfoot;
458
+ 128 ft^3 converts to cord;
459
+ 1 cord converts to cordfoot;
460
+ 1 ft^3 converts to timberfoot;
461
+
462
+ // Thread
463
+ 900 ft pound^-1 converts to linenyarncount;
464
+ 1 meter gram^-1 converts to metricyarncount;
465
+ 0.000111111111111111 gram m converts to denier;
466
+ 1680 ft pound^-1 converts to worstedyarncount;
467
+ 2520 ft pound^-1 converts to cottonyarncount;
468
+ 120 yd converts to skein;
469
+ 14400 yd converts to spindle;
470
+
471
+ // Jewelers
472
+ 0.205 g converts to carat;
473
+ 1/20 oz converts to pennyweight;
474
+ 1 pennyweight converts to pwt;
475
+ 0.2 g converts to metriccarat;
476
+ 0.002 gram converts to jewlerspoint;
477
+
478
+ // Trivia
479
+ 1.0e-06 sec converts to sigma;
480
+ 1 m^3 converts to stere;
481
+ 0.0001 m^2 sec^-1 converts to stoke;
482
+ 4600000.0 m^2 sec^-2 converts to tnt;
483
+ 1.00202e-13 m converts to Xunit;
484
+ 1.0e-28 m^2 converts to barn;
485
+ 1 m^-1 converts to dipotre;
486
+ 100 kg converts to doppelzentner;
487
+ 0.01 m sec^-2 converts to galileo;
488
+ 6.28e-05 gram converts to iudiptheria;
489
+ 4.167e-05 gram converts to iuinsulin;
490
+ 6.0e-07 gram converts to iupenicillin;
491
+ 1 kg converts to key;
492
+ 100 kg m g sec converts to poncelet;
493
+ 2 pi sec^-1 converts to pulsatance;
494
+ 10 m^2 nt^-1 sec^-1 converts to rhe;
495
+ 0.001 apostilb converts to skot;
496
+ 1000.0 nt converts to sthene;
497
+ 0.001 gram m converts to tex;
498
+ 1 gram g cc converts to water;
499
+ 1.0e-12 m^2 newton^-1 converts to brewster;
500
+ 0.01 grade converts to centesimalminute;
501
+ 0.0001 grade converts to centesimalsecond;
502
+ 37.2 inch converts to scottishell;
503
+ 45 inch converts to englishell;
504
+ 27 inch converts to flemishell;
505
+ 1 gm force sec^2 m^-1 converts to hyl;
506
+ 1000 lbf converts to kip;
507
+ 1.0e-09 m hg m^3 s^-1 converts to lusec;
508
+ 100.0 gm m^-1 sec^-1 converts to poise;
509
+ 4 pi sr converts to spat;
510
+ 1/4 pi in^2 converts to circularinch;
511
+ 2.5e-07 pi in^2 converts to circularmil;
512
+ 1.0e-11 m hg m^3 s^-1 converts to clusec;
513
+ 0.0906 gm converts to crith;
514
+ // 1.38047e-16 erg degC^-1 converts to k;
515
+ 100.0 cal m^-2 converts to langley;
516
+ 1 ft lb sec^-2 converts to poundal;
517
+ 100 erg gm^-1 converts to rad;
518
+ 12000 btu ton^-1 hour^-1 converts to refrigeration;
519
+ 1 ft^2 converts to sabin;
520
+ 1 lb g sec^2 ft^-1 converts to slug;
521
+ 191.835 ft converts to arpentlin;
522
+ 1.0e-09 weber m^-2 converts to gamma;
523
+ 1/16 yd converts to nail;
524
+ 3.5 mi converts to parasang;
525
+ 1 poundal converts to pdl;
526
+ 13.6054 ev converts to rydberg;
527
+ 27.52 mi converts to arpentcan;
528
+ 1/4 mi^2 converts to homestead;
529
+ 1/4 mi^2 converts to quartersection;
530
+ 1 mi^2 converts to section;
531
+ 36 mi^2 converts to township;
532
+
533
+ /*
534
+ * REVISIT: These currency conversions haven't been updated since 1993
535
+ *
536
+ 5 dollar converts to fin ephemeral;
537
+ 1 dollar converts to argentinapeso ephemeral;
538
+ 0.66 dollar converts to australiadollar ephemeral;
539
+ 2.6522 dollar converts to bahraindinar ephemeral;
540
+ 1.9e-05 dollar converts to brazilcruzeiro ephemeral;
541
+ 1.49 dollar converts to britainpound ephemeral;
542
+ 1 britainpound converts to greatbritainpound;
543
+ 1 dollar converts to buck ephemeral;
544
+ 0.77 dollar converts to canadadollar ephemeral;
545
+ 0.01 dollar converts to cent ephemeral;
546
+ 0.0025 dollar converts to chilepeso ephemeral;
547
+ 0.174856 dollar converts to chinarenminbi ephemeral;
548
+ 0.001495 dollar converts to colombiapeso ephemeral;
549
+ 0.034 dollar converts to czechkoruna ephemeral;
550
+ 0.15 dollar converts to denmarkkrone ephemeral;
551
+ 0.000539 dollar converts to ecuadorsucre ephemeral;
552
+ 0.0043 dollar converts to greecedrachma ephemeral;
553
+ 0.13 dollar converts to hongkongdollar ephemeral;
554
+ 0.011 dollar converts to hungaryforint ephemeral;
555
+ 0.03211 dollar converts to indiarupee ephemeral;
556
+ 0.0004782 dollar converts to indonesiarupiah ephemeral;
557
+ 0.3642 dollar converts to israelshekel ephemeral;
558
+ 0.0093 dollar converts to japanyen ephemeral;
559
+ 1.4682 dollar converts to jordandinar ephemeral;
560
+ 3.3173 dollar converts to kuwaitdinar ephemeral;
561
+ 0.000578 dollar converts to lebanonpound ephemeral;
562
+ 0.338 dollar converts to malaysiaringgit ephemeral;
563
+ 2.6042 dollar converts to maltalira ephemeral;
564
+ 0.3205128 dollar converts to mexicopeso ephemeral;
565
+ 0.539 dollar converts to newzealanddollar ephemeral;
566
+ 0.139 dollar converts to norwaykrone ephemeral;
567
+ 0.037 dollar converts to pakistanrupee ephemeral;
568
+ 0.5065 dollar converts to perunewsol ephemeral;
569
+ 0.03738 dollar converts to philippinespeso ephemeral;
570
+ 5.9e-05 dollar converts to polandzloty ephemeral;
571
+ 0.26702 dollar converts to saudiarabiariyal ephemeral;
572
+ 0.6157 dollar converts to singaporedollar ephemeral;
573
+ 0.034 dollar converts to slovakkoruna ephemeral;
574
+ 0.21 dollar converts to southafricarand ephemeral;
575
+ 0.001 dollar converts to southkoreawon ephemeral;
576
+ 0.13 dollar converts to swedenkrona ephemeral;
577
+ 0.66 dollar converts to switzerlandfranc ephemeral;
578
+ 0.038285 dollar converts to taiwandollar ephemeral;
579
+ 0.03962 dollar converts to thailandbaht ephemeral;
580
+ 9.29e-05 dollar converts to turkeylira ephemeral;
581
+ 0.2723 dollar converts to unitedarabdirham ephemeral;
582
+ 0.246852 dollar converts to uruguaynewpeso ephemeral;
583
+ 0.011 dollar converts to venezuelabolivar ephemeral;
584
+ */