This project is a miniature information-retrieval system featuring:
-
Rails 6.1
-
PostgreSQL
-
Vite Ruby (JS bundler)
-
Bootstrap 5
-
Chart.js
-
Ability to:
- Import
.trecfiles - Auto-compute style vectors (TTR, sentence length, pronoun ratio, readability)
- Query documents via different scoring approaches
- Visualize vectors in the browser
- Import
Ensure the following are installed:
- Ruby 3.3.x
- Rails 6.1
- PostgreSQL 13+
- Node.js / Bun
- Yarn or npm
- Vite Ruby (installed via Gemfile)
Clone the project:
git clone https://github.com/your-org/iis_project.git
cd iis_projectInstall Ruby dependencies:
bundle installInstall JavaScript dependencies (using Bun or Yarn):
bun install
# or:
yarn installrails db:create
rails db:migratebin/vite devIf needed, restart the Rails server afterward.
The frontend entrypoint is:
app/frontend/entrypoints/application.js
Import any TREC XML file containing:
<DOC>
<recordId>DOC001</recordId>
<text>Full document text…</text>
<style_vec>1.0,4.3,0.05,60.2</style_vec> <!-- optional -->
</DOC>Run:
rake trec:import FILE=path/to/file.trecThe task will:
- Parse the XML
- Compute style vectors if missing (
StyleFeatureService) - Store everything in PostgreSQL
- Reindex Document model (Searchkick-style or custom)
Style vectors use:
- TTR (type-token ratio)
- Avg sentence length
- Pronoun ratio
- Flesch readability score
Implemented in:
app/services/style_feature_service.rb
GET /search?q=keyword
GET /search_style?q=your text
GET /search_hybrid?q=your text
| Path | Purpose |
|---|---|
/home |
Document list |
/search |
Lexical search |
/search_style |
Vector-based search |
/search_hybrid |
Combined score |
/vectors |
Vector visualization UI |
Route definitions:
get "home" => "documents#index", as: :documents_home
get "vectors" => "vectors#index"
get "search" => "documents#search"
get "search_style" => "documents#search_style"
get "search_hybrid" => "documents#search_hybrid"Accessible at:
/vectors
Displays:
- Document ID
- Title
- Body (optional)
- Extracted style vector
- Mini-charts using Chart.js inside Bootstrap Accordions
In one terminal:
bin/vite devIn another:
rails sThen visit:
http://localhost:3000/home
app/models/document.rb # Model storing trec_id, title, body, style_vec
app/services/style_feature_service.rb
app/controllers/documents_controller.rb
app/controllers/vectors_controller.rb
lib/tasks/trec_import.rake
app/frontend/entrypoints/application.js
app/views/vectors/index.html.haml # Visualization UI
This project provides:
✔ Import + processing of TREC documents ✔ Style-feature vector extraction ✔ Multiple search strategies ✔ Beautiful Vite-powered frontend ✔ Chart.js vector visualization ✔ Clean Rails 6.1 backend