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): """
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__ = {
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.
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. """
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):
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,