open-index/open-npm huggingface dataset:
npm package: @recipe-scope/food-data-ja
Description: Japanese food composition data based on the Standard Tables of Food Composition in Japan
Author: recipe-scope
Latest version: 0.1.0

# @recipe-scope/food-data-ja

Japanese food composition data based on the Standard Tables of Food Composition in Japan (日本食品標準成分表).

## Installation

```bash
npm install @recipe-scope/food-data-ja
```

## Usage

### Basic Usage

```typescript
import {
  foodDatabase,
  getFoodDataById,
  exactAliasMap,
  foodNameHiraganaMap
} from '@recipe-scope/food-data-ja';

// Get food data by ID
const sugar = getFoodDataById(3003);
console.log(sugar?.normalizedName); // '砂糖'

// Use with @recipe-scope/ingredient-converter
import { InMemorySearchProvider } from '@recipe-scope/ingredient-converter';

const provider = new InMemorySearchProvider(foodDatabase, {
  exactAliasMap,
  hiraganaMap: foodNameHiraganaMap
});
```

### Database Contents

The database includes:

- **18 food categories** from the Standard Tables:
  1. Cereals (穀類)
  2. Potatoes & Starches (いも及びでん粉類)
  3. Sugars & Sweeteners (砂糖及び甘味類)
  4. Pulses (豆類)
  5. Nuts & Seeds (種実類)
  6. Vegetables (野菜類)
  7. Fruits (果実類)
  8. Mushrooms (きのこ類)
  9. Algae (藻類)
  10. Fish & Shellfish (魚介類)
  11. Meats (肉類)
  12. Eggs (卵類)
  13. Dairy Products (乳類)
  14. Fats & Oils (油脂類)
  15. Confectioneries (菓子類)
  16. Beverages (し好飲料類)
  17. Seasonings & Spices (調味料及び香辛料類)
  18. Prepared Foods (調理済み流通食品類)

- **External foods** not in the official tables:
  - Water (水) - ID: 90003

### Adding Custom Foods

```typescript
import { foodDatabase } from '@recipe-scope/food-data-ja';
import type { FoodDataEntry } from '@recipe-scope/food-data-ja';

// Create custom food entries
const customFoods: Map<number, FoodDataEntry> = new Map([
  [90001, {
    foodId: 90001,
    normalizedName: '特製たれ',
    aliases: ['特製ダレ', 'とくせいたれ'],
    foodType: 'liquid',
    conversion: {
      densityGPerMl: 1.1
    },
    enercKcal: 50
  }]
]);

// Merge with existing database (custom foods take priority)
const mergedDatabase = new Map([...foodDatabase, ...customFoods]);
```

### Food ID Ranges

- **1-89999**: Official Standard Tables foods
- **90000+**: External/custom foods

## Data Source & Credits

本パッケージの食品成分データは、以下を元に作成しています：

- [日本食品標準成分表（八訂）](https://www.mext.go.jp/a_menu/syokuhinseibun/mext_00001.html) - 文部科学省
- [katoharu432/standards-tables-of-food-composition-in-japan](https://github.com/katoharu432/standards-tables-of-food-composition-in-japan) (CC BY 4.0)

## License

This package is licensed under **CC BY 4.0** (Creative Commons Attribution 4.0 International).

See [LICENSE](./LICENSE) for details.