EmmaMustain

Thu May 01 2025

Query-JDM

Query-JDM

Query-JDM is a web interface and query engine for the JeuxDeMots lexical-semantic network, enabling expressive queries with variables, logical operators, and semantic relations through its REST API.

Overview of the project

Query-JDM is a web application and query engine developed as part of a Master 1 Computer Science TER (Travail d’Étude et de Recherche) at Université de Montpellier (2024–2025). The project provides an expressive query language to interact with the JeuxDeMots (JDM) lexical-semantic network through its REST API.

The goal is to allow users to formulate complex semantic queries (with variables, logical operators, negation, regex, and weight filters) and extract meaningful relations from the JDM graph, which contains 20M+ nodes and 850M+ relations.

Technical Implementation

Query-JDM is built with Next.js and TypeScript, combining a modern web interface with a powerful backend query engine. The system is structured in layers:

  • Frontend (Next.js + React): user interface for writing queries and visualizing results.
  • Query Engine: parses user queries into an AST (Abstract Syntax Tree), evaluates them, and translates them into optimized API calls.
  • Backend API: communicates with the JeuxDeMots REST API, applies caching, and filters results.
  • Optimizations: caching, query reordering, and local evaluation to reduce API calls.

Sign Up

Key Components

  1. Custom Query Language

    • Variables ($x, $y)
    • Relations (r_isa, r_can_eat, …)
    • Logical operators (AND, OR, !)
    • Regex filters (/^ba/)
    • Weight filters (>30, <50)

Example:

$x r_isa animal AND $y r_isa animal AND $x r_can_eat $y

→ returns predator-prey pairs like (lion,gazelle).(lion, gazelle).

  1. Lexer & Parser (AST-based) Queries are parsed character by character into tokens, then structured into an AST for evaluation. This approach allows:
  • Complex token recognition ($x, r_isa, AND)

  • Precise error handling with positions

  • Support for future syntax (parentheses, weights, etc.)

    Example AST:


  1. Optimized Query Evaluation
  • API calls are minimized by fetching once and comparing locally.
  • Example: instead of 810,000 calls for $x r_can_eat $y, the system reduces it to ~900 calls.
  • Results are cached for 5 minutes.
  1. Error Handling & Constraints
  • Invalid queries return clear error messages.
  • Auto-prevention of invalid results (e.g., $x != $y to avoid "cat eats cat").
  1. User Interface
  • Text input for queries
  • AST visualization
  • Tabular results (single values, pairs, or triplets)
  • Options for weight filters, regex, and result limits

User Interface and Experience

The UI is designed to be simple and educational:

  • Users type queries in a text box.
  • The system shows the AST (so users understand how the query is parsed).
  • Results are displayed in tables (e.g., predator-prey pairs, food chains).

Built with React + Tailwind CSS, the interface is responsive and intuitive, making semantic exploration accessible even to non-experts.


Internationalization and Responsiveness

  • Fully responsive (desktop & mobile).
  • Designed for French lexical data (JeuxDeMots), but the query engine is language-agnostic and could be extended to other semantic networks (WordNet, ConceptNet).


Challenges and Solutions

  1. Parsing Queries
  • Challenge: splitting by spaces was too naive.
  • Solution: implemented lexical analysis (lexer) to parse character-by-character.
  1. Performance
  • Challenge: millions of nodes → too many API calls.
  • Solution: caching, query reordering, and local evaluation.
  1. Extensibility
  • Challenge: adding new syntax (e.g., <, > for weights).
  • Solution: modular AST-based design → adding new tokens is straightforward.

Future Improvements

  • Graph Visualization: interactive graph view of results.
  • Export Options: CSV/JSON export for research.
  • Advanced Query Language: quantifiers, temporal constraints, distance in graph.
  • Integration with AI: automatic query suggestions, semantic reasoning.
  • Cross-Network Support: extend to WordNet, ConceptNet, or domain-specific ontologies.

Conclusion

Query-JDM demonstrates how a custom query language + AST-based engine can make a massive semantic network like JeuxDeMots accessible, expressive, and efficient.

Developed as part of a Master 1 Computer Science TER (2024–2025), the project combines linguistics, NLP, and web development into a practical tool for semantic exploration.

By leveraging Next.js, TypeScript, and a custom query engine, Query-JDM bridges the gap between raw lexical data and human-friendly semantic queries, paving the way for future research and applications in linguistics, AI, and knowledge graphs.