Ejemplo n.º 1
0
 def __init__(self):
     watch("httpstream")
     self.graph = Graph(super().graph_url)
     tx = self.graph.cypher.begin()
     tx.append(SnomedConceptProcessor.create_index_concept_id)
     tx.append(SnomedConceptProcessor.create_index_term)
     tx.commit()
Ejemplo n.º 2
0
 def create_unique(self, entity):
     entity = Graph.cast(entity)
     index = len(self.entities)
     name = _(index)
     if isinstance(entity, Path):
         self.names.append(self.create_unique_path(entity, name))
     else:
         raise TypeError("Cannot create unique entity of type %s" % type(entity).__name__)
     self.entities.append(entity)
Ejemplo n.º 3
0
 def create_unique(self, entity):
     entity = Graph.cast(entity)
     index = len(self.entities)
     name = _(index)
     if isinstance(entity, Path):
         self.names.append(self.create_unique_path(entity, name))
     else:
         raise TypeError("Cannot create unique entity of type %s" %
                         type(entity).__name__)
     self.entities.append(entity)
Ejemplo n.º 4
0
 def delete(self, entity):
     entity = Graph.cast(entity)
     index = len(self.entities)
     name = _(index)
     if isinstance(entity, Node):
         self.delete_node(entity, name)
     elif isinstance(entity, Relationship):
         self.delete_relationship(entity, name)
     elif isinstance(entity, Path):
         self.delete_path(entity, name)
     self.entities.append(entity)
Ejemplo n.º 5
0
    def delete(self, entity):
        """ Append an entity to the DELETE clause of this statement.

        :arg entity: The entity to delete.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Node):
            self._delete_node(entity, name)
        elif isinstance(entity, Relationship):
            self._delete_relationship(entity, name)
        elif isinstance(entity, Path):
            self._delete_path(entity, name)
        self.entities.append(entity)
Ejemplo n.º 6
0
    def delete(self, entity):
        """ Append an entity to the DELETE clause of this statement.

        :arg entity: The entity to delete.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Node):
            self._delete_node(entity, name)
        elif isinstance(entity, Relationship):
            self._delete_relationship(entity, name)
        elif isinstance(entity, Path):
            self._delete_path(entity, name)
        self.entities.append(entity)
Ejemplo n.º 7
0
    def create(self, entity):
        """ Append an entity to the CREATE clause of this statement.

        :arg entity: The entity to create.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Node):
            self.names.append(self._create_node(entity, name))
        elif isinstance(entity, Path):
            self.names.append(self._create_path(entity, name, unique=False))
        else:
            raise TypeError("Cannot create entity of type %s" % type(entity).__name__)
        self.entities.append(entity)
Ejemplo n.º 8
0
    def create(self, entity):
        """ Append an entity to the CREATE clause of this statement.

        :arg entity: The entity to create.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Node):
            self.names.append(self._create_node(entity, name))
        elif isinstance(entity, Path):
            self.names.append(self._create_path(entity, name, unique=False))
        else:
            raise TypeError("Cannot create entity of type %s" %
                            type(entity).__name__)
        self.entities.append(entity)
Ejemplo n.º 9
0
    def create_unique(self, entity):
        """ Append an entity to the CREATE UNIQUE clause of this statement.

        :arg entity: The entity to add.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Path):
            if len(entity) == 0:
                raise ValueError("Cannot create unique path with zero length")
            if not any(node.bound or node in self for node in entity.nodes):
                raise ValueError("At least one node must be bound to create a unique path")
            self.names.append(self._create_path(entity, name, unique=True))
        else:
            raise TypeError("Cannot create unique entity of type %s" % type(entity).__name__)
        self.entities.append(entity)
Ejemplo n.º 10
0
    def create_unique(self, entity):
        """ Append an entity to the CREATE UNIQUE clause of this statement.

        :arg entity: The entity to add.

        """
        entity = Graph.cast(entity)
        index = len(self.entities)
        name = _(index)
        if isinstance(entity, Path):
            if len(entity) == 0:
                raise ValueError("Cannot create unique path with zero length")
            if not any(node.bound or node in self for node in entity.nodes):
                raise ValueError(
                    "At least one node must be bound to create a unique path")
            self.names.append(self._create_path(entity, name, unique=True))
        else:
            raise TypeError("Cannot create unique entity of type %s" %
                            type(entity).__name__)
        self.entities.append(entity)
Ejemplo n.º 11
0
import json
import os
import shutil
import sys
import time
import urlparse

from dateutil import parser
from py2neo.core import Graph
from whoosh import scoring
from whoosh.index import open_dir
from whoosh.qparser.default import MultifieldParser
from whoosh.qparser.syntax import OrGroup
from whoosh.scoring import BM25F, TF_IDF

graph = Graph("http://*****:*****@localhost:7474/db/data/")

__version__ = "0.6"

__all__ = ["MyHttpServer"]

try:
    from cStringIO import StringIO
except ImportError:
    from StringIO import StringIO


class OurWeight(scoring.WeightingModel):
    class Scorer(scoring.BaseScorer):
        def __init__(self, idfScorer, bm25Scorer):
            self.idfScorer = idfScorer
Ejemplo n.º 12
0
 def __init__(self):
     watch("httpstream")
     self.graph = Graph(super().graph_url)
Ejemplo n.º 13
0
def load(server_url, geometry_name, wkt_string, layer_name):
    graph = Graph(server_url)
    spatial = Spatial(graph)
    spatial.create_layer(layer_name)
    spatial.create_geometry(geometry_name, wkt_string, layer_name)
    print('done')
Ejemplo n.º 14
0
 def test_can_get_same_instance(self):
     graph_1 = Graph()
     graph_2 = Graph()
     assert graph_1 is graph_2