An interactive web prototype for exploring the geographic origins of Japanese loanwords (外来語)
Explore the report »
Features
·
Snapshots
·
Setup
·
Structure
語旅 (Kotabi), meaning "word journey," is an interactive web prototype that makes the phenomenon of Japanese loanwords (gairaigo, 外来語) explorable and visually engaging. Built with Svelte, TypeScript, and D3.js, it renders a zoomable world map where each donor country is colored using a traditional Japanese pigment palette. Users can click any country to browse its loanwords, or switch to the AI-powered Discover mode to classify a katakana word and predict its donor language, powered by a pre-trained LinearSVC classifier served through a FastAPI backend.
This project was built for COSC 402: Current Trends and Topics in Computing (HCI Interactive Prototype). It has since been extended with an emotion detection feature, which is the Feel (感情) panel, as part of a follow-up activity: Extend a prototype with emotion detection feature.
This section documents the Feel (感情) panel, which was added as an extension to the original Kotabi prototype.
The Feel panel is a third tab alongside Explore and Discover. It lets users describe how they are feeling in plain English. The backend classifies the text into one of seven emotions, joy, sadness, anger, fear, surprise, disgust, or neutral, using a fine-tuned transformer model. The result drives three things in the UI simultaneously: an emotion badge, a Japanese music playlist, and a set of thematically related loanwords highlighted on the map.
POST /emotion on the FastAPI backend.j-hartmann/emotion-english-distilroberta-base (a DistilRoBERTa model fine-tuned for emotion classification) and returns the top emotion label.| File | Description |
|---|---|
src/lib/components/FeelPanel.svelte |
The Feel panel component: input, emotion badge, YouTube player, loanword list |
| Technology | Purpose |
|---|---|
| Svelte + TypeScript | Frontend framework and type safety |
| Vite | Build tool and dev server |
| D3.js | Map rendering, zoom behavior, and data binding |
| TopoJSON | Geographic data (world-atlas) |
| FastAPI | Backend REST API for AI predictions |
| YouTube IFrame API | Embedded music player in Feel panel |
| flagcdn.com | Country flag images |
World map with Japanese pigment country colors and the Explore panel idle state
Country selected with flag, language tag, loanword count, search bar, and word cards
Katakana input, Analyze button, disclaimer note, and example word chips
Emotion input, emotion badge, music player, and related loanwords
8000git clone https://github.com/krislette/gairaigo-map.git
cd gairaigo-map
npm install
npm run dev
The app will be available at http://localhost:5173. Make sure the FastAPI backend is running before using Discover or Feel mode.
npm run build
npm run preview
npm run check
gairaigo-map/
├── public/
│ ├── favicon.svg
│ └── icons.svg
├── src/
│ ├── data/
│ │ └── gairaigo_full.json # 10,378 loanword entries across 37 donor languages
│ ├── lib/
│ │ ├── components/
│ │ │ ├── WorldMap.svelte # D3 map, zoom, pan, country rendering
│ │ │ ├── ExplorePanel.svelte # Country header, search, word list
│ │ │ ├── DiscoverPanel.svelte # Katakana input, AI prediction, result card
│ │ │ └── FeelPanel.svelte # [NEW] Emotion input, music player, loanword list
│ │ ├── stores/
│ │ │ └── mapStore.ts # Shared reactive state (activeIso2, highlights, zoom, ytPlayer)
│ │ ├── isoMapping.ts # ISO2 <-> numeric country code mapping
│ │ └── types.ts # TypeScript interfaces (includes EmotionResponse)
│ ├── App.svelte # Root layout, tab bar (now includes 感情 · Feel tab), header, footer
│ ├── app.css # Global CSS variables and design tokens
│ └── main.ts # Entry point
├── index.html
├── vite.config.ts
├── svelte.config.js
├── tsconfig.json
├── tsconfig.app.json
└── tsconfig.node.json
This project is for academic use. Loanword data is sourced from JMdict/EDICT, distributed under the Creative Commons Attribution-ShareAlike 4.0 International License by the Electronic Dictionary Research and Development Group.