SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Downloaden Sie, um offline zu lesen
Presented by Grant Paton-Simpson
Word Puzzles with
Neo4j and Py2neo
Overview
●
Brief look at graph databases & Neo4j
●
Introduction to word transformation game
●
Getting suitable words
●
Adding words and relationships into Neo4j
●
Querying graph data to generate puzzles
Graph Databases – a NoSQL option
http://neo4j.com/books/graph-databases/
NoSQL – when is it a good fit?
●
SQL has its origins in the 1970s
and may not be fresh and shiny
any more but ...
●
… we shouldn't choose NoSQL
for reasons of fashion.
●
Venerable SQL often a better
choice for standard hierarchies
e.g. countries that have cities
that have suburbs etc
https://twitter.com/edd/status/400190499585544192
Graph Databases
●
Graph databases much, much better for related data with:
– lots of different links between same nodes
– different numbers of links between nodes
e.g. 3 hops to one peer and 7 hops to another
– lots of peer-to-peer links
Substantial Benefits
●
Massive performance benefits (going exponential as number
of links grows)
●
Structural harmony
– between structure of data and structure of data storage
(what you draw on the whiteboard might look very similar
to how you data is actually structured)
– between questions of data and query language used to
answer them
Word transformations
●
Start with one word and get to
the other by single-letter
tranformations word-by-word
●
E.g. starting with “stores” get to
“slaked”
– BTW there are 96 alternative
ways 5 moves or less
stores
stored
stared
staked
slaked
Puzzle taster
Get from 'sloven' to 'closed' in
no more than 5 steps
(there are 10 unique solutions)
sloven
?
closed
Getting a simple word list
●
How hard could it be?
●
Lesson #1 – scrabble lists and similar are useless – only want lists
with standard words otherwise puzzles too hard
●
Lesson #2 – have to decide about taboo/profane words
●
Lesson #3 – the number of words affects the number of
ONE_LETTER_DIFF relationships a lot
●
Lesson #4 – clever optimisation not needed if restricting self to
ordinary words
SCOWL (Spell Checker Oriented Word Lists) http://wordlist.aspell.net/
Filtering words
●
Needed to turn é to e
●
Needed to eliminate possessives e.g. cat's (as used in the phrase “the
cat's whiskers”)
●
Needed to leave out capitalised words
For each word, identifying words different
by one letter only
Disclaimer: the code worked but probably some super-smart optimisations
would be possible involving n-dimensional space or something
Adding data to Neo4j
●
Create nodes and relationships
●
Lots of room for optimisations
●
Only need to build database once so 15 minutes is not worth
reducing
●
My Neo4j and Py2neo is beginner level but I was able to solve my
problem
Py2neo and Cypher
Cypher Syntax as ASCII Art (Really!)
Word Word
ONE_OFF
(Word) -[ONE_OFF]->(Word)
Cypher Syntax as ASCII Art (Really!)
Word Word
ONE_OFF
(Word) -[ONE_OFF]->(Word)
How cool is this?
Example Output
Matching chart
Live Demo – Suggestions for Start Word
“sloven” to “closed” solution(s)
Resources
●
Neo4j
– http://neo4j.com/books/graph-databases/
– http://neo4j.com/graphacademy/
– http://graphgist.neo4j.com/#!/gists
– https://www.youtube.com/channel/UCvze3hU6OZBkB1vkhH2lH9Q
●
Py2neo
– http://py2neo.org/2.0/
●
SCOWL
– http://wordlist.aspell.net/
About Catalyst

Weitere ähnliche Inhalte

Ähnlich wie Word Puzzles with Neo4j and Py2neo

Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
Muhammad Jahanzaib
 
Running Neo4j in Production: Tips, Tricks and Optimizations
Running Neo4j in Production:  Tips, Tricks and OptimizationsRunning Neo4j in Production:  Tips, Tricks and Optimizations
Running Neo4j in Production: Tips, Tricks and Optimizations
Nick Manning
 

Ähnlich wie Word Puzzles with Neo4j and Py2neo (20)

Oracle's Take On NoSQL
Oracle's Take On NoSQLOracle's Take On NoSQL
Oracle's Take On NoSQL
 
Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013Introduction to SQL Alchemy - SyPy June 2013
Introduction to SQL Alchemy - SyPy June 2013
 
Getting started with Graph Databases & Neo4j
Getting started with Graph Databases & Neo4jGetting started with Graph Databases & Neo4j
Getting started with Graph Databases & Neo4j
 
Do Languages Matter?
Do Languages Matter?Do Languages Matter?
Do Languages Matter?
 
Neo4j graph database
Neo4j graph databaseNeo4j graph database
Neo4j graph database
 
Week 2 tyoes of databases and ERD 2020
Week  2 tyoes of databases and ERD  2020Week  2 tyoes of databases and ERD  2020
Week 2 tyoes of databases and ERD 2020
 
Research writing tips to prevent journal rejection: 5 Ground truths for clear...
Research writing tips to prevent journal rejection: 5 Ground truths for clear...Research writing tips to prevent journal rejection: 5 Ground truths for clear...
Research writing tips to prevent journal rejection: 5 Ground truths for clear...
 
Software Craftmanship - Cours Polytech
Software Craftmanship - Cours PolytechSoftware Craftmanship - Cours Polytech
Software Craftmanship - Cours Polytech
 
[CocoaHeads Tricity] Maciej Burda - Working as an iOS developer Interview Cas...
[CocoaHeads Tricity] Maciej Burda - Working as an iOS developer Interview Cas...[CocoaHeads Tricity] Maciej Burda - Working as an iOS developer Interview Cas...
[CocoaHeads Tricity] Maciej Burda - Working as an iOS developer Interview Cas...
 
Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
 
ACL 2018 Recap
ACL 2018 RecapACL 2018 Recap
ACL 2018 Recap
 
Running Neo4j in Production: Tips, Tricks and Optimizations
Running Neo4j in Production:  Tips, Tricks and OptimizationsRunning Neo4j in Production:  Tips, Tricks and Optimizations
Running Neo4j in Production: Tips, Tricks and Optimizations
 
Running Neo4j in Production: Tips, Tricks and Optimizations
Running Neo4j in Production:  Tips, Tricks and OptimizationsRunning Neo4j in Production:  Tips, Tricks and Optimizations
Running Neo4j in Production: Tips, Tricks and Optimizations
 
Ontology Access Kit_ Workshop Intro Slides.pptx
Ontology Access Kit_ Workshop Intro Slides.pptxOntology Access Kit_ Workshop Intro Slides.pptx
Ontology Access Kit_ Workshop Intro Slides.pptx
 
introtonlp-190218095523 (1).pdf
introtonlp-190218095523 (1).pdfintrotonlp-190218095523 (1).pdf
introtonlp-190218095523 (1).pdf
 
Intro to nlp
Intro to nlpIntro to nlp
Intro to nlp
 
Neo4jrb
Neo4jrbNeo4jrb
Neo4jrb
 
Developing Korean Chatbot 101
Developing Korean Chatbot 101Developing Korean Chatbot 101
Developing Korean Chatbot 101
 
AINL 2016: Nikolenko
AINL 2016: NikolenkoAINL 2016: Nikolenko
AINL 2016: Nikolenko
 
What it's like to do a Master's thesis with me (Ted Pedersen)
What it's like to do a Master's thesis with me (Ted Pedersen)What it's like to do a Master's thesis with me (Ted Pedersen)
What it's like to do a Master's thesis with me (Ted Pedersen)
 

Kürzlich hochgeladen

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Kürzlich hochgeladen (20)

Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 

Word Puzzles with Neo4j and Py2neo

  • 1. Presented by Grant Paton-Simpson Word Puzzles with Neo4j and Py2neo
  • 2. Overview ● Brief look at graph databases & Neo4j ● Introduction to word transformation game ● Getting suitable words ● Adding words and relationships into Neo4j ● Querying graph data to generate puzzles
  • 3. Graph Databases – a NoSQL option http://neo4j.com/books/graph-databases/
  • 4. NoSQL – when is it a good fit? ● SQL has its origins in the 1970s and may not be fresh and shiny any more but ... ● … we shouldn't choose NoSQL for reasons of fashion. ● Venerable SQL often a better choice for standard hierarchies e.g. countries that have cities that have suburbs etc
  • 6. Graph Databases ● Graph databases much, much better for related data with: – lots of different links between same nodes – different numbers of links between nodes e.g. 3 hops to one peer and 7 hops to another – lots of peer-to-peer links
  • 7. Substantial Benefits ● Massive performance benefits (going exponential as number of links grows) ● Structural harmony – between structure of data and structure of data storage (what you draw on the whiteboard might look very similar to how you data is actually structured) – between questions of data and query language used to answer them
  • 8. Word transformations ● Start with one word and get to the other by single-letter tranformations word-by-word ● E.g. starting with “stores” get to “slaked” – BTW there are 96 alternative ways 5 moves or less stores stored stared staked slaked
  • 9. Puzzle taster Get from 'sloven' to 'closed' in no more than 5 steps (there are 10 unique solutions) sloven ? closed
  • 10. Getting a simple word list ● How hard could it be? ● Lesson #1 – scrabble lists and similar are useless – only want lists with standard words otherwise puzzles too hard ● Lesson #2 – have to decide about taboo/profane words ● Lesson #3 – the number of words affects the number of ONE_LETTER_DIFF relationships a lot ● Lesson #4 – clever optimisation not needed if restricting self to ordinary words SCOWL (Spell Checker Oriented Word Lists) http://wordlist.aspell.net/
  • 11. Filtering words ● Needed to turn é to e ● Needed to eliminate possessives e.g. cat's (as used in the phrase “the cat's whiskers”) ● Needed to leave out capitalised words
  • 12. For each word, identifying words different by one letter only Disclaimer: the code worked but probably some super-smart optimisations would be possible involving n-dimensional space or something
  • 13. Adding data to Neo4j ● Create nodes and relationships ● Lots of room for optimisations ● Only need to build database once so 15 minutes is not worth reducing ● My Neo4j and Py2neo is beginner level but I was able to solve my problem
  • 15. Cypher Syntax as ASCII Art (Really!) Word Word ONE_OFF (Word) -[ONE_OFF]->(Word)
  • 16. Cypher Syntax as ASCII Art (Really!) Word Word ONE_OFF (Word) -[ONE_OFF]->(Word) How cool is this?
  • 19. Live Demo – Suggestions for Start Word
  • 21. Resources ● Neo4j – http://neo4j.com/books/graph-databases/ – http://neo4j.com/graphacademy/ – http://graphgist.neo4j.com/#!/gists – https://www.youtube.com/channel/UCvze3hU6OZBkB1vkhH2lH9Q ● Py2neo – http://py2neo.org/2.0/ ● SCOWL – http://wordlist.aspell.net/