Skip to content

go library bindings for docker-composed Ichiran–a morphological analyzer / romanizer for japanese

License

Notifications You must be signed in to change notification settings

tassa-yoniso-manasi-karoto/go-ichiran

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Status: alpha Go Reference Go Report Card

A Go library for Japanese text analysis using the Ichiran morphological analyzer in Docker compose containers. This client provides easy access to Japanese language parsing, including readings, translations, and grammatical analysis.

Features

  • Morphological analysis of Japanese text
  • Kanji readings and translations
  • Romaji (romanization) support
  • Part-of-speech tagging
  • Conjugation analysis
  • Download & manage the docker containers directly using the Docker Compose Go API

Installation

go get github.com/tassa-yoniso-manasi-karoto/go-ichiran

tldr

func main() {
	// Initialize Docker client with default configuration
	docker, err := ichiran.NewDocker()
	if err != nil {
		panic(err)
	}
	defer docker.Close()

	// Initialize the environment (downloads, builds and starts containers if they are not running)
	if err := docker.Init(); err != nil {
		panic(err)
	}

	tokens, err := ichiran.Analyze("私は日本語を勉強しています。")
	if err != nil {
		panic(err)
	}

	fmt.Printf("Tokenized: %#v\n",		tokens.Tokenized())
	fmt.Printf("TokenizedParts: %#v\n",	tokens.TokenizedParts())
	fmt.Printf("Kana: %#v\n",		tokens.Kana())
	fmt.Printf("KanaParts: %#v\n",		tokens.KanaParts())
	fmt.Printf("Roman: %#v\n",		tokens.Roman())
	fmt.Printf("RomanParts: %#v\n",		tokens.RomanParts())
	fmt.Printf("GlossParts: %#v\n",		tokens.GlossParts())
}

Output

Tokenized: "私 は 日本語 を 勉強しています . "
TokenizedParts: []string{"私", "は", "日本語", "を", "勉強しています", ". "}
Kana: "わたし は にほんご を べんきょう しています . "
KanaParts: []string{"わたし", "は", "にほんご", "を", "べんきょう しています", ". "}
Roman: "watashi wa nihongo wo benkyō shiteimasu . "
RomanParts: []string{"watashi", "wa", "nihongo", "wo", "benkyō shiteimasu", ". "}
GlossParts: []string{"私(I; me)",
	"は (indicates sentence topic; indicates contrast with another option (stated or unstated); adds emphasis)",
	"日本語 (Japanese (language))",
	"を (indicates direct object of action; indicates subject of causative expression; indicates an area traversed; indicates time (period) over which action takes place; indicates point of departure or separation of action; indicates object of desire, like, hate, etc.)",
	"勉強 (study; diligence; working hard; experience; lesson (for the future); discount; price reduction)",
	"して (to do; to carry out; to perform; to cause to become; to make (into); to turn (into); to serve as; to act as; to work as; to wear (clothes, a facial expression, etc.); to judge as being; to view as being; to think of as; to treat as; to use as; to decide on; to choose; to be sensed (of a smell, noise, etc.); to be (in a state, condition, etc.); to be worth; to cost; to pass (of time); to elapse; to place, or raise, person A to a post or status B; to transform A to B; to make A into B; to exchange A for B; to make use of A for B; to view A as B; to handle A as if it were B; to feel A about B; verbalizing suffix (applies to nouns noted in this dictionary with the part of speech \"vs\"); creates a humble verb (after a noun prefixed with \"o\" or \"go\"); to be just about to; to be just starting to; to try to; to attempt to)",
	"います (to be (of animate objects); to exist; to stay; to be ...-ing; to have been ...-ing)",
	". "}

Tip

if you have 'exec: "ichiran-cli": executable file not found' errors, remove directory ./docker/pgdata (as recommended by README of ichiran repo) at location below and use docker.InitForce() to bypass cache and force rebuild from scratch.

Docker compose containers' location

  • Linux: ~/.config/ichiran
  • macOS: ~/Library/Application Support/ichiran
  • Windows: %LOCALAPPDATA%\ichiran

Requirements

Important

The Docker library in Go is not standalone - it requires a running Docker daemon: Docker Desktop (Windows/Mac) or Docker Engine (Linux) must be installed and running for this library to work.**

Windows

  1. Docker Desktop for Windows

    • Download and install from Docker Hub
    • Requires Windows 10/11 Pro, Enterprise, or Education (64-bit)
    • WSL 2 backend is recommended
    • Hardware requirements:
      • 64-bit processor with Second Level Address Translation (SLAT)
      • 4GB system RAM
      • BIOS-level hardware virtualization support must be enabled
  2. WSL 2 (Windows Subsystem for Linux)

    • Required for best performance
    • Install via PowerShell (as administrator):
      wsl --install
    • Restart your computer after installation
  3. System Requirements

    • Go 1.19 or later
    • Internet connection (for initial setup)

macOS

  1. Docker Desktop for Mac

    • Download and install from Docker Hub
    • Compatible with macOS 10.15 or newer
  2. System Requirements

    • Go 1.19 or later
    • Internet connection (for initial setup)

Linux

  1. Docker Engine

    • Install using your distribution's package manager
    • Docker Compose V2 (included with recent Docker Engine installations)
    # Ubuntu/Debian
    sudo apt-get update
    sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  2. System Requirements

    • Go 1.19 or later
    • Internet connection (for initial setup)

Post-Installation

  1. Verify Docker installation:

    docker --version
    docker compose version
  2. Start Docker service (if not started):

    # Windows/Mac: Start Docker Desktop
    # Linux:
    sudo systemctl start docker
  3. (Optional) Configure non-root access on Linux:

    sudo usermod -aG docker $USER
    # Log out and back in for changes to take effect

Alternatives

License

GPL3

About

go library bindings for docker-composed Ichiran–a morphological analyzer / romanizer for japanese

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages