Knowledge Graphs
Transform crawled web data into structured knowledge graphs. Extract entities, discover relationships, and build queryable graph databases for advanced insights and analysis.
Entity Extraction
Automatic detection of people, places, organizations, and concepts
Relationship Mapping
Discover connections between entities across documents
Graph Database
Export to Neo4j, ArangoDB, or custom graph formats
Core Concepts
What is a Knowledge Graph?
A knowledge graph is a structured representation of information where:
- Nodes (Entities): Represent distinct objects, concepts, or data points
- Edges (Relationships): Define connections and associations between entities
- Properties: Attributes that describe entities and relationships
Graph Structure
JSON001{002 "nodes": [003 {004 "id": "person_1",005 "type": "Person",006 "properties": {007 "name": "John Doe",008 "title": "CEO",009 "email": "[email protected]"010 }011 },012 {013 "id": "company_1",014 "type": "Company",015 "properties": {016 "name": "Example Corp",017 "industry": "Technology",018 "founded": "2010"019 }020 }021 ],022 "edges": [023 {024 "source": "person_1",025 "target": "company_1",026 "type": "WORKS_FOR",027 "properties": {028 "since": "2015",029 "role": "Chief Executive Officer"030 }031 }032 ]033}
Entity Extraction
Supported Entity Types
Named Entities
- People (names, titles)
- Organizations (companies, institutions)
- Locations (cities, countries, addresses)
- Dates and times
- Monetary values
- Products and services
Custom Entities
- Email addresses
- Phone numbers
- URLs and domains
- Social media handles
- Technical terms
- Industry-specific entities
Extraction Configuration
TOML001[knowledge_graph.extraction]002# Entity extraction settings003extract_entities = true004entity_types = ["person", "organization", "location", "product"]005006# Confidence threshold (0-1)007min_confidence = 0.7008009# Custom patterns010[knowledge_graph.extraction.patterns]011email = "\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b"012phone = "\+?[1-9]\d{1,14}"013social_handle = "@[A-Za-z0-9_]+"014015# NER model settings016[knowledge_graph.extraction.ner]017model = "en_core_web_lg" # spaCy model018batch_size = 100019max_length = 10000
Relationship Discovery
Automatic Relationship Detection
Omnivore automatically discovers relationships based on:
- Co-occurrence: Entities appearing in the same context
- Syntactic patterns: Grammar-based relationship extraction
- Semantic analysis: Understanding meaning and context
- Link analysis: Hyperlink and reference relationships
Relationship Types
RUST001// Common relationship types002enum RelationType {003 // Organizational004 WorksFor,005 ManagesEmployeeOf,006 ParentCompany,007 Subsidiary,008009 // Personal010 Knows,011 RelatedTo,012 ContactOf,013014 // Locational015 LocatedIn,016 HeadquarteredIn,017 OperatesIn,018019 // Transactional020 Customer,021 Supplier,022 Partner,023 Competitor,024025 // Content026 Mentions,027 References,028 LinksTo,029 CitedBy,030}
Building Knowledge Graphs
Basic Graph Construction
BASH001# Build graph from crawled data002omnivore graph build crawl-results.json --output knowledge-graph.json003004# Specify entity types to extract005omnivore graph build crawl-results.json \006 --entities person,organization,location \007 --output knowledge-graph.json008009# Set confidence threshold010omnivore graph build crawl-results.json \011 --min-confidence 0.8 \012 --output knowledge-graph.json
Advanced Configuration
BASH001# Use custom extraction config002omnivore graph build crawl-results.json \003 --config graph-config.toml \004 --output knowledge-graph.json005006# Parallel processing007omnivore graph build crawl-results.json \008 --workers 10 \009 --batch-size 1000 \010 --output knowledge-graph.json011012# Include metadata013omnivore graph build crawl-results.json \014 --include-metadata \015 --include-timestamps \016 --output knowledge-graph.json
Programmatic API
RUST001use omnivore::{KnowledgeGraph, GraphBuilder, EntityExtractor};002003#[tokio::main]004async fn main() -> Result<(), Box<dyn std::error::Error>> {005 // Load crawled data006 let crawl_data = load_crawl_results("results.json")?;007008 // Configure entity extractor009 let extractor = EntityExtractor::builder()010 .add_entity_type(EntityType::Person)011 .add_entity_type(EntityType::Organization)012 .min_confidence(0.75)013 .build();014015 // Build knowledge graph016 let graph_builder = GraphBuilder::new(extractor);017 let knowledge_graph = graph_builder018 .process(crawl_data)019 .extract_entities()020 .discover_relationships()021 .build()022 .await?;023024 // Query the graph025 let ceo_nodes = knowledge_graph026 .query()027 .nodes()028 .filter_type(EntityType::Person)029 .filter_property("title", "CEO")030 .execute()?;031032 println!("Found {} CEOs", ceo_nodes.len());033034 // Export to different formats035 knowledge_graph.export_json("graph.json")?;036 knowledge_graph.export_graphml("graph.graphml")?;037 knowledge_graph.export_neo4j("bolt://localhost:7687")?;038039 Ok(())040}
Graph Storage & Export
Storage Backends
1. Neo4j Export
BASH001# Export to Neo4j database002omnivore graph export knowledge-graph.json \003 --format neo4j \004 --uri bolt://localhost:7687 \005 --username neo4j \006 --password password007008# Batch import for large graphs009omnivore graph export knowledge-graph.json \010 --format neo4j-import \011 --output-dir ./neo4j-import/
2. ArangoDB Export
BASH001# Export to ArangoDB002omnivore graph export knowledge-graph.json \003 --format arangodb \004 --url http://localhost:8529 \005 --database knowledge \006 --collection entities
3. GraphML Format
BASH001# Export to GraphML (compatible with most graph tools)002omnivore graph export knowledge-graph.json \003 --format graphml \004 --output knowledge-graph.graphml
4. JSON-LD Format
BASH001# Export as JSON-LD for semantic web002omnivore graph export knowledge-graph.json \003 --format jsonld \004 --context schema.org \005 --output knowledge-graph.jsonld
Querying Knowledge Graphs
Built-in Query Language
BASH001# Find all entities of a specific type002omnivore graph query knowledge-graph.json \003 --type Person \004 --limit 10005006# Search by property007omnivore graph query knowledge-graph.json \008 --property "title=CEO" \009 --type Person010011# Find relationships012omnivore graph query knowledge-graph.json \013 --relationship "WORKS_FOR" \014 --source-type Person \015 --target-type Company
Graph Traversal
BASH001# Find connected entities (1 hop)002omnivore graph traverse knowledge-graph.json \003 --start "person_123" \004 --depth 1005006# Find paths between entities007omnivore graph path knowledge-graph.json \008 --from "person_123" \009 --to "company_456" \010 --max-depth 5011012# Find clusters/communities013omnivore graph analyze knowledge-graph.json \014 --algorithm community-detection \015 --output communities.json
Analysis & Insights
Graph Metrics
BASH001# Calculate graph statistics002omnivore graph stats knowledge-graph.json003004# Output:005# Nodes: 10,543006# Edges: 45,231007# Average degree: 8.58008# Clustering coefficient: 0.234009# Connected components: 12
Centrality Analysis
BASH001# Find most important nodes002omnivore graph analyze knowledge-graph.json \003 --algorithm pagerank \004 --output pagerank-scores.json005006# Betweenness centrality007omnivore graph analyze knowledge-graph.json \008 --algorithm betweenness \009 --output betweenness-scores.json010011# Degree centrality012omnivore graph analyze knowledge-graph.json \013 --algorithm degree \014 --output degree-scores.json
Pattern Detection
BASH001# Find patterns and motifs002omnivore graph patterns knowledge-graph.json \003 --min-support 0.1 \004 --max-size 5 \005 --output patterns.json006007# Detect anomalies008omnivore graph anomalies knowledge-graph.json \009 --algorithm isolation-forest \010 --threshold 0.9 \011 --output anomalies.json
Visualization
Export for Visualization Tools
BASH001# Gephi format002omnivore graph export knowledge-graph.json \003 --format gexf \004 --output graph.gexf005006# Cytoscape format007omnivore graph export knowledge-graph.json \008 --format cyjs \009 --output graph.cyjs010011# D3.js format012omnivore graph export knowledge-graph.json \013 --format d3 \014 --output graph-d3.json
Built-in Visualization Server
BASH001# Start visualization server002omnivore graph serve knowledge-graph.json \003 --port 8080 \004 --host 0.0.0.0005006# With custom layout007omnivore graph serve knowledge-graph.json \008 --layout force-directed \009 --port 8080
Use Cases
Competitive Intelligence
Map competitor relationships, track personnel movements, and identify partnership networks
Market Analysis
Discover industry trends, identify key players, and analyze market relationships
Research & Discovery
Build knowledge bases, track citations, and discover hidden connections in research data
Performance Considerations
Scaling Large Graphs
- Streaming Processing: Process large datasets in chunks
- Distributed Computing: Use multiple workers for parallel processing
- Index Optimization: Create indexes on frequently queried properties
- Graph Partitioning: Split large graphs into manageable subgraphs
TOML001[knowledge_graph.performance]002# Streaming settings003stream_processing = true004chunk_size = 10000005max_memory = "4GB"006007# Parallel processing008workers = 8009batch_size = 1000010011# Caching012enable_cache = true013cache_size = "1GB"014015# Optimization016create_indexes = true017optimize_queries = true
Best Practices
Recommendations
- Start with high-confidence thresholds and adjust based on results
- Use domain-specific entity extractors for better accuracy
- Regularly validate and clean extracted entities
- Create indexes on frequently queried properties
- Use graph partitioning for very large datasets
- Export to specialized graph databases for production use
- Implement incremental updates rather than full rebuilds
Built with Rust. Developed by Pranav Karra