Expand description
WebAssembly bindings for hs-predict.
Exposes three APIs:
classify_smiles(smiles)— SMILES → functional groups + HS heading hintclassify_product(product_json)— full rule-based pipeline (Priorities 1–3)WasmSession— Akinator-style interactive session
Build with:
wasm-pack build --target web --release§JavaScript usage
import init, { classify_smiles, WasmSession } from './pkg/hs_predict_wasm.js';
await init();
// 1. SMILES classification
const r = classify_smiles('CC(O)=O');
// → { organic_class: "organic", functional_groups: ["CarboxylicAcid"],
// heading_hint: { chapter: 29, heading: 2915, confidence: 0.6, rationale: "..." } }
// 2. Rule-based pipeline
const pred = classify_product(JSON.stringify({
identifier: { cas: "1310-73-2" },
physical_form: "Solid"
}));
// → { hs_code: "281511", confidence: 1.0, ... }
// 3. Interactive session
const session = new WasmSession();
const q1 = session.start();
// → { step: "Identifier", prompt: "Please enter a CAS number...", type: "text" }
const r1 = session.answer(JSON.stringify({ Text: "1310-73-2" }));
// → { type: "NeedMoreInfo", next_question: { step: "IsMixture", ... } }Structs§
- Wasm
Session - Interactive Akinator-style HS classification session.
Functions§
- classify_
product - Classify a chemical product using the full rule-based pipeline (Priorities 1–3).
- classify_
smiles - Analyse a SMILES string and return functional-group + HS heading hint.