Exemplo n.º 1
0
class Post(nm.StructuredNode):
    uid = nm.StringProperty(unique_index=True, default=uuid4)
    create_datetime = nm.DateTimeProperty(default_now=True)
    content = nm.StringProperty(required=True)

    comments = nm.Relationship('Comment', 'COMMENTED')
    written_by = nm.Relationship('User', 'WRITTEN_BY')
Exemplo n.º 2
0
class User(nm.StructuredNode):
    uid = nm.StringProperty(index=True, default=uuid4)
    create_datetime = nm.DateTimeProperty(default_now=True)
    email = nm.StringProperty(unique_index=True, required=True)
    password = nm.StringProperty(required=True)
    name = nm.StringProperty(required=True)

    liked_posts = nm.RelationshipTo('Post', 'LIKED', model=Like)
    followings = nm.RelationshipTo('User', 'FOLLOW')
Exemplo n.º 3
0
class News(neomodel.StructuredNode):
    headline = neomodel.StringProperty(unique_index=True, required=True)
    url = neomodel.StringProperty(required=False)
    publisher = neomodel.StringProperty(required=False)
    created_at = neomodel.DateTimeProperty(required=False)
    keywords = neomodel.ArrayProperty(neomodel.StringProperty(),
                                      required=False)
    score = neomodel.FloatProperty(required=False)

    cites = neomodel.RelationshipTo('Company', 'CITES')
Exemplo n.º 4
0
class PipelineRunInfo(neomodel.StructuredNode):
    """
    Define a model for pipeline run information.
    """
    uid = neomodel.UniqueIdProperty()  # Unique ID for this database entry
    run_id = neomodel.StringProperty(
    )  # ID for this pipeline run, created with sentence IDs involved in this run
    timestamp = neomodel.StringProperty(
    )  # Timestamp for the current pipeline run
    article_ids = neomodel.ArrayProperty(
    )  # List of sentence IDs involved in this pipeline run
Exemplo n.º 5
0
class Recipe(nm.StructuredNode):
    r_id = nm.UniqueIdProperty()
    title = nm.StringProperty()
    description = nm.StringProperty()
    requires = nm.RelationshipTo('Ingredient', 'REQUIRES', model=Requires)

    def to_dict(self):
        return {
            'r_id': self.r_id,
            'title': self.title,
            'description': self.description
        }
Exemplo n.º 6
0
class Entity(neomodel.StructuredNode, EveCompatibilityMixin):
    """
    Node model for entities in the graph.
    """
    uid = neomodel.UniqueIdProperty()  # Unique ID for this database entry
    category = neomodel.StringProperty(
    )  # Category of this entity (Person, Organization...)
    label = neomodel.StringProperty(
    )  # Text that should be displayed about this node
    data = neomodel.JSONProperty(
    )  # Dictionary with more detailed data about this entity
    relations = neomodel.Relationship("Entity",
                                      "CONNECTED_WITH",
                                      model=Relation)
    weight = neomodel.IntegerProperty(default=1)
Exemplo n.º 7
0
class BasePerson(neomodel.StructuredNode):
    """
    Base class for defining some basic sort of an actor.
    """
    name = neomodel.StringProperty(required = True, unique_index = True)
    friends_with = neomodel.RelationshipTo("BasePerson", "FRIENDS_WITH",
                                           model = PersonalRelationship)
Exemplo n.º 8
0
class PilotPerson(BasePerson):
    """
    A pilot person specialises BasePerson by adding the type of airplane they
    can operate.
    """

    airplane = neomodel.StringProperty(required=True)
Exemplo n.º 9
0
class Company(neomodel.StructuredNode):
    id_str = neomodel.StringProperty(unique_index=True, required=True)
    name = neomodel.StringProperty(required=False)
    created_at = neomodel.DateTimeProperty(required=False)
    modified = neomodel.DateTimeProperty(required=False)
    description = neomodel.StringProperty(required=False)
    brand_score = neomodel.FloatProperty(required=False)
    tweet_score = neomodel.FloatProperty(required=False)
    news_score = neomodel.FloatProperty(required=False)
    stock_price = neomodel.FloatProperty(required=False)
    stock_change = neomodel.FloatProperty(required=False)
    mkt_cap = neomodel.FloatProperty(required=False)

    def save(self):
        self.modified = datetime.datetime.now()
        super(Company, self).save()
        return self
Exemplo n.º 10
0
class specificModelClass3(baseModelClass2):
    '''Models another class that is a specialisation of baseModelClass2
    
    NOTE:
        This class is a specialisation of baseModelClass2, therefore it is also perfectly valid 
        as an "attachment" to someLink
    '''
    yetAnotherAttribute = neomodel.StringProperty(index=True)
Exemplo n.º 11
0
class specificModelClass2(baseModelClass2):
    '''Models a class that is a specialisation of baseModelClass2
    
    NOTE:
        This class is a specialisation of baseModelClass2, therefore it is perfectly 
        valid to be "attached" at someLink. 
    '''
    anotherAttribute = neomodel.StringProperty(unique_index=True)
Exemplo n.º 12
0
class Relation(neomodel.StructuredRel, EveCompatibilityMixin):
    """
    Node model for relations in the graph.
    """
    label = neomodel.StringProperty(
    )  # Text that should be displayed about this edge
    data = neomodel.JSONProperty(
    )  # Dictionary with more detailed data about this relation
    weight = neomodel.IntegerProperty(default=1)
Exemplo n.º 13
0
class Location(neomodel.StructuredNode):
    location_id = neomodel.IntegerProperty(unique_index=True)
    name = neomodel.StringProperty(required=True)
    parent = neomodel.RelationshipTo("Location",
                                     "IS_IN",
                                     neomodel.ZeroOrOne,
                                     model=LocationRelationship)

    def __str__(self):
        return self.name
Exemplo n.º 14
0
class EventNode(neomodel.StructuredNode):

    ## event name --> Type field
    ## event target --> Value field
    ## other properties are currently empty

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()
Exemplo n.º 15
0
class DOMSnapshot(neomodel.StructuredNode):

    ## html path 		--> Location field
    ## html code 		--> Code field
    ## other properties are currently empty

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()
Exemplo n.º 16
0
class BaseEntity(neomodel.StructuredNode):
    name = neomodel.StringProperty(unique_index=True)
    variants = neomodel.JSONProperty()
    best_variant = neomodel.StringProperty()
    count = neomodel.IntegerProperty(default=1)
    weight = neomodel.FloatProperty(default=0)
    create_at = neomodel.DateTimeFormatProperty(format=DATETIME_FORMAT, default_now=True)

    # GOD attributes: relation from head (self) to Tail (other)
    used_for = neomodel.RelationshipTo(neomodel.StructuredNode, 'used_for', model=UsedFor)
    part_of = neomodel.RelationshipTo(neomodel.StructuredNode, 'part_of', model=PartOf)
    feature_of = neomodel.RelationshipTo(neomodel.StructuredNode, 'feature_of', model=FeatureOf)
    compare = neomodel.RelationshipTo(neomodel.StructuredNode, 'compare', model=Compare)
    hyponym_of = neomodel.RelationshipTo(neomodel.StructuredNode, 'hyponym_of', model=HyponymOf)
    evaluate_for = neomodel.RelationshipTo(neomodel.StructuredNode, 'evaluate_for', model=EvaluateFor)
    refer_to = neomodel.RelationshipTo(neomodel.StructuredNode, 'refer_to', model=ReferTo)
    appear_in = neomodel.RelationshipTo(neomodel.StructuredNode, 'appear_in', model=AppearIn)
    author_of = neomodel.RelationshipTo(neomodel.StructuredNode, 'author_of', model=AuthorOf)
    affiliate_with = neomodel.RelationshipTo(neomodel.StructuredNode, 'affiliate_with', model=AffiliateWith)
    cite = neomodel.RelationshipTo(neomodel.StructuredNode, 'cite', model=Cite)
    related_to = neomodel.RelationshipTo(neomodel.StructuredNode, 'related_to', model=RelatedTo)
Exemplo n.º 17
0
class Tweet(neomodel.StructuredNode):
    id_str = neomodel.StringProperty(unique_index=True, required=True)
    created_at = neomodel.DateTimeProperty(required=False)
    modified = neomodel.DateTimeProperty(required=False)
    retweeted = neomodel.BooleanProperty(required=False)
    retweet_id_str = neomodel.StringProperty(required=False, default='')
    reply_id_str = neomodel.StringProperty(required=False, default='')
    quote_id_str = neomodel.StringProperty(required=False, default='')
    mention_ids_str = neomodel.ArrayProperty(required=False, default=[])
    text = neomodel.StringProperty(required=False)
    coordinates = neomodel.ArrayProperty(required=False, default=[])
    lang = neomodel.StringProperty(required=False)
    features = neomodel.JSONProperty(required=False, default={})
    sentiment_polarity = neomodel.FloatProperty(required=False)
    sentiment_subjectivity = neomodel.FloatProperty(required=False)

    retweets = neomodel.RelationshipTo('Tweet', 'RETWEETS')
    mentions = neomodel.RelationshipTo('User', 'MENTIONS')
    replies = neomodel.RelationshipTo('Tweet', 'REPLIES')
    tags = neomodel.RelationshipTo('Hashtag', 'TAGS')
    contains = neomodel.RelationshipTo('Link', 'CONTAINS')
    quotes = neomodel.Relationship('Tweet', 'QUOTES')
    tweet_about = neomodel.RelationshipTo('Company', 'TWEETS')

    def save(self):
        self.modified = datetime.datetime.now()
        super(Tweet, self).save()
        return self
Exemplo n.º 18
0
class CookieNode(neomodel.StructuredNode):

    ## cookie name 		--> Raw field
    ## cookie value 	--> Value field
    ## cookie httpOnly  --> Type field
    ## other properties are currently empty

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()
Exemplo n.º 19
0
class Event(neomodel.StructuredNode):
    name = neomodel.StringProperty(unique_index=True, required=True)
    weighting = neomodel.FloatProperty(required=False)
    modified = neomodel.DateTimeProperty(required=False)

    related_to = neomodel.RelationshipTo('Company', 'ABOUT')
    tweet_from = neomodel.RelationshipFrom('Tweet', 'TWEET_FROM')
    cited_from = neomodel.RelationshipFrom('News', 'CITE_FROM')

    def save(self):
        self.modified = datetime.datetime.now()
        super(Event, self).save()
        return self
Exemplo n.º 20
0
class Company(nm.StructuredNode):
    name = nm.StringProperty(unique_index=True, require=True)
    symbol = nm.StringProperty()
    market = nm.StringProperty()
    list_date = nm.IntegerProperty()
    updated = nm.DateTimeProperty(default_now=True)

    concept = nm.RelationshipTo('Concept',
                                'COMPONENT_OF',
                                cardinality=nm.ZeroOrMore,
                                model=ComponentRel)
    industry = nm.RelationshipTo('Industry',
                                 'COMPONENT_OF',
                                 cardinality=nm.ZeroOrMore,
                                 model=ComponentRel)
    index = nm.RelationshipTo('Industry',
                              'COMPONENT_OF',
                              cardinality=nm.ZeroOrMore,
                              model=ComponentRel)
    customer = nm.RelationshipTo('Company',
                                 'SUPPLIES_TO',
                                 cardinality=nm.ZeroOrMore)
    product = nm.RelationshipTo('Product', 'PRODUCES', model=ProductRel)
Exemplo n.º 21
0
class RequestNode(neomodel.StructuredNode):

    ## request method 					   --> Type field
    ## request kind (e.g., xmlhttprequest) --> Kind field
    ## request URL						   --> Value field
    ## request body						   --> Raw field
    ## request status code 				   --> Code field
    ## other properties are currently empty

    # properties
    Id = neomodel.UniqueIdProperty()
    Type = neomodel.StringProperty()
    Kind = neomodel.StringProperty()
    Code = neomodel.StringProperty()
    Range = neomodel.StringProperty()
    Location = neomodel.StringProperty()
    Value = neomodel.StringProperty()
    Raw = neomodel.StringProperty()
    Async = neomodel.StringProperty()
    SemanticType = neomodel.StringProperty()
Exemplo n.º 22
0
class User(neomodel.StructuredNode):
    id_str = neomodel.StringProperty(unique_index=True, required=True)
    name = neomodel.StringProperty(required=False)
    screen_name = neomodel.StringProperty(required=False)
    followers_count = neomodel.IntegerProperty(required=False)
    friends_count = neomodel.IntegerProperty(required=False)
    modified = neomodel.DateTimeProperty(required=False)
    created_at = neomodel.DateTimeProperty(required=False)
    description = neomodel.StringProperty(required=False)
    location = neomodel.StringProperty(required=False)
    coordinates = neomodel.ArrayProperty(required=False, default=[])
    time_zone = neomodel.StringProperty(required=False)
    url = neomodel.StringProperty(required=False)
    lang = neomodel.StringProperty(required=False)

    follows = neomodel.RelationshipTo('User', 'FOLLOWS')
    posts = neomodel.RelationshipTo('Tweet', 'POSTS')

    def save(self):
        self.modified = datetime.datetime.now()
        super(User, self).save()
Exemplo n.º 23
0
class Movie(neo.StructuredNode):
    uid = neo.IntegerProperty()
    title = neo.StringProperty()
    vote = neo.StringProperty()
    overview = neo.StringProperty()
    poster = neo.StringProperty()
    date = neo.StringProperty()
    language = neo.StringProperty()

    producer = neo.RelationshipTo('Producer',
                                  'PRODUCE_BY',
                                  cardinality=ZeroOrOne)
    compositor = neo.RelationshipTo('Compositor',
                                    'COMPOSED_BY',
                                    cardinality=ZeroOrOne)
    director = neo.RelationshipTo('Director', 'LEAD_BY', cardinality=ZeroOrOne)
    actors = neo.RelationshipTo('Actor', 'PLAYED_BY', cardinality=ZeroOrMore)
    genres = neo.RelationshipTo('Genre', 'OWN', cardinality=ZeroOrMore)
    keywords = neo.RelationshipTo('Keyword', 'IS', cardinality=ZeroOrMore)

    @property
    def serialize(self):
        return {
            'id': self.uid,
            'title': self.title,
            'vote_average': self.vote,
            'overview': self.overview,
            'poster_path': self.poster,
            'release_date': self.date,
            'original_language': self.language
        }

    @classmethod
    def related_base(cls, name, selection):
        return neo.db.cypher_query(
            f"""MATCH (Base {{name:"{name}"}})--(m:Movie)--(b:Base)
                WHERE NOT m.uid IN {selection}
                RETURN m, collect(b) LIMIT 50""")[0]

    @classmethod
    def matrix(cls, selection_ids):
        return neo.db.cypher_query(f"""MATCH (p)-[r]-(m:Movie)
                WHERE m.uid in {selection_ids}
                WITH p, Count(r) AS CountRelation
                RETURN p, CountRelation 
                ORDER BY CountRelation DESC LIMIT 30""")
Exemplo n.º 24
0
class SomeEntity(neomodel.StructuredNode):
    """
        A bare minimum entity specified in neomodel to demonstrate the error condition and how to enter it.
    """
    serial_num = neomodel.UniqueIdProperty()
    payload = neomodel.StringProperty(unique_index=True)
Exemplo n.º 25
0
class Link(neomodel.StructuredNode):
    url = neomodel.StringProperty(unique_index=True, required=True)
Exemplo n.º 26
0
class Hashtag(neomodel.StructuredNode):
    text = neomodel.StringProperty(unique_index=True, required=True)
Exemplo n.º 27
0
class BaseOtherPerson(neomodel.StructuredNode):
    """
    An obviously "wrong" class of actor to befriend BasePersons with.
    """
    car_color = neomodel.StringProperty(required=True)
Exemplo n.º 28
0
class TechnicalPerson(BasePerson):
    """
    A Technical person specialises BasePerson by adding their expertise.
    """
    expertise = neomodel.StringProperty(required=True)
Exemplo n.º 29
0
class Ingredient(nm.StructuredNode):
    name = nm.StringProperty()
    keyword = nm.StringProperty(required=True)

    def to_dict(self):
        return {'keyword': self.keyword, 'name': self.name}
Exemplo n.º 30
0
class Requires(nm.StructuredRel):
    quant = nm.FloatProperty()
    unit = nm.StringProperty()