This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person(models.NodeModel): | |
name = models.StringProperty() | |
knows = models.Relationship('Person', | |
rel_type = neo4django.Outgoing.KNOWS, | |
related_name = 'is_known') | |
def connections(self, depth=1): | |
return [Person._neo4j_instance(node) \ | |
for node in self.node.traverse(types=[client.All.KNOWS], stop=depth)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person(models.NodeModel): | |
name = models.StringProperty() | |
knows = models.Relationship('Person', | |
rel_type = neo4django.Outgoing.KNOWS, | |
related_name = 'is_known') | |
def connections(self, depth=1): | |
from neo4django.db.models import query | |
from itertools import chain | |
query.execute_select_related(models=[self], max_depth=depth) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import jellyfish | |
>>> from soft_jaccard import soft_jaccard | |
>>> c1 = set(['CL Isbell','C. L. Isbell']) | |
>>> c2 = set(['C Isbell','C Isbell, Jr.']) | |
>>> soft_jaccard(c1, c2, jellyfish.jaro_winkler) | |
0.75848950260673509 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LazyBase(object): | |
""" | |
A mixin to make elements of the REST client lazy. | |
""" | |
def __init__(self, url, dic): | |
self._dont_update = True | |
super(LazyBase, self).__init__(url, create=False) | |
self._dic = dic.copy() | |
self._dont_update = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a hack for `NodeA.objects.filter(nodeb__in=nodebnodes)` | |
from neo4django.db import connections | |
from neo4django.db.models.script_utils import LazyNode | |
# ... | |
b_nodes = set([...]) #your NodeB instances | |
b_node_ids = [b.id for b in b_nodes] | |
type_node_a = NodeA._type_node() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VERSION='1.6' | |
DIR="neo4j-community-$VERSION" | |
FILE="$DIR-unix.tar.gz" | |
SERVER_PROPERTIES_FILE="lib/neo4j/conf/neo4j-server.properties" | |
if [[ ! -d lib/$DIR ]]; then | |
wget http://dist.neo4j.org/$FILE | |
tar xvfz $FILE &> /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from neo4django.db import models | |
import neo4django | |
class Concept(models.NodeModel): | |
name = models.StringProperty(indexed=True) | |
class ContainerConcept(Concept): | |
class Meta: | |
abstract = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@nettuno:~$ cd ~/builds | |
vagrant@nettuno:~/builds$ export TRAVIS_PULL_REQUEST=false | |
vagrant@nettuno:~/builds$ export TRAVIS_SECURE_ENV_VARS=false | |
vagrant@nettuno:~/builds$ export NEO4J_VERSION="1.6.3" | |
vagrant@nettuno:~/builds$ git clone --depth=100 --quiet git://github.com/mhluongo/neo4django.git mhluongo/neo4django | |
vagrant@nettuno:~/builds$ cd mhluongo/neo4django | |
vagrant@nettuno:~/builds/mhluongo/neo4django$ git checkout -qf 155c266129d2d587b39e5d7acff86b123c94dda7 | |
vagrant@nettuno:~/builds/mhluongo/neo4django$ export TRAVIS_PYTHON_VERSION=2.6 | |
vagrant@nettuno:~/builds/mhluongo/neo4django$ source ~/virtualenv/python2.6/bin/activate | |
vagrant@nettuno:~/builds/mhluongo/neo4django$ python --version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a hack for pete.groups.filter(created_date__gt = datetime.date(2012,1,1), type__type = "Chess Club") | |
import datetime | |
import neo4django | |
from neo4django.db import models | |
class Person(models.NodeModel): | |
auto_id = models.AutoProperty(indexed=True) | |
groups = models.Relationship('Group', related_name='people', | |
rel_type=neo4django.Outgoing.MEMBER_OF) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import orcid | |
>>> cs_authors = orcid.search('computer science') | |
>>> print cs_authors.next() | |
<Author Olga Zhelenkova, ORCID 0000-0003-0028-2469> |
OlderNewer