Quick Start
This guide walks you through creating a simple dictionary, compiling it, and querying it with the CLI.
-
Create a new dictionary
Section titled “Create a new dictionary”Use the
odict newcommand to scaffold a blank XML file:Terminal window odict new animals -n "Animal Dictionary"This creates
animals.xml:<?xml version="1.0" encoding="UTF-8"?><dictionary name="Animal Dictionary"></dictionary> -
Add entries
Section titled “Add entries”Open
animals.xmland add some entries:<?xml version="1.0" encoding="UTF-8"?><dictionary name="Animal Dictionary"><entry term="cat"><ety description="From Latin cattus"><sense pos="n"><definition value="A small domesticated carnivorous mammal with soft fur"><example value="The cat sat on the mat." /><example value="She adopted two cats from the shelter." /></definition><definition value="(informal) A person, especially a man"><example value="He's a cool cat." /></definition></sense></ety></entry><entry term="dog"><ety description="From Old English docga"><sense pos="n"><definition value="A domesticated carnivorous mammal kept as a pet or for work"><example value="The dog fetched the ball." /></definition></sense><sense pos="v"><definition value="To follow someone closely and persistently"><example value="Reporters dogged the politician." /></definition></sense></ety></entry><entry term="kitty" see="cat" /></dictionary>What’s happening here:
<dictionary>is the top-level element. It can include a human-readablename.<entry>defines one headword. Thetermattribute is the lookup key.<ety>groups senses by etymology or origin. A word can have more than one.<sense>groups definitions by part of speech. Here,nmeans noun andvmeans verb.<definition>stores one meaning for the sense.<example>shows the definition in context.seecreates a cross-reference. When you look up “kitty”, ODict can follow it to “cat”.
-
Compile the dictionary
Section titled “Compile the dictionary”Terminal window odict compile animals.xmlThis produces
animals.odict, a compact binary file. You can inspect it with:Terminal window odict info animals.odictAnimal Dictionary─────────────────File Version: 3File Size: 312 BEntries: 3 -
Look up entries
Section titled “Look up entries”Terminal window odict lookup animals.odict catOutput:
cat (From Latin cattus)noun1. A small domesticated carnivorous mammal with soft fur• "The cat sat on the mat."• "She adopted two cats from the shelter."2. (informal) A person, especially a man• "He's a cool cat."Follow cross-references with
-F:Terminal window odict lookup animals.odict kitty -FReturn structured JSON with
-f json:Terminal window odict lookup animals.odict cat -f json -
Search definitions
Section titled “Search definitions”To search across all definitions, first create an index:
Terminal window odict index animals.odictThen search:
Terminal window odict search animals.odict "domesticated mammal"This returns entries whose definitions match the query. You can also pass
--indextoodict searchto create the index on the fly. -
Serve over HTTP
Section titled “Serve over HTTP”Start a local server to query dictionaries via REST:
Terminal window odict serve animals.odict -p 8080Then query from any HTTP client:
Terminal window curl "http://localhost:8080/animals/lookup?q=cat,dog"curl "http://localhost:8080/animals/search?q=domesticated"curl "http://localhost:8080/animals/split?q=catdog&min_length=3"curl "http://localhost:8080/animals/tokenize?text=the+cat+and+the+dog"
What’s next?
Section titled “What’s next?”- XML Schema Reference — learn the full XML format including pronunciations, notes, and groups
- CLI Overview — learn when to use each command
- Serving Dictionaries — use ODict over HTTP
- Language bindings: Python, JavaScript, Rust