예제 #1
0
def load_subject_weibo_data():
    """加载客观微博数据
    """
    # topicname = u'外滩踩踏-微博'
    # topicname = u'呼格案-微博'
    # topicname = u'复旦投毒案-微博'
    topicname = u'APEC-微博'

    em = EventManager()
    topicid = em.getEventIDByName(topicname)
    event = Event(topicid)

    # f = open('caitai.jl')
    # f = open('huge.jl')
    # f = open('fudan.jl')
    f = open('apec.jl')
    for line in f:
        item = json.loads(line.strip())
        item['text'] = item['text'].encode('utf-8')
        item = subob_classifier(item)
        if not item['subject']:
            news = subject_weibo2news(item)
            event.saveItem(news)

    f.close()
예제 #2
0
def one_topic_clear(topicname_start):
    topicname, start_datetime = topicname_start
    em = EventManager()
    topicid = em.getEventIDByName(topicname)
    start_ts = datetime2ts(start_datetime)

    event = Event(topicid)
    event.initialize(start_ts)
예제 #3
0
def initializeNewsTopic():
    """初始化新闻话题
    """
    em = EventManager()

    topicname = u'外滩踩踏'
    start_datetime = "2015-01-02 00:00:00"
    topicid = em.getEventIDByName(topicname)
    start_ts = datetime2ts(start_datetime)

    event = Event(topicid)
    event.initialize(start_ts)
예제 #4
0
def initializeWeiboTopic():
    """初始化weibo话题
    """
    em = EventManager()

    # topicname = u'外滩踩踏-微博'
    # start_datetime = "2015-01-02 00:00:00"
    # topicname = u'呼格案-微博'
    # start_datetime = "2014-12-14 00:00:00"
    # topicname = u'复旦投毒案-微博'
    # start_datetime = "2014-12-15 00:00:00"
    topicname = u'APEC-微博'
    start_datetime = "2014-12-15 00:00:00"

    topicid = em.getEventIDByName(topicname)
    start_ts = datetime2ts(start_datetime)

    event = Event(topicid)
    event.initialize(start_ts)
예제 #5
0
def load_object_weibo_data():
    """加载主观微博数据
    """
    # topicname = u'外滩踩踏-微博'
    # topicname = u'呼格案-微博'
    # topicname = u'复旦投毒案-微博'
    # topicname = u'APEC-微博'
    # topicname = u'高校宣传思想工作-微博'
    topicname = u'张灵甫遗骨被埋羊圈-微博'

    em = EventManager()
    topicid = em.getEventIDByName(topicname)
    print topicid
    eventcomment = EventComments(topicid)

    # f = open('caitai.jl')
    # f = open('huge.jl')
    # f = open('fudan.jl')
    # f = open('apec.jl')
    # f = open('items_qiushi.jl')
    f = open('items_zhang.jl')
    for line in f:
        item = json.loads(line.strip())
        if 'mid' in item:
            item['text'] = item['text'].encode('utf-8')
            item = subob_classifier(item)
            if item['subject']:
                comment = api_object_weibo2comment(item)
                eventcomment.saveItem(comment)
        """
        item['text'] = item['text'].encode('utf-8')
        item = subob_classifier(item)
        if item['subject']:
            weibo = object_weibo2comment(item)
            eventcomment.saveItem(weibo)
        """

    f.close()
예제 #6
0
from case.time_utils import ts2datetime, ts2date
from xapian_case.xapian_backend import XapianSearch
from xapian_case.utils import cut, load_scws
from case.dynamic_xapian_weibo import getXapianWeiboByTopic
from case.global_config import XAPIAN_USER_DATA_PATH
from case.Database import Event, EventManager
from case.topic_manage import topics_name_start_end
from flask import Blueprint, url_for, render_template, request, abort, flash, session, redirect, make_response

scws = load_scws()

mod = Blueprint('case', __name__, url_prefix='/index')

xapian_search_weibo = getXapianWeiboByTopic()

em = EventManager()


def acquire_user_by_id(uid):
    user_search = XapianSearch(path=XAPIAN_USER_DATA_PATH,
                               name='master_timeline_user',
                               schema_version=1)
    result = user_search.search_by_id(int(uid),
                                      fields=[
                                          'name', 'location',
                                          'followers_count', 'friends_count',
                                          'profile_image_url'
                                      ])
    user = {}

    if result: