<commit_before>== Welcome to Neography

Neography is a thin Ruby wrapper to the Neo4j Rest API, for more information:
* {Getting Started with Neo4j Server}[http://wiki.neo4j.org/content/Getting_Started_with_Neo4j_Server]
* {Neo4j Rest API Reference}[http://components.neo4j.org/neo4j-rest/]

If you want to the full power of Neo4j, you will want to use JRuby and the excellent {Neo4j.rb} [https://github.com/andreasronge/neo4j]

=== Installation

  gem install 'neography'
  require 'neography'

=== Dependencies

  for use:
  json
  httparty 

  for development:
  rspec 
  net-http-spy 
  fakeweb 

==== Rails

Just add gem 'neography' to your Gemfile and run bundle install

=== Documentation

A thin ruby wrapper Neography::Rest which tries to mirror the Neo4j Rest API and returns JSON or Nil:

  #                            protocol,  server,        port,  log_file,           log_enabled
  @neo = Neography::Rest.new ('http://', '192.168.10.1', 7479, 'log/neography.log', true)

Default Parameters are:   

  @neo = Neography::Rest.new ('http://', 'localhost', 7474, '/neography.log', false)

To Use:

  @neo = Neography::Rest.new 

  @neo.get_root                                     # Get the root node
  @neo.create_node                                  # Create an empty node
  @neo.create_node("age" => 31, "name" => "Max")    # Create a node with some properties
  @neo.get_node(id)                                 # Get a node and its properties
  @neo.delete_node(id)                              # Delete an unrelated node
  @neo.delete_node!(id)                             # Delete a node and all its relationships

  @neo.reset_node_properties(id, {"age" => 31})     # Reset a node's properties
  @neo.set_node_properties(id, {"weight" => 200})   # Set a node's properties
  @neo.get_node_properties(id)                      # Get just the node properties
  @neo.get_node_properties(id, ["weight","age"])    # Get some of the node properties
  @neo.remove_node_properties(id)                   # Remove all properties of a node
  @neo.remove_node_properties(id, "weight")         # Remove one property of a node
  @neo.remove_node_properties(id, ["weight","age"]) # Remove multiple properties of a node

  @neo.create_relationship("friends", node1, node2)        # Create a relationship between node1 and node2
  @neo.get_node_relationships(id)                          # Get all relationships
  @neo.get_node_relationships(id, "in")                    # Get only incoming relationships
  @neo.get_node_relationships(id, "all", "enemies")        # Get all relationships of type enemies
  @neo.get_node_relationships(id, "in", "enemies")         # Get only incoming relationships of type enemies
  @neo.delete_relationship(id)                             # Delete a relationship

  @neo.reset_relationship_properties(id, {"age" => 31})    # Reset a relationship's properties
  @neo.set_relationship_properties(id, {"weight" => 200})  # Set a relationship's properties
  @neo.get_relationship_properties(id)                     # Get just the relationship properties
  @neo.get_relationship_properties(id, ["since","met"])    # Get some of the relationship properties
  @neo.remove_relationship_properties(id)                  # Remove all properties of a relationship
  @neo.remove_relationship_properties(id, "since")         # Remove one property of a relationship
  @neo.remove_relationship_properties(id, ["since","met"]) # Remove multiple properties of a relationship

  @neo.list_indexes                        # doesn't really seam to do what the api says it does
  @neo.add_to_index(key, value, id)        # adds a node to an index with the given key/value pair
  @neo.remove_from_index(key, value, id)   # removes a node to an index with the given key/value pair
  @neo.get_index(key, value)               # gets an index with the given key/value pair

  @neo.get_path(from, to, relationships, depth=4, algorithm="shortestPath") # finds the shortest path between two nodes 
  @neo.get_paths(from, to, relationships, depth=3, algorithm="allPaths")    # finds all paths between two nodes

  nodes = @neo.traverse(id,                                                 # the id of the node where the traversal starts
                        "nodes",                                            # the return type (can be "nodes", "relationships" or "paths"
                        {"order" => "breadth first",                        # "breadth first" or "depth first" traversal order
                         "uniqueness" => "node global",                     # See Uniqueness in API documentation for options.
                         "relationships" => [{"type"=> "roommates",         # A hash containg a description of the traversal
                                              "direction" => "all"},        # two relationships. 
                                             {"type"=> "friends",           # 
                                              "direction" => "out"}],       # 
                         "prune evaluator" => {"language" => "javascript",  # A prune evaluator (when to stop traversing)
                                               "body" => "position.endNode().getProperty('age') < 21;"
                         "return filter" => {"language" => "builtin",       # "all" or "all but start node"
                                             "name" => "all"},
                         "depth" => 4})  

  # "depth" is a short-hand way of specifying a prune evaluator which prunes after a certain depth. 
  # If not specified a depth of 1 is used and if a "prune evaluator" is specified instead of a depth, no depth limit is set.

{Order}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/Traverser.Order.html]
{Uniqueness}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/kernel/Uniqueness.html]
{Prune Evaluator}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/StopEvaluator.html]
{Return Filter}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/ReturnableEvaluator.html]

=== To Do

* More tests
* examples
* batch import with typhoeus ?
* create proper objects for Node and Relationship

=== License

* Neography - MIT, see the LICENSE file http://github.com/maxdemarzi/neography/tree/master/LICENSE.
* Lucene -  Apache, see http://lucene.apache.org/java/docs/features.html
* Neo4j - Dual free software/commercial license, see http://neo4j.org

<commit_msg>doc updates<commit_after>== Welcome to Neography

Neography is a thin Ruby wrapper to the Neo4j Rest API, for more information:
* {Getting Started with Neo4j Server}[http://wiki.neo4j.org/content/Getting_Started_with_Neo4j_Server]
* {Neo4j Rest API Reference}[http://components.neo4j.org/neo4j-rest/]

If you want to the full power of Neo4j, you will want to use JRuby and the excellent Neo4j.rb gem at https://github.com/andreasronge/neo4j

=== Installation

  gem install 'neography'
  require 'neography'

=== Dependencies

  for use:
  json
  httparty 

  for development:
  rspec 
  net-http-spy 
  fakeweb 

==== Rails

Just add gem 'neography' to your Gemfile and run bundle install

=== Documentation

A thin ruby wrapper Neography::Rest which tries to mirror the Neo4j Rest API and returns JSON or Nil:

  #                            protocol,  server,        port,  log_file,           log_enabled
  @neo = Neography::Rest.new ('http://', '192.168.10.1', 7479, 'log/neography.log', true)

Default Parameters are:   

  @neo = Neography::Rest.new ('http://', 'localhost', 7474, '/neography.log', false)

To Use:

  @neo = Neography::Rest.new 

  @neo.get_root                                     # Get the root node
  @neo.create_node                                  # Create an empty node
  @neo.create_node("age" => 31, "name" => "Max")    # Create a node with some properties
  @neo.get_node(id)                                 # Get a node and its properties
  @neo.delete_node(id)                              # Delete an unrelated node
  @neo.delete_node!(id)                             # Delete a node and all its relationships

  @neo.reset_node_properties(id, {"age" => 31})     # Reset a node's properties
  @neo.set_node_properties(id, {"weight" => 200})   # Set a node's properties
  @neo.get_node_properties(id)                      # Get just the node properties
  @neo.get_node_properties(id, ["weight","age"])    # Get some of the node properties
  @neo.remove_node_properties(id)                   # Remove all properties of a node
  @neo.remove_node_properties(id, "weight")         # Remove one property of a node
  @neo.remove_node_properties(id, ["weight","age"]) # Remove multiple properties of a node

  @neo.create_relationship("friends", node1, node2)        # Create a relationship between node1 and node2
  @neo.get_node_relationships(id)                          # Get all relationships
  @neo.get_node_relationships(id, "in")                    # Get only incoming relationships
  @neo.get_node_relationships(id, "all", "enemies")        # Get all relationships of type enemies
  @neo.get_node_relationships(id, "in", "enemies")         # Get only incoming relationships of type enemies
  @neo.delete_relationship(id)                             # Delete a relationship

  @neo.reset_relationship_properties(id, {"age" => 31})    # Reset a relationship's properties
  @neo.set_relationship_properties(id, {"weight" => 200})  # Set a relationship's properties
  @neo.get_relationship_properties(id)                     # Get just the relationship properties
  @neo.get_relationship_properties(id, ["since","met"])    # Get some of the relationship properties
  @neo.remove_relationship_properties(id)                  # Remove all properties of a relationship
  @neo.remove_relationship_properties(id, "since")         # Remove one property of a relationship
  @neo.remove_relationship_properties(id, ["since","met"]) # Remove multiple properties of a relationship

  @neo.list_indexes                        # doesn't really seam to do what the api says it does
  @neo.add_to_index(key, value, id)        # adds a node to an index with the given key/value pair
  @neo.remove_from_index(key, value, id)   # removes a node to an index with the given key/value pair
  @neo.get_index(key, value)               # gets an index with the given key/value pair

  @neo.get_path(from, to, relationships, depth=4, algorithm="shortestPath") # finds the shortest path between two nodes 
  @neo.get_paths(from, to, relationships, depth=3, algorithm="allPaths")    # finds all paths between two nodes

  nodes = @neo.traverse(id,                                                 # the id of the node where the traversal starts
                        "nodes",                                            # return_type (can be "nodes", "relationships" or "paths"
                        {"order" => "breadth first",                        # "breadth first" or "depth first" traversal order
                         "uniqueness" => "node global",                     # See Uniqueness in API documentation for options.
                         "relationships" => [{"type"=> "roommates",         # A hash containg a description of the traversal
                                              "direction" => "all"},        # two relationships. 
                                             {"type"=> "friends",           # 
                                              "direction" => "out"}],       # 
                         "prune evaluator" => {"language" => "javascript",  # A prune evaluator (when to stop traversing)
                                               "body" => "position.endNode().getProperty('age') < 21;"
                         "return filter" => {"language" => "builtin",       # "all" or "all but start node"
                                             "name" => "all"},
                         "depth" => 4})  

  # "depth" is a short-hand way of specifying a prune evaluator which prunes after a certain depth. 
  # If not specified a depth of 1 is used and if a "prune evaluator" is specified instead of a depth, no depth limit is set.

Please see the specs for more examples.

See Neo4j API for:
* {Order}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/Traverser.Order.html]
* {Uniqueness}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/kernel/Uniqueness.html]
* {Prune Evaluator}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/StopEvaluator.html]
* {Return Filter}[http://components.neo4j.org/neo4j-examples/1.2.M04/apidocs/org/neo4j/graphdb/ReturnableEvaluator.html]

=== To Do

* More tests
* examples
* batch import with typhoeus ?
* create proper objects for Node and Relationship

=== License

* Neography - MIT, see the LICENSE file http://github.com/maxdemarzi/neography/tree/master/LICENSE.
* Lucene -  Apache, see http://lucene.apache.org/java/docs/features.html
* Neo4j - Dual free software/commercial license, see http://neo4j.org


{'fraction_non_alphanumeric': 0.10543204217281688, 'fraction_numerical': 0.012300404920161968, 'mean_word_length': 2.303053242493061, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 43, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6287491', 'n_tokens_mistral': 3816, 'n_tokens_neox': 3557, 'n_words': 1108}