Skip to content

Contains python code for validating and correcting the directions of Cypher relationships based on a supplied query specification.

License

Notifications You must be signed in to change notification settings

Frodnar/cypher_direction_validation_entry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cypher direction validation competition entry

This repo holds my entry for Tomaz Bratanic's competition on validating relationship directions in Cypher queries.

The code is structured to be imported and used as a single function that takes properly formatted Cypher query text and schema text as inputs and returns a corrected query or an empty string if a relationship does not fit the schema.

The current version does not attempt to correct any other formatting mistakes or parse otherwise incorrectly formatted Cypher queries, since these are not requirements of the competition rules. These features could be added in the future, however.

Usage

>>> cypher_text = "MATCH (p:Person) RETURN p, [(p)<-[:WORKS_AT]-(o:Organization) | o.name] AS op"
>>> schema_text = "(Person, KNOWS, Person), (Person, WORKS_AT, Organization)"
>>> fix_cypher_relationship_directions(cypher_text, schema_text)
'MATCH (p:Person) RETURN p, [(p)-[:WORKS_AT]->(o:Organization) | o.name] AS op'

The fix_cypher_relationship_directions() function also accepts an optional pattern_config argument that can be used to change the regular expression specification should it be found to require modifications for specific query formats.

About

Contains python code for validating and correcting the directions of Cypher relationships based on a supplied query specification.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages