# Clone the repository
git clone https://github.com/wronai/nlp2tree.git
cd nlp2tree
# Install dependencies
pip install -r requirements.txt
# For semantic search (optional but recommended)
pip install sentence-transformers scikit-learn
# Run all 30 use cases on current directory
python examples/code_analysis_demo.py .
# Analyze specific project
python examples/code_analysis_demo.py /path/to/your/project
# Find functions parsing JSON
nlp3 query "znajdĹş funkcjÄ™ parsujÄ…cÄ… JSON" /path/to/project
# Show all TODOs
nlp3 query "pokaĹĽ TODO" /path/to/project
# Find async functions
nlp3 query "gdzie jest async" /path/to/project
# Find security issues
nlp3 query "gdzie mamy eval" /path/to/project
from pathlib import Path
from nlp3.adapters.code_use_cases import CodeAnalysisUseCases
# Initialize analyzer
analyzer = CodeAnalysisUseCases(Path("/path/to/project"))
# Run specific analysis
todos = analyzer.find_todo_comments()
security_issues = analyzer.find_security_hotspots()
async_functions = analyzer.find_async_code()
print(f"Found {len(todos)} TODOs")
print(f"Found {len(security_issues)} security issues")
print(f"Found {len(async_functions)} async functions")
from nlp3.adapters.semantic_search import SemanticSearchEngine
# Initialize semantic engine
semantic_engine = SemanticSearchEngine()
semantic_engine.build_semantic_index(code_engine, project_path)
# Find functions by description
results = semantic_engine.find_functions_by_description("parse CSV data")
results = semantic_engine.find_functions_by_description("authenticate user")
# Find similar functions
similar = semantic_engine.find_similar_functions("parse_json")
from nlp3.adapters.code_intelligence import CodeIntelligenceEngine
# Initialize engine
engine = CodeIntelligenceEngine()
engine.build_index(project_path)
# Find unused functions
unused = engine.find_unused_functions()
# Get call graph
call_graph = engine.get_call_graph("main_function")
# Calculate metrics
metrics = engine.calculate_metrics(project_path)
# Table format (default)
nlp3 query "find functions" /path/to/project --format table
# Tree format
nlp3 query "find functions" /path/to/project --format tree
# JSON format
nlp3 query "find functions" /path/to/project --format json
# HTML report
nlp3 query "find functions" /path/to/project --format html
# Run all tests
pytest tests/test_code_analysis.py
# Run with coverage
pytest --cov=nlp3/adapters tests/test_code_analysis.py
# Run specific test
pytest tests/test_code_analysis.py::TestCodeAnalysisUseCases::test_find_todo_comments
from nlp3.adapters.code_use_cases import CodeAnalysisUseCases
analyzer = CodeAnalysisUseCases(Path("."))
todos = analyzer.find_todo_comments()
for file_path, line_num, todo_text in todos:
print(f"{file_path}:{line_num} - {todo_text}")
from nlp3.adapters.code_intelligence import CodeIntelligenceEngine
engine = CodeIntelligenceEngine()
engine.build_index(Path("."))
security_issues = engine.find_security_hotspots()
for issue in security_issues:
print(f"SECURITY: {issue.docstring}")
print(f"Location: {issue.name} at line {issue.line_start}")
from nlp3.adapters.semantic_search import SemanticSearchEngine
semantic_engine = SemanticSearchEngine()
semantic_engine.build_semantic_index(code_engine, Path("."))
# Find functions that handle authentication
results = semantic_engine.search_by_intent("authenticate", "user login password")
for function, score in results:
print(f"{function.name} (similarity: {score:.2f})")
# Find potential issues
nlp3 query "find security hotspots" /path/to/project
nlp3 query "show TODOs" /path/to/project
nlp3 query "find unused functions" /path/to/project
# Understand codebase structure
nlp3 query "find entry points" /path/to/project
nlp3 query "find main functions" /path/to/project
nlp3 query "show API endpoints" /path/to/project
# Find related code
nlp3 query "find functions calling database" /path/to/project
nlp3 query "find async functions" /path/to/project
nlp3 query "find logging code" /path/to/project
Happy Code Exploration! 🚀