-
-
Table mode: set each person's allergies and see which dishes are flagged for anyone.
-
Evaluation panel: separate 50-line test set, missed labels, cross-validation by allergen and the training-loss curve.
-
Free-text check: paste an ingredient list in English or Japanese and see which allergens are flagged and why.
Problem. When children with food allergies eat out with friends, they often get a different dish, and many feel left out. Parents and children have to read ingredient lists at every meal. Japanese law requires allergen labels on packaged food, but restaurant menus have no such requirement, so the check is manual. The author has egg and wheat allergies.
Solution. Onaji Sara ("same plate" in Japanese) reads an ingredient list in English or Japanese and flags eight common allergens: egg, milk, wheat, buckwheat, shrimp, crab, peanut and soy. Enter the allergies of everyone at the table, and the app shows which dishes have no flag for the selected allergies. No flag from this tool is not a guarantee of safety. The goal is simple: help a child and their friends discuss the same dish, while still checking the real label and asking staff.
Key features.
- An AI model that trains in the browser. Eight logistic regression classifiers learn from 127 hand-labeled ingredient lines, using character 1-to-3-gram TF-IDF features. Training takes well under a second, with no server and no API key.
- A flag from the trained model or from a keyword list is enough. The keyword list includes Japanese spelling variants and English names, including タマゴ, エビ, カニ, ソバ, ダイズ, マヨネーズ, whey, flour, toast and spaghetti. Soy sauce, miso and noodle sauces prompt checks for both wheat and soy. These are precautionary checks: recipes vary, and broad matches can also produce false flags.
- Table mode. Set each person's avoid list and see which menu items are flagged for anyone.
- Explanations. The app shows the character patterns that raised each flag.
- An evaluation panel with a separate 50-line test set, missed-label counts, recall, false flags, all test lines and their remaining misses. It also shows 5-fold cross-validation scores per allergen, the training-loss curve, and the limits. No-flag results use neutral text and explicitly say they do not guarantee safety, including in the free-text results table.
Evaluation. The separate test set has 50 synthetic ingredient lines and 53 expected allergen labels, including Japanese, English, katakana and half-width variants. None of its normalized sentences overlaps the 127 training lines. It is excluded from vocabulary building, IDF calculation, model fitting and threshold selection. It was written for this project and includes known spelling gaps, so it is not a blind or external validation set. The HTML's core code was extracted and run in Node.js; the app calculates the same results when it opens:
| System | Detected labels | Missed labels | False flags | Micro recall | Micro precision |
|---|---|---|---|---|---|
| Model only | 22 | 31 | 4 | 41.5% | 84.6% |
| Keyword only | 50 | 3 | 3 | 94.3% | 94.3% |
| Model + keyword | 50 | 3 | 6 | 94.3% | 89.3% |
Recall counts detected expected allergen labels out of all 53 expected labels, not dishes. The combined system still misses egg in "Albumen glaze over sugar decorations", milk in "Casein powder in a berry drink", and peanut in "Groundnut paste with chili and lime". Seven spot-check examples—エビマヨ, カニクリームコロッケ, タマゴサンド, ソバ, ダイズ油, 卵焼き with 醤油, and Pasta carbonara—flag every expected allergen when run with the specified ingredient text. This verifies those examples only; it does not establish safety for other recipes or labels.
Technologies used. Plain HTML, CSS and JavaScript. No frameworks, no external libraries, no server. Logistic regression with stochastic gradient descent, written from scratch. TF-IDF on character n-grams, which works for Japanese without word segmentation. Unicode NFKC normalization. HTML Canvas for the loss chart.
Target users. Families and friends who eat together, school and event catering staff, restaurant staff who answer allergy questions, and people with food allergies who travel or eat out.
Limits and next steps. This is a prototype, not a medical tool, and it can miss allergens. The training set is small and was labeled by one person, so the scores show the method, not clinical accuracy. The model alone has low cross-validation F1 for rare allergens: peanut 0.00, buckwheat 0.29, shrimp 0.40 and crab 0.40. The combined results largely come from keywords: on the separate set, adding the model detects no extra expected labels and increases false flags from 3 to 6. The 0.4 threshold and training settings were chosen using the same 127 training lines; cross-validation does not independently validate those choices. The test labels are synthetic screening assumptions, not verified product contents, and neither dataset has been reviewed by allergy specialists. The eight demo classes are not a complete list for Japanese labeling compliance; cashew and walnut are not detected. Next steps: use real product labels and a new external test set, extend coverage beyond the current eight classes, and review the flags with allergy specialists before any real use.
Links.
- Live demo: https://vpgkotaro-jpg.github.io/onaji-sara/
- Source code (MIT): https://github.com/vpgkotaro-jpg/onaji-sara
Built With
- canvas
- css3
- html5
- javascript
- logistic-regression
- machine-learning
- tf-idf