Semantic search for Finnegans Wake, the most incomprehensible book that people still care about.
If you're familiar with both Finnegans Wake and semantic search, you'll know that this is a horrible idea. Most words in Finnegans Wake are not pure English; it's full of portmanteaus, foreign borrowings from a hundred languages, and words that are just purely made up for their sound. Semantic search requires breaking text down into known tokens that a language model has been trained on. Finnegans Wake is full of words that likely occur inside its pages only and no where else. It some ways this is a test more of the flexibility of the semantic search model itself.
Still, in a very Wakian way it can take you from many general search terms to passages of the Wake with dreamy connections.
- Node.js: >= 20.9.0 (required for Next.js 16)
- Package Manager: pnpm (recommended)
-
Install dependencies:
pnpm install
-
Configure environment variables: Copy
.env.exampleto.env.localand fill in your values:cp .env.example .env.local
Required variables:
OPENAI_API_KEY- Your OpenAI API keyCHROMA_COLLECTION- Name of your Chroma collection (default:fwtext)CHROMA_HOST- ChromaDB host (default:localhost)CHROMA_PORT- ChromaDB port (default:8000)CHROMA_SSL- Use SSL for ChromaDB (default:false)
-
Start Chroma & Index the text:
pnpm chroma pnpm ingest
-
Run the development server:
pnpm dev
Open http://localhost:3000 in your browser.
├── src/
│ ├── app/
│ │ ├── api/ # Next.js API routes
│ │ │ ├── fw/ # Finnegans Wake search endpoints
│ │ │ └── health/ # Health check endpoint
│ │ ├── layout.tsx # Root layout
│ │ ├── page.tsx # Home page
│ │ └── globals.css # Global styles
│ ├── components/
│ │ ├── ui/ # Reusable UI components
│ │ └── FinnegansBed.tsx # Main search interface
│ └── lib/
│ └── utils.ts # Utility functions
├── data/
│ └── fw/ # Finnegans Wake text data files
└── public/ # Static files
GET /api/query?q=<query>- Search Finnegans WakeGET /api/text/:book/:chapter- Get chapter text
# Build for production
pnpm build
# Start chromadb
pnpm chroma
# Start production server
pnpm start