コード例 #1
0
ファイル: story.py プロジェクト: publicscience/argos
from argos.core.brain.summarizer import multisummarize

import itertools
from nltk.tokenize import sent_tokenize

from argos.util.logger import logger
from argos.conf import APP

logr = logger('STORY_CLUSTERING')

if APP['DEBUG']:
    logr.setLevel('DEBUG')
else:
    logr.setLevel('ERROR')

stories_events = join_table('stories_events', 'story', 'event')
stories_mentions = join_table('stories_mentions', 'story', 'alias')

class StoryConceptAssociation(BaseConceptAssociation):
    __backref__     = 'story_associations'
    story_id        = db.Column(db.Integer, db.ForeignKey('story.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True)

class Story(Cluster):
    __tablename__   = 'story'
    __members__     = {'class_name': 'Event', 'secondary': stories_events, 'backref_name': 'stories'}
    __concepts__    = {'association_model': StoryConceptAssociation, 'backref_name': 'story'}
    __mentions__    = {'secondary': stories_mentions, 'backref_name': 'stories'}

    @property
    def events(self):
        """
コード例 #2
0
ファイル: story.py プロジェクト: publicscience/argos
from argos.core.brain.summarizer import multisummarize

import itertools
from nltk.tokenize import sent_tokenize

from argos.util.logger import logger
from argos.conf import APP

logr = logger('STORY_CLUSTERING')

if APP['DEBUG']:
    logr.setLevel('DEBUG')
else:
    logr.setLevel('ERROR')

stories_events = join_table('stories_events', 'story', 'event')
stories_mentions = join_table('stories_mentions', 'story', 'alias')


class StoryConceptAssociation(BaseConceptAssociation):
    __backref__ = 'story_associations'
    story_id = db.Column(db.Integer,
                         db.ForeignKey('story.id',
                                       ondelete='CASCADE',
                                       onupdate='CASCADE'),
                         primary_key=True)


class Story(Cluster):
    __tablename__ = 'story'
    __members__ = {
コード例 #3
0
ファイル: article.py プロジェクト: publicscience/argos
from argos.core.models.cluster import Clusterable
from argos.core import knowledge

import galaxy as gx

import pytz
from sqlalchemy import event
from slugify import slugify

import re
from collections import Counter
from datetime import datetime

epoch = datetime.utcfromtimestamp(0).replace(tzinfo=pytz.UTC)

articles_authors = join_table('articles_authors', 'article', 'author')
articles_mentions = join_table('articles_mentions', 'article', 'alias')


class ArticleConceptAssociation(BaseConceptAssociation):
    __backref__ = 'article_associations'
    article_id = db.Column(db.Integer,
                           db.ForeignKey('article.id',
                                         ondelete='CASCADE',
                                         onupdate='CASCADE'),
                           primary_key=True)


class Article(Clusterable):
    """
    An article.
コード例 #4
0
ファイル: article.py プロジェクト: publicscience/argos
from argos.core.models.cluster import Clusterable
from argos.core import knowledge

import galaxy as gx

import pytz
from sqlalchemy import event
from slugify import slugify

import re
from collections import Counter
from datetime import datetime

epoch = datetime.utcfromtimestamp(0).replace(tzinfo=pytz.UTC)

articles_authors = join_table("articles_authors", "article", "author")
articles_mentions = join_table("articles_mentions", "article", "alias")


class ArticleConceptAssociation(BaseConceptAssociation):
    __backref__ = "article_associations"
    article_id = db.Column(
        db.Integer, db.ForeignKey("article.id", ondelete="CASCADE", onupdate="CASCADE"), primary_key=True
    )


class Article(Clusterable):
    """
    An article.
    """
コード例 #5
0
ファイル: event.py プロジェクト: publicscience/argos
from argos.datastore import db, join_table
from argos.core.models.cluster import Cluster
from argos.core.models.concept import BaseConceptAssociation
from argos.core.brain import summarizer

from itertools import chain
from datetime import datetime
from math import log
from sqlalchemy import event, inspect
from nltk.tokenize import sent_tokenize

import galaxy as gx

events_articles = join_table('events_articles', 'event', 'article')
events_mentions = join_table('events_mentions', 'event', 'alias')

class EventConceptAssociation(BaseConceptAssociation):
    __backref__     = 'event_associations'
    event_id        = db.Column(db.Integer, db.ForeignKey('event.id', ondelete='CASCADE', onupdate='CASCADE'), primary_key=True)

class Event(Cluster):
    __tablename__   = 'event'
    __members__     = {'class_name': 'Article', 'secondary': events_articles, 'backref_name': 'events'}
    __concepts__    = {'association_model': EventConceptAssociation, 'backref_name': 'event'}
    __mentions__    = {'secondary': events_mentions, 'backref_name': 'events'}
    active          = db.Column(db.Boolean, default=True)
    raw_score       = db.Column(db.Float, default=0.0)
    _score          = db.Column(db.Float, default=0.0)

    @classmethod
    def all_active(cls):
コード例 #6
0
from argos.datastore import db, join_table
from argos.core.models.cluster import Cluster
from argos.core.models.concept import BaseConceptAssociation
from argos.core.brain import summarizer

from itertools import chain
from datetime import datetime
from math import log
from sqlalchemy import event, inspect
from nltk.tokenize import sent_tokenize

import galaxy as gx

events_articles = join_table('events_articles', 'event', 'article')
events_mentions = join_table('events_mentions', 'event', 'alias')


class EventConceptAssociation(BaseConceptAssociation):
    __backref__ = 'event_associations'
    event_id = db.Column(db.Integer,
                         db.ForeignKey('event.id',
                                       ondelete='CASCADE',
                                       onupdate='CASCADE'),
                         primary_key=True)


class Event(Cluster):
    __tablename__ = 'event'
    __members__ = {
        'class_name': 'Article',
        'secondary': events_articles,