Need to remove duplicates, check images

This commit is contained in:
Álvaro González 2026-02-23 20:02:13 +01:00
parent 6aefb47839
commit f7a678d7dd
13 changed files with 214 additions and 57 deletions

View file

@ -1,3 +1,12 @@
[ [
{"name":"Temperature converter","description":"Example of simple formula, just unit conversion","input":[{"name":"Input","unit":"Kelvin"}],"output":{"name":"Output","unit":"Kelvin"},"d4rtCode":"Output = Input;","tags":["converter","temperature"]} {"name":"Temperature converter","description":r"""
Simple temperature converter example that returns the input value (Kelvin) as output.
Formula: $$T_{out} = T_{in}$$
Inputs: `Input` in kelvin (K).
Output: `Output` in kelvin (K).
![Temperature scales (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Temperature_scales.svg/800px-Temperature_scales.svg.png)
""","input":[{"name":"Input","unit":"Kelvin"}],"output":{"name":"Output","unit":"Kelvin"},"d4rtCode":"Output = Input;","tags":["converter","temperature"]}
] ]

View file

@ -1,5 +1,20 @@
[ [
{"name":"Coulomb's Law","input":[{"name":"q1","unit":"coulomb"},{"name":"q2","unit":"coulomb"},{"name":"r","unit":"meter"}],"output":{"name":"F","unit":"newton"},"d4rtCode":"F = (8.9875517923e9 * q1 * q2) / pow(r, 2);","tags":["physics","electricity","electrostatics"]}, {"name":"Coulomb's Law","input":[{"name":"q1","unit":"coulomb"},{"name":"q2","unit":"coulomb"},{"name":"r","unit":"meter"}],"output":{"name":"F","unit":"newton"},"d4rtCode":"F = (8.9875517923e9 * q1 * q2) / pow(r, 2);","description":r"""
{"name":"Ohm's Law","input":[{"name":"I","unit":"ampere"},{"name":"R","unit":"ohm"}],"output":{"name":"V","unit":"volt"},"d4rtCode":"V = I * R;","tags":["physics","electricity","electronics"]}, Calculates the magnitude of the electrostatic force between two point charges.
{"name":"Electric Power","input":[{"name":"V","unit":"volt"},{"name":"I","unit":"ampere"}],"output":{"name":"P","unit":"watt"},"d4rtCode":"P = V * I;","tags":["physics","electricity","electronics"]} Formula: $F = k \dfrac{q_1 q_2}{r^2}$ where $k = 8.9875517923\times10^9\ \mathrm{N\,m^2/C^2}$.
Inputs: `q1`, `q2` in coulombs; `r` in meters.
Output: Force `F` in newtons (N).
""","tags":["physics","electricity","electrostatics"]},
{"name":"Ohm's Law","input":[{"name":"I","unit":"ampere"},{"name":"R","unit":"ohm"}],"output":{"name":"V","unit":"volt"},"d4rtCode":"V = I * R;","description":r"""
Relates voltage, current and resistance for a linear resistor.
Formula: $V = I\,R$.
Inputs: current `I` in amperes (A), resistance `R` in ohms (Ω).
Output: voltage `V` in volts (V).
""","tags":["physics","electricity","electronics"]},
{"name":"Electric Power","input":[{"name":"V","unit":"volt"},{"name":"I","unit":"ampere"}],"output":{"name":"P","unit":"watt"},"d4rtCode":"P = V * I;","description":r"""
Calculates electrical power delivered to a load.
Formula: $P = V\,I$ (also $P = I^2 R$ or $P = V^2 / R$ when substituting Ohm's law).
Inputs: voltage `V` in volts (V), current `I` in amperes (A).
Output: power `P` in watts (W).
""","tags":["physics","electricity","electronics"]}
] ]

View file

@ -1,6 +1,52 @@
[ [
{"name":"Kinetic Energy","input":[{"name":"m","unit":"kilogram"},{"name":"v","unit":"meters per second"}],"output":{"name":"KE","unit":"joule"},"d4rtCode":"KE = 0.5 * m * pow(v, 2);","tags":["physics","energy","mechanics"]}, {"name":"Kinetic Energy","description":r"""
{"name":"Work","input":[{"name":"F","unit":"newton"},{"name":"d","unit":"meter"},{"name":"theta","unit":"degree"}],"output":{"name":"W","unit":"joule"},"d4rtCode":"var thetaRad = theta * (pi / 180); W = F * d * cos(thetaRad);","tags":["physics","energy","mechanics"]}, Energy possessed by a moving object.
{"name":"Power","input":[{"name":"W","unit":"joule"},{"name":"t","unit":"second"}],"output":{"name":"P","unit":"watt"},"d4rtCode":"P = W / t;","tags":["physics","energy","mechanics"]},
{"name":"Mass-Energy Equivalence","input":[{"name":"m","unit":"kilogram"}],"output":{"name":"E","unit":"joule"},"d4rtCode":"E = m * pow(299792458, 2);","tags":["physics","relativity","energy"]} $$KE = \frac{1}{2}mv^2$$
Where:
- $m$: Mass (kg)
- $v$: Velocity (m/s)
![Kinetic energy (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/4/44/Kinetic_energy.svg/1200px-Kinetic_energy.svg.png)
""","input":[{"name":"m","unit":"kilogram"},{"name":"v","unit":"meters per second"}],"output":{"name":"KE","unit":"joule"},"d4rtCode":"KE = 0.5 * m * pow(v, 2);","tags":["physics","energy","mechanics"]},
{"name":"Work","description":r"""
Energy transferred when a force moves an object.
$$W = F d \cos(\theta)$$
Where:
- $W$: Work (Joules)
- $F$: Force (Newtons)
- $d$: Displacement (meters)
- $\theta$: Angle between force and displacement
![Work (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/e/e7/Work.svg/800px-Work.svg.png)
""","input":[{"name":"F","unit":"newton"},{"name":"d","unit":"meter"},{"name":"theta","unit":"degree"}],"output":{"name":"W","unit":"joule"},"d4rtCode":"var thetaRad = theta * (pi / 180); W = F * d * cos(thetaRad);","tags":["physics","energy","mechanics"]},
{"name":"Power","description":r"""
Rate at which work is done or energy is transferred.
$$P = \frac{W}{t}$$
Where:
- $P$: Power (Watts)
- $W$: Work or energy (Joules)
- $t$: Time (seconds)
![Power (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/9/90/Power_equation.svg/800px-Power_equation.svg.png)
""","input":[{"name":"W","unit":"joule"},{"name":"t","unit":"second"}],"output":{"name":"P","unit":"watt"},"d4rtCode":"P = W / t;","tags":["physics","energy","mechanics"]},
{"name":"Mass-Energy Equivalence","description":r"""
Einstein's mass-energy equivalence relation.
$$E = mc^2$$
Where:
- $E$: Energy (Joules)
- $m$: Mass (kg)
- $c$: Speed of light $299{,}792{,}458\ \mathrm{m/s}$
This shows mass can be converted to energy and vice versa.
![Einstein formula (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Einstein_light_beam.svg/800px-Einstein_light_beam.svg.png)
""","input":[{"name":"m","unit":"kilogram"}],"output":{"name":"E","unit":"joule"},"d4rtCode":"E = m * pow(299792458, 2);","tags":["physics","relativity","energy"]}
] ]

View file

@ -1,5 +1,46 @@
[ [
{"name":"Density","input":[{"name":"m","unit":"kilogram"},{"name":"V","unit":"cubic meter"}],"output":{"name":"rho","unit":"kilogram per cubic meter"},"d4rtCode":"rho = m / V;","tags":["physics","mechanics","material"]}, {"name":"Density","description":r"""
{"name":"Pressure","input":[{"name":"F","unit":"newton"},{"name":"A","unit":"square meter"}],"output":{"name":"P","unit":"pascal"},"d4rtCode":"P = F / A;","tags":["physics","mechanics","fluid"]}, Mass per unit volume of a substance.
{"name":"Buoyant Force","input":[{"name":"rho","unit":"kilogram per cubic meter"},{"name":"g","unit":"meters per square second"},{"name":"V","unit":"cubic meter"}],"output":{"name":"Fb","unit":"newton"},"d4rtCode":"Fb = rho * g * V;","tags":["physics","fluid","mechanics"]}
$$\rho = \frac{m}{V}$$
Where:
- $\rho$: Density ($\mathrm{kg/m^3}$)
- $m$: Mass (kilograms)
- $V$: Volume (cubic meters)
Density is an intrinsic property of materials.
![Density illustration (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/2/2d/Density_of_solids.svg/800px-Density_of_solids.svg.png)
""","input":[{"name":"m","unit":"kilogram"},{"name":"V","unit":"cubic meter"}],"output":{"name":"rho","unit":"kilogram per cubic meter"},"d4rtCode":"rho = m / V;","tags":["physics","mechanics","material"]},
{"name":"Pressure","description":r"""
Force applied perpendicular to a surface per unit area.
$$P = \frac{F}{A}$$
Where:
- $P$: Pressure (Pascals)
- $F$: Force (Newtons)
- $A$: Area (square meters)
Pressure is transmitted equally in all directions in fluids.
![Pressure (diagram) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/9/95/Pressure_in_fluid.svg/800px-Pressure_in_fluid.svg.png)
""","input":[{"name":"F","unit":"newton"},{"name":"A","unit":"square meter"}],"output":{"name":"P","unit":"pascal"},"d4rtCode":"P = F / A;","tags":["physics","mechanics","fluid"]},
{"name":"Buoyant Force","description":r"""
Upward force exerted on an object immersed in a fluid (Archimedes' principle).
$$F_b = \rho g V$$
Where:
- $F_b$: Buoyant force (Newtons)
- $\rho$: Fluid density ($\mathrm{kg/m^3}$)
- $g$: Gravitational acceleration ($\mathrm{m/s^2}$)
- $V$: Displaced volume (cubic meters)
An object floats when buoyant force equals its weight.
![Archimedes principle (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/7/72/Archimedes-principle.svg/960px-Archimedes-principle.svg.png)
""","input":[{"name":"rho","unit":"kilogram per cubic meter"},{"name":"g","unit":"meters per square second"},{"name":"V","unit":"cubic meter"}],"output":{"name":"Fb","unit":"newton"},"d4rtCode":"Fb = rho * g * V;","tags":["physics","fluid","mechanics"]}
] ]

View file

@ -635,30 +635,6 @@ This law explains how light bends when passing between materials.''',
"tags": ["physics", "optics", "light"] "tags": ["physics", "optics", "light"]
}, },
// Buoyant Force (Archimedes' Principle)
{
"name": "Buoyant Force",
"description": r'''
Upward force exerted on an object immersed in a fluid
$$F_b = \rho g V$$
Where:
- $F_b$: Buoyant force (Newtons)
- $\rho$: Fluid density ($\mathrm{kg/m^3}$)
- $g$: Gravitational acceleration ($\mathrm{m/s^2}$)
- $V$: Displaced volume (cubic meters)
An object floats when buoyant force equals its weight.''',
"input": [
{"name": "rho", "unit": "kilogram per cubic meter"}, // Fluid density
{"name": "g", "unit": "meters per square second"}, // Gravitational acceleration
{"name": "V", "unit": "cubic meter"} // Displaced volume
],
"output": {"name": "Fb", "unit": "newton"}, // Buoyant force
"d4rtCode": "Fb = rho * g * V;",
"tags": ["physics", "fluid", "mechanics"]
},
// Area of Circle // Area of Circle
{ {

View file

@ -1,3 +1,16 @@
[ [
{"name":"Hooke's Law","input":[{"name":"k","unit":"newton per meter"},{"name":"x","unit":"meter"}],"output":{"name":"F","unit":"newton"},"d4rtCode":"F = -k * x;","tags":["physics","elasticity","oscillations"]} {"name":"Hooke's Law","description":r"""
Force exerted by a spring is proportional to its displacement (linear region).
$$F = -kx$$
Where:
- $F$: Restoring force (Newtons)
- $k$: Spring constant (N/m)
- $x$: Displacement from equilibrium (meters)
The negative sign indicates the force opposes displacement.
![Hooke's law (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/9/9d/HookesLaw.svg/800px-HookesLaw.svg.png)
""","input":[{"name":"k","unit":"newton per meter"},{"name":"x","unit":"meter"}],"output":{"name":"F","unit":"newton"},"d4rtCode":"F = -k * x;","tags":["physics","elasticity","oscillations"]}
] ]

View file

@ -1,3 +1,16 @@
[ [
{"name":"Apgar Score","input":[{"name":"HeartRate","values":["Absent","< 100 bpm>","> 100 bpm"]},{"name":"Breathing","values":["Absent","Weak, irregular","Strong, robust cry"]},{"name":"MuscleTone","values":["None","Some","Flexed arms/leg, resists extension"]},{"name":"Reflexes","values":["No response","Grimace on aggressive stimulation","Cry on stimulation"]},{"name":"SkinColor","values":["Blue or pale","Blue extremities, pink body","Pink"]}],"output":{"name":"Result","unit":"string"},"d4rtCode":"var total = indexOf(\"HeartRate\") + indexOf(\"Breathing\") + indexOf(\"MuscleTone\") + indexOf(\"Reflexes\") + indexOf(\"SkinColor\"); late var interpretation; if( total < 4 ) { interpretation = 'Critical condition'; } else if( total < 7 ){ interpretation = 'Needs assistance'; } else { interpretation = 'Normal'; } Result = 'Score: \$total - \$interpretation';","tags":["medical","pediatrics","assessment"]} {"name":"Apgar Score","description":r"""
Newborn health assessment scoring system performed at 1 and 5 minutes after birth.
The Apgar score sums five categories (02 points each):
1. Heart rate
2. Respiratory effort
3. Muscle tone
4. Reflex response
5. Color
Total score ranges from 0 to 10. Higher scores indicate better newborn condition.
![Apgar score (illustration) (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/8/80/Apgar_scale.svg/800px-Apgar_scale.svg.png)
""","input":[{"name":"HeartRate","values":["Absent","< 100 bpm>","> 100 bpm"]},{"name":"Breathing","values":["Absent","Weak, irregular","Strong, robust cry"]},{"name":"MuscleTone","values":["None","Some","Flexed arms/leg, resists extension"]},{"name":"Reflexes","values":["No response","Grimace on aggressive stimulation","Cry on stimulation"]},{"name":"SkinColor","values":["Blue or pale","Blue extremities, pink body","Pink"]}],"output":{"name":"Result","unit":"string"},"d4rtCode":"var total = indexOf(\"HeartRate\") + indexOf(\"Breathing\") + indexOf(\"MuscleTone\") + indexOf(\"Reflexes\") + indexOf(\"SkinColor\"); late var interpretation; if( total < 4 ) { interpretation = 'Critical condition'; } else if( total < 7 ){ interpretation = 'Needs assistance'; } else { interpretation = 'Normal'; } Result = 'Score: \$total - \$interpretation';","tags":["medical","pediatrics","assessment"]}
] ]

View file

@ -1,3 +1,16 @@
[ [
{"name":"Snell's Law","input":[{"name":"n1","unit":"scalar"},{"name":"n2","unit":"scalar"},{"name":"theta1","unit":"degree"}],"output":{"name":"theta2","unit":"degree"},"d4rtCode":"var theta1Rad = theta1 * (pi / 180); var sinTheta2 = (n1 * sin(theta1Rad)) / n2; theta2 = asin(sinTheta2) * (180 / pi);","tags":["physics","optics","light"]} {"name":"Snell's Law","description":r"""
Law describing refraction of light at an interface between two media.
$$n_1 \sin(\theta_1) = n_2 \sin(\theta_2)$$
Where:
- $n_1, n_2$: Refractive indices
- $\theta_1$: Angle of incidence
- $\theta_2$: Angle of refraction
This law explains how light bends when passing between materials.
![Refraction diagram (Wikipedia)](https://upload.wikimedia.org/wikipedia/commons/thumb/6/6f/Refraction_en.svg/800px-Refraction_en.svg.png)
""","input":[{"name":"n1","unit":"scalar"},{"name":"n2","unit":"scalar"},{"name":"theta1","unit":"degree"}],"output":{"name":"theta2","unit":"degree"},"d4rtCode":"var theta1Rad = theta1 * (pi / 180); var sinTheta2 = (n1 * sin(theta1Rad)) / n2; theta2 = asin(sinTheta2) * (180 / pi);","tags":["physics","optics","light"]}
] ]

View file

@ -1,3 +1,18 @@
[ [
{"name":"Ideal Gas Law","input":[{"name":"n","unit":"mole"},{"name":"T","unit":"kelvin"},{"name":"V","unit":"cubic meter"}],"output":{"name":"P","unit":"pascal"},"d4rtCode":"P = (n * 8.314462618 * T) / V;","tags":["physics","thermodynamics","gas"]} {"name":"Ideal Gas Law","description":r"""
Equation of state for an ideal gas.
$$PV = nRT$$
Where:
- $P$: Pressure (Pascals)
- $V$: Volume (m^3)
- $n$: Amount of substance (moles)
- $R$: Universal gas constant $8.314\ \mathrm{J/(mol\cdot K)}$
- $T$: Temperature (Kelvin)
This law combines Boyle's, Charles's and Avogadro's laws.
![Ideal Gas](https://upload.wikimedia.org/wikipedia/commons/thumb/0/02/Ideal_gas_sphere.svg/800px-Ideal_gas_sphere.svg.png)
""","input":[{"name":"n","unit":"mole"},{"name":"T","unit":"kelvin"},{"name":"V","unit":"cubic meter"}],"output":{"name":"P","unit":"pascal"},"d4rtCode":"P = (n * 8.314462618 * T) / V;","tags":["physics","thermodynamics","gas"]}
] ]

10
assets/llm.md Normal file
View file

@ -0,0 +1,10 @@
See all files in assets/formulas ending int d4rt.
They are dart set/arraty literals with formulas.
Add a description to each formula without that field.
The description is markdown a raw dart literal r"""like this""",
and should contain latex for math.
Include also images from wikipedia.

View file

@ -27,7 +27,7 @@ class Corpus{
final Multimap<String, Formula> _tags = Multimap.create(); final Multimap<String, Formula> _tags = Multimap.create();
final Map<String, Formula> _allFormulas = {}; final Map<String, Formula> _allFormulas = {};
void loadFormulas(List<Formula> formulas, {bool replaceOnDuplicates = false, bool checkUnits = true}) { void loadFormulas(List<Formula> formulas, {bool replaceOnDuplicates = true, bool checkUnits = true}) {
for (final formula in formulas) { for (final formula in formulas) {
if (!replaceOnDuplicates && _allFormulas.containsKey(formula.name)) { if (!replaceOnDuplicates && _allFormulas.containsKey(formula.name)) {
throw ArgumentError("Duplicate formula:$formula"); throw ArgumentError("Duplicate formula:$formula");

View file

@ -50,7 +50,13 @@ Future<Corpus> createDefaultCorpus() async{
} }
Future<void> loadFormulas() async { Future<void> loadFormulas() async {
final formulaResources = ["assets/formulas/formulas.d4rt"]; final formulaResources = [
"assets/formulas/formulas.d4rt",
"assets/formulas/electromagnetism.d4rt",
"assets/formulas/thermodynamics.d4rt",
"assets/formulas/fluids_and_pressure.d4rt",
];
for (final formRes in formulaResources) { for (final formRes in formulaResources) {
print( "Loading formulas from $formRes ..."); print( "Loading formulas from $formRes ...");

View file

@ -468,26 +468,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "10.0.9" version: "11.0.2"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.9" version: "3.0.10"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.1" version: "3.0.2"
linked_scroll_controller: linked_scroll_controller:
dependency: transitive dependency: transitive
description: description:
@ -540,10 +540,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.16.0" version: "1.17.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -881,26 +881,26 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: test name: test
sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" sha256: "75906bf273541b676716d1ca7627a17e4c4070a3a16272b7a3dc7da3b9f3f6b7"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.25.15" version: "1.26.3"
test_api: test_api:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd sha256: ab2726c1a94d3176a45960b6234466ec367179b87dd74f1611adb1f3b5fb9d55
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.7.4" version: "0.7.7"
test_core: test_core:
dependency: transitive dependency: transitive
description: description:
name: test_core name: test_core
sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" sha256: "0cc24b5ff94b38d2ae73e1eb43cc302b77964fbf67abad1e296025b78deb53d0"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.6.8" version: "0.6.12"
timing: timing:
dependency: transitive dependency: transitive
description: description:
@ -1025,10 +1025,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vector_math name: vector_math
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.4" version: "2.2.0"
vm_service: vm_service:
dependency: transitive dependency: transitive
description: description: