SlideShare uma empresa Scribd logo
1 de 54
FACEBOOK GRAPH SEARCH
How to create your own graph search using
Neo4j

jDays 2013
Ole-Martin Mørk
26/11/13
FACEBOOK GRAPH SEARCH
How to create your own graph search using
Neo4j

jDays 2013
Ole-Martin Mørk
26/11/13
ABOUT ME

Ole-Martin Mørk
Scientist

Bekk Consulting AS
Oslo, Norway

twitter: olemartin
AGENDA
INTRODUCTION TO SEARCH
INTRODUCTION TO NEO4J
INTRODUCTION TO PARSING

GRAPH SEARCH
GRAF

BETRAYS

KNOWS
KNOWS

LOVES
KNOWS
NODE

PERSON
ADRESSE

BODDE

navn: Thomas
alder: 24

gate: Aker
nummer: 15
RELASJON

BODDE
fra:
til:
RELASJONSDATABASER
“PATH EXISTS” RESPONSTID
-

One database
containing 1000
persons

-

Max 50 friends

-

Detect if two random
persons are
connected via friends

Antall
personer

Responstid

Relational db
Neo4j

1.000
1.000

2000ms
2ms

Neo4j

1.000.000

2ms
Neo4j
GRAF

C

B

A

I

D

H

E
F

G
CYPHER
GRAF

C

B

A

I

D

H

E
F

G
Cypher
CYPHER

( ) --> ( )
CYPHER

a

b

(a) --> (b)
CYPHER

a

b

c

(a)-->(b)<--(c)
CYPHER

a

kjenner

b

(a) –[:kjenner]-> (b)
CYPHER SØK

START person=node:person(name=“Ole-Martin”)
START school=node:school(“name:Norw*”)
START student=node:student(“year:(3 OR 4 OR 5)”)
FACEBOOK GRAPH SEARCH WITH CYPHER

START me=node:person(name = “Ole-Martin”),

location=node:location(location=“Göteborg”),
cuisine=node:cuisine(cuisine=“Sushi”)
MATCH (me)-[:IS_FRIEND_OF]->(friend)-[:LIKES]->(restaurant)
-[:LOCATED_IN]->(location),(restaurant)-[:SERVES]->(cuisine)
RETURN restaurant
Grammar
GRAMMAR

A “language” can be formally defined as “any system of
formalized symbols, signs, etc. used for communication”

A “grammar” can be defined as a “the set of structural rules
that governs sentences, words, etc. in a natural language”
TEXT PARSING

CFG PEG
GRAMMAR

Alfred, who loved fishing, bought fish at the store
downtown

(Alfred, (who loved (fishing)), (bought
(fish (at (the store (downtown))))))
additionExp
: multiplyExp
( '+' multiplyExp
| '-' multiplyExp
)*
;
multiplyExp
: atomExp
( '*' atomExp
| '/' atomExp
)*
;

atomExp
: Number
| '(' additionExp ')'
;
Number
: ('0'..'9')+
;

An additionExp is defined as a multiplyExp
+ or - a multiplyExp

A multiplyExp is defined as an atomExp *
or / an atomExp

An atomExp is defined as a number or a
parenthesized additionExp

Number is one or more character between
0-9
class CalculatorParser extends BaseParser<> {

Rule Expression() {
return Sequence(
Term(),
ZeroOrMore(AnyOf("+-"), Term())
);
}

An expression is a sequence of Term
followed by zero or more “+” or “-” followed
by a Term

Rule Term() {
return Sequence(
Factor(),
ZeroOrMore(AnyOf("*/"), Factor())
);
}

Term is a Factor followed by zero or more
sequences of “*” or “/” followed by a factor

Rule Factor() {
return FirstOf(
Number(),
Sequence('(', Expression(), ')')
);
}

Factor is a number or a parenthesized
expression

Rule Number() {
return OneOrMore(CharRange('0', '9'));

Number is a one or more characters
between 0-9
PEG VS CFG

PEGs firstof operator vs CFG’s | operator
PEG does not have a separate tokenizing step
CFG might come across as more powerful, but also more difficult to master
PEG does not allow ambiguity in the grammar
PARBOILED
PARBOILED
Parsing expression grammars parser
Lightweight
Easy to use
Implementation in Scala and Java
Rules are written in the programming language
class CalculatorParser extends BaseParser<> {

Rule Expression() {
return Sequence(
Term(),
ZeroOrMore(AnyOf("+-"), Term())
);
}

An expression is a sequence of Term
followed by zero or more “+” or “-” followed
by a Term

Rule Term() {
return Sequence(
Factor(),
ZeroOrMore(AnyOf("*/"), Factor())
);
}

Term is a Factor followed by zero or more
sequences of “*” or “/” followed by a factor

Rule Factor() {
return FirstOf(
Number(),
Sequence('(', Expression(), ')')
);
}

Factor is a number or a parenthesized
expression

Rule Number() {
return OneOrMore(CharRange('0', '9'));

Number is a one or more characters
between 0-9
I went for a walk downtown

Sequence( “I”, “went”, “for”, “a”, “walk”, “downtown”)
went
downtown
I
for a walk
wend
to the city
Sequence(
String(“I”),

FirstOf(“went”, “wend”),
Sequence(“for”, “a”, “walk”),

FirstOf(“downtown”, “to the city”));
went
downtown
today
I
for a walk
walked
to the city
Sequence(
…,

Optional(String(“today”)));
went
downtown
today
for a walk
today I
walked
to the city
Sequence(
Today(),

…,
Today());

Rule Today() { return Optional(String(“today”)); }
Rule AnyOf(java.lang.String characters)

Creates a new rule that matches any of
the characters in the given string.
Rule Ch(char c)

Explicitly creates a rule matching the
given character.
Rule CharRange(char cLow, char cHigh)

Creates a rule matching a range of
characters from cLow to cHigh (both
inclusively).
Rule FirstOf(java.lang.Object... rules)

Creates a new rule that successively
tries all of the given subrules and succeeds
when the first one of its subrules matches.
Rule IgnoreCase(char... characters)

Explicitly creates a rule matching the
given string in a case-independent fashion.
Rule NoneOf(char... characters)

Creates a new rule that matches all
characters except the ones in the given char
array and EOI.
Rule NTimes(int repetitions,
java.lang.Object rule)

Creates a new rule that repeatedly
matches a given sub rule a certain fixed
number of times.
went
downtown
today
for a walk
today I
walked
to the city
Sequence(
…,

FirstOf(
Sequence(push(“downtown”), “downtown”,

Sequence(push(“city”), “to the city”)));
BEKK
CV-db
A search for Java

yields 224 hits!
public Rule Expression() {
return Sequence(
Start(),
FirstOf(People(), Projects(), Technologies()),
OneOrMore(
FirstOf(
And(),
Sequence(
Know(),
Subjects()
),
Sequence(
WorkedAt(),
Customers()
),
Sequence(
Know(),
Customers()
),
Sequence(
Know(),
Technologies()
)
)
)
);
}
start
fag=node:fag(navn = "Neo4J"), fag1=node:fag(navn =
"Java"), prosjekt2=node:prosjekt(navn ="Modernisering")
match
CONSULTANTS -[:KAN]-> fag,
CONSULTANTS -[:KAN]-> fag1,
CONSULTANTS -[:KONSULTERTE]-> prosjekt
return
distinct CONSULTANTS
Demo
LEARN MORE

graphdatabases.com
neo4j.org
bit.ly/neo-cyp
parboiled.org
?
Thank
you!

@olemartin

Mais conteúdo relacionado

Mais procurados

Mais procurados (15)

Mining the social web ch1
Mining the social web ch1Mining the social web ch1
Mining the social web ch1
 
The Ring programming language version 1.3 book - Part 35 of 88
The Ring programming language version 1.3 book - Part 35 of 88The Ring programming language version 1.3 book - Part 35 of 88
The Ring programming language version 1.3 book - Part 35 of 88
 
CSS for developers
CSS for developersCSS for developers
CSS for developers
 
Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?Is Haskell an acceptable Perl?
Is Haskell an acceptable Perl?
 
The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212The Ring programming language version 1.10 book - Part 28 of 212
The Ring programming language version 1.10 book - Part 28 of 212
 
The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.3 book - Part 33 of 88The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.3 book - Part 33 of 88
 
Functional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures editionFunctional Pe(a)rls - the Purely Functional Datastructures edition
Functional Pe(a)rls - the Purely Functional Datastructures edition
 
Cryptography for Smalltalkers 2
Cryptography for Smalltalkers 2Cryptography for Smalltalkers 2
Cryptography for Smalltalkers 2
 
The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180The Ring programming language version 1.5.1 book - Part 21 of 180
The Ring programming language version 1.5.1 book - Part 21 of 180
 
Be Lazy & Scale
Be Lazy & ScaleBe Lazy & Scale
Be Lazy & Scale
 
Fs2 - Crash Course
Fs2 - Crash CourseFs2 - Crash Course
Fs2 - Crash Course
 
The Ring programming language version 1.7 book - Part 23 of 196
The Ring programming language version 1.7 book - Part 23 of 196The Ring programming language version 1.7 book - Part 23 of 196
The Ring programming language version 1.7 book - Part 23 of 196
 
Opa hackathon
Opa hackathonOpa hackathon
Opa hackathon
 
Frsa
FrsaFrsa
Frsa
 
The Ring programming language version 1.5.4 book - Part 45 of 185
The Ring programming language version 1.5.4 book - Part 45 of 185The Ring programming language version 1.5.4 book - Part 45 of 185
The Ring programming language version 1.5.4 book - Part 45 of 185
 

Destaque

Destaque (6)

Agile Development + Interaction design = True
Agile Development + Interaction design = TrueAgile Development + Interaction design = True
Agile Development + Interaction design = True
 
Digital Meets Physical: Collective Currents, et IoT-eksperiment
Digital Meets Physical: Collective Currents, et IoT-eksperimentDigital Meets Physical: Collective Currents, et IoT-eksperiment
Digital Meets Physical: Collective Currents, et IoT-eksperiment
 
Polyglot heaven
Polyglot heavenPolyglot heaven
Polyglot heaven
 
First-time users, longtime strategies: Why Parkinson’s Law is making you less...
First-time users, longtime strategies: Why Parkinson’s Law is making you less...First-time users, longtime strategies: Why Parkinson’s Law is making you less...
First-time users, longtime strategies: Why Parkinson’s Law is making you less...
 
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
DevOps and Continuous Delivery Reference Architectures (including Nexus and o...
 
Design Thinking and Lean UX
Design Thinking and Lean UXDesign Thinking and Lean UX
Design Thinking and Lean UX
 

Semelhante a Graph search with Neo4j

Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
adrianoalmeida7
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
Sway Wang
 

Semelhante a Graph search with Neo4j (20)

FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdfFUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
FUNDAMENTALS OF REGULAR EXPRESSION (RegEX).pdf
 
Why Scala is the better Java
Why Scala is the better JavaWhy Scala is the better Java
Why Scala is the better Java
 
Python postgre sql a wonderful wedding
Python postgre sql   a wonderful weddingPython postgre sql   a wonderful wedding
Python postgre sql a wonderful wedding
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
Cypher inside out: Como a linguagem de pesquisas em grafo do Neo4j foi constr...
 
The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212The Ring programming language version 1.10 book - Part 47 of 212
The Ring programming language version 1.10 book - Part 47 of 212
 
String slide
String slideString slide
String slide
 
A bit about Scala
A bit about ScalaA bit about Scala
A bit about Scala
 
Strings and Characters
Strings and CharactersStrings and Characters
Strings and Characters
 
Php & my sql
Php & my sqlPhp & my sql
Php & my sql
 
Java string handling
Java string handlingJava string handling
Java string handling
 
Scala in Places API
Scala in Places APIScala in Places API
Scala in Places API
 
Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"
 
Scala
ScalaScala
Scala
 
Intro toswift1
Intro toswift1Intro toswift1
Intro toswift1
 
An Introduction to Scala (2014)
An Introduction to Scala (2014)An Introduction to Scala (2014)
An Introduction to Scala (2014)
 
Arrays string handling java packages
Arrays string handling java packagesArrays string handling java packages
Arrays string handling java packages
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
How to write code you won't hate tomorrow
How to write code you won't hate tomorrowHow to write code you won't hate tomorrow
How to write code you won't hate tomorrow
 
This Is Not Your Father's Java
This Is Not Your Father's JavaThis Is Not Your Father's Java
This Is Not Your Father's Java
 

Mais de Ole-Martin Mørk (9)

Polyglot Persistence
Polyglot PersistencePolyglot Persistence
Polyglot Persistence
 
Patterns for key-value stores
Patterns for key-value storesPatterns for key-value stores
Patterns for key-value stores
 
Presentation of Redis
Presentation of RedisPresentation of Redis
Presentation of Redis
 
Evolusjonen av PaaS
Evolusjonen av PaaSEvolusjonen av PaaS
Evolusjonen av PaaS
 
Polyglot persistence
Polyglot persistencePolyglot persistence
Polyglot persistence
 
Du må vite hva som skjer i produksjon
Du må vite hva som skjer i produksjonDu må vite hva som skjer i produksjon
Du må vite hva som skjer i produksjon
 
Presentasjon om skyen
Presentasjon om skyenPresentasjon om skyen
Presentasjon om skyen
 
Hele butikken i skyen
Hele butikken i skyenHele butikken i skyen
Hele butikken i skyen
 
Collaborative Filtering in Map/Reduce
Collaborative Filtering in Map/ReduceCollaborative Filtering in Map/Reduce
Collaborative Filtering in Map/Reduce
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Graph search with Neo4j

  • 1. FACEBOOK GRAPH SEARCH How to create your own graph search using Neo4j jDays 2013 Ole-Martin Mørk 26/11/13
  • 2.
  • 3. FACEBOOK GRAPH SEARCH How to create your own graph search using Neo4j jDays 2013 Ole-Martin Mørk 26/11/13
  • 4. ABOUT ME Ole-Martin Mørk Scientist Bekk Consulting AS Oslo, Norway twitter: olemartin
  • 5. AGENDA INTRODUCTION TO SEARCH INTRODUCTION TO NEO4J INTRODUCTION TO PARSING GRAPH SEARCH
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 16.
  • 18. “PATH EXISTS” RESPONSTID - One database containing 1000 persons - Max 50 friends - Detect if two random persons are connected via friends Antall personer Responstid Relational db Neo4j 1.000 1.000 2000ms 2ms Neo4j 1.000.000 2ms
  • 19. Neo4j
  • 28. CYPHER SØK START person=node:person(name=“Ole-Martin”) START school=node:school(“name:Norw*”) START student=node:student(“year:(3 OR 4 OR 5)”)
  • 29. FACEBOOK GRAPH SEARCH WITH CYPHER START me=node:person(name = “Ole-Martin”), location=node:location(location=“Göteborg”), cuisine=node:cuisine(cuisine=“Sushi”) MATCH (me)-[:IS_FRIEND_OF]->(friend)-[:LIKES]->(restaurant) -[:LOCATED_IN]->(location),(restaurant)-[:SERVES]->(cuisine) RETURN restaurant
  • 31. GRAMMAR A “language” can be formally defined as “any system of formalized symbols, signs, etc. used for communication” A “grammar” can be defined as a “the set of structural rules that governs sentences, words, etc. in a natural language”
  • 33. GRAMMAR Alfred, who loved fishing, bought fish at the store downtown (Alfred, (who loved (fishing)), (bought (fish (at (the store (downtown))))))
  • 34. additionExp : multiplyExp ( '+' multiplyExp | '-' multiplyExp )* ; multiplyExp : atomExp ( '*' atomExp | '/' atomExp )* ; atomExp : Number | '(' additionExp ')' ; Number : ('0'..'9')+ ; An additionExp is defined as a multiplyExp + or - a multiplyExp A multiplyExp is defined as an atomExp * or / an atomExp An atomExp is defined as a number or a parenthesized additionExp Number is one or more character between 0-9
  • 35. class CalculatorParser extends BaseParser<> { Rule Expression() { return Sequence( Term(), ZeroOrMore(AnyOf("+-"), Term()) ); } An expression is a sequence of Term followed by zero or more “+” or “-” followed by a Term Rule Term() { return Sequence( Factor(), ZeroOrMore(AnyOf("*/"), Factor()) ); } Term is a Factor followed by zero or more sequences of “*” or “/” followed by a factor Rule Factor() { return FirstOf( Number(), Sequence('(', Expression(), ')') ); } Factor is a number or a parenthesized expression Rule Number() { return OneOrMore(CharRange('0', '9')); Number is a one or more characters between 0-9
  • 36. PEG VS CFG PEGs firstof operator vs CFG’s | operator PEG does not have a separate tokenizing step CFG might come across as more powerful, but also more difficult to master PEG does not allow ambiguity in the grammar
  • 38. PARBOILED Parsing expression grammars parser Lightweight Easy to use Implementation in Scala and Java Rules are written in the programming language
  • 39. class CalculatorParser extends BaseParser<> { Rule Expression() { return Sequence( Term(), ZeroOrMore(AnyOf("+-"), Term()) ); } An expression is a sequence of Term followed by zero or more “+” or “-” followed by a Term Rule Term() { return Sequence( Factor(), ZeroOrMore(AnyOf("*/"), Factor()) ); } Term is a Factor followed by zero or more sequences of “*” or “/” followed by a factor Rule Factor() { return FirstOf( Number(), Sequence('(', Expression(), ')') ); } Factor is a number or a parenthesized expression Rule Number() { return OneOrMore(CharRange('0', '9')); Number is a one or more characters between 0-9
  • 40. I went for a walk downtown Sequence( “I”, “went”, “for”, “a”, “walk”, “downtown”)
  • 41. went downtown I for a walk wend to the city Sequence( String(“I”), FirstOf(“went”, “wend”), Sequence(“for”, “a”, “walk”), FirstOf(“downtown”, “to the city”));
  • 42. went downtown today I for a walk walked to the city Sequence( …, Optional(String(“today”)));
  • 43. went downtown today for a walk today I walked to the city Sequence( Today(), …, Today()); Rule Today() { return Optional(String(“today”)); }
  • 44. Rule AnyOf(java.lang.String characters) Creates a new rule that matches any of the characters in the given string. Rule Ch(char c) Explicitly creates a rule matching the given character. Rule CharRange(char cLow, char cHigh) Creates a rule matching a range of characters from cLow to cHigh (both inclusively). Rule FirstOf(java.lang.Object... rules) Creates a new rule that successively tries all of the given subrules and succeeds when the first one of its subrules matches. Rule IgnoreCase(char... characters) Explicitly creates a rule matching the given string in a case-independent fashion. Rule NoneOf(char... characters) Creates a new rule that matches all characters except the ones in the given char array and EOI. Rule NTimes(int repetitions, java.lang.Object rule) Creates a new rule that repeatedly matches a given sub rule a certain fixed number of times.
  • 45. went downtown today for a walk today I walked to the city Sequence( …, FirstOf( Sequence(push(“downtown”), “downtown”, Sequence(push(“city”), “to the city”)));
  • 47. A search for Java yields 224 hits!
  • 48.
  • 49. public Rule Expression() { return Sequence( Start(), FirstOf(People(), Projects(), Technologies()), OneOrMore( FirstOf( And(), Sequence( Know(), Subjects() ), Sequence( WorkedAt(), Customers() ), Sequence( Know(), Customers() ), Sequence( Know(), Technologies() ) ) ) ); }
  • 50. start fag=node:fag(navn = "Neo4J"), fag1=node:fag(navn = "Java"), prosjekt2=node:prosjekt(navn ="Modernisering") match CONSULTANTS -[:KAN]-> fag, CONSULTANTS -[:KAN]-> fag1, CONSULTANTS -[:KONSULTERTE]-> prosjekt return distinct CONSULTANTS
  • 51. Demo
  • 53. ?

Notas do Editor

  1. Ole-Martin MørkScientist hos BEKK
  2. Jeger Scientist i Bekk hvorjegharjobbetmerellermindresiden 2000.Jeger @olemartinpå twitter, oghvisnoenhar et spørsmålellertilbakemelding under fordragetså ta detgjerne der.
  3. EvolusjonFormel 1Verdensarterogsøkogsøkemotorerså kun påenkeltdokumentermanuellkategorisering
  4. pagerankfragooglealle sider får en pagerankbasertpåinnholdetpåsidenogpagerankpåsidenesomlenker inn
  5. Googles Knowledge Graph, where you can follow relations between different knowledge. Search for Mona Lisa
  6. and you get dynamic information about that picture displayed in the sidebar
  7. Mark Zuckerbergmed facebook graph search vistefacebook at relasjonenevar like viktigsomdataeneomjeg liker fotografi, ogborioslokunneværtioslo, ellerværtfødtioslo, men jeg BOR iosloogdet her visersegåværeveldigkraftig
  8. Facebook Graph Search developed by Lars Rasmussen, the danish dude that created Google Wave.They use a Context Free Grammar, which is translated to a query they run against an index called Unicorn that has a graph-like architecture.
  9. You can also search for combined queries, like people from gothenburg that works as a barista in Oslo, lots of those around :-)
  10. Dettehaddeikkeværtmuliguten en graf-strukturibunnen.Ogdetteer en graf:En grafbestårenkeltforklartavnoderogrelasjoner.En relasjongårfra en node til en annen node. Skalrelasjonengåbeggeveier, må du ha to.Noderkan ha attrubutterogrelasjonerkan ha attributter
  11. Somnavnog alderosvHvis du har data somandrenoderkantenkesegårelateretil, såskiller du den ut via en relasjon
  12. Ogrelasjonenharogsåattributter
  13. If we go back to the monalisa example, some of the attributes presented are in fact attributes, others actually relationships
  14. Fordet vi såkanogsåløses med en relasjonsdatabase.MENStatiskeskjemaer, definereshvordandataeneserutførstTungtåjobbe med mange ogdyperelasjonerogikkeminstytelse
  15. Created in Sweden! :-) By Emil EifremNow have offices in sweden, malaysia with Rickard Øberg, uk with Jim Webber, united states etc. A fast growing company, making some really nice technology. And nobody is paying me a dime to say this, I just love their technology.17 minutter hit
  16. Vi gårtilbaketilgrafen
  17. Det her erogså en grafforsåvidt, dvs en veldiglitengraf.En node med en relasjontil en annen node.
  18. Hvis vi tar detuttrykketogsøkeretterdetidatabasensåfinner man det.Man vilforsåvidtfinneallestederhvor en node errelaterttil en annen
  19. I Matrix erhanikke et godtselskap for Neo, men i Neo4j såer de perlevenner
  20. Ogdetsomerfantastisker at detteer en gyldigi Neo4j
  21. Navngittenoder
  22. Flerenavngittenoder
  23. Relasjonerav en viss type
  24. So… Now we have the database and query language. Now we only need to define some grammar.
  25. A language, norsk,ellerskavlan-svenska, or english
  26. CFG - context free grammar, used byfacebook graph search and many many programming languages. Been used for defining programming languages since the 50sparsing expression grammar, the new kid on the block, defined in 2004
  27. May look a little like LISP
  28. Parboiled is written by a german named Mathias Doenitz. This man has managed to create a user friendly and powerful PEG-parser. Mathias has also created spray.io, a really powerful akka-based REST-module for Scala.Parboiled is the main reason why I went with PEG in my project. Parboiled is easy to understand, and has all the features necessery for
  29. 34 minutter hit
  30. whitespaces
  31. ValueStack
  32. ValueStack
  33. Inside your rulesyou might add values to the ValueStack.This is a great way for your rules and actions to communicate, or you can use this to return values from the parsing process.
  34. Vi brukervår cv-databasenaktivt. Når en kundeetterspør en konsulentsomkan neo4j såsøkerselgerengjennomdatabasen. Hviskundenharkravomrelasjoner, andrefagfeltetcsåblirdetkomplekst med fritekst-søk.
  35. Our search is currently a free text search, and a search for Java gives 224 hits. We have 200 developers in our company, including lots of .net developers.
  36. Så la oss sepå en demo
  37. Twitter