LRriver opened a new pull request, #303:
URL: https://github.com/apache/incubator-hugegraph-ai/pull/303

   ๐Ÿ“‹ **Project Overview**
   This PR adds a complete Text-to-Gremlin corpus generation system based on a 
recursive backtracking recipe-guided generation approach, capable of 
automatically generating large-scale and diverse training data from Gremlin 
query templates.
   
   ๐Ÿ—๏ธ **Project Structure**
   ```
   AST_Text2Gremlin/                   # Project root directory
   โ”œโ”€โ”€ base/                           # Core system directory
   โ”‚   โ”œโ”€โ”€ generator.py                # Main generator entry point
   โ”‚   โ”œโ”€โ”€ GremlinTransVisitor.py      # ANTLR syntax tree visitor
   โ”‚   โ”œโ”€โ”€ TraversalGenerator.py       # Recursive backtracking generator
   โ”‚   โ”œโ”€โ”€ Schema.py                   # Graph database Schema management
   โ”‚   โ”œโ”€โ”€ GremlinBase.py              # Base component library
   โ”‚   โ”œโ”€โ”€ Config.py                   # Configuration management
   โ”‚   โ”œโ”€โ”€ cypher2gremlin_dataset.csv  # 3514 real query dataset
   โ”‚   โ””โ”€โ”€ test/                       # Test suite
   โ”œโ”€โ”€ config.json                     # Global configuration file
   โ”œโ”€โ”€ db_data/                        # Schema and data files
   โ””โ”€โ”€ README.md                       # Detailed technical documentation
   ```
   
   ๐ŸŽฏ **Core Features**
   1. **Recipe-Guided Generation**
      - Parse Gremlin queries into Recipes using ANTLR
      - Perform intelligent parameter generalization based on Schema
      - Generate large numbers of valid variants through recursive backtracking
   
   2. **Large-Scale Data Processing**
      - Support batch loading of query templates from CSV files
      - Process 3514 real cypher2gremlin dataset entries
      - Global deduplication to ensure corpus quality
   
   3. **Complete Error Handling**
      - Support complex query types (g.call(), .with(), etc.)
      - Individual failures don't affect overall processing
      - Detailed statistics and error reporting
   
   4. **Intelligent Constraint Mechanism**
      - Schema connectivity validation
      - Syntax validity checking
      - Combinatorial explosion control (320k โ†’ 7k valid combinations)
   
   ๐Ÿ“Š **System Capabilities**
   - Query type support: V/E traversals, graph algorithm calls, complex 
filtering, etc.
   - Generation scale: Single complex template can generate 6000+ valid variants
   - Processing efficiency: Batch processing of 3514 templates with robust 
error handling
   - Output quality: JSON format with query-description pairs and detailed 
metadata
   
   ๐Ÿงช **Technical Features**
   - Recursive backtracking algorithm: Systematically explore parameter 
combination space
   - Recipe abstraction: Structure queries into generalizable Recipes
   - Constraint optimization: 97%+ invalid combinations intelligently filtered
   - Modular design: Core components can be used and tested independently
   
   ๐Ÿ“ˆ **Application Value**
   - Text-to-Gremlin training: Provide large-scale training data for NLP models
   - Query diversity: Generate rich query variants from limited templates
   - Data quality: Ensure syntactic correctness and semantic reasonableness of 
generated queries
   - Extensibility: Support extension of new schemas and query types
   
   ๐Ÿ”ง **Usage**
   ```python
   # Basic usage
   from generator import generate_corpus_from_templates
   
   templates = ["g.V().hasLabel('person')", "g.V().out('knows')"]
   result = generate_corpus_from_templates(templates)
   print(f"Generated {result['total_unique_queries']} unique queries")
   ```
   
   ๐Ÿ“‹ **Documentation**
   - README.md: Quick start guide
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to