def __init__(self, time_gap): self._graph = Graph( f"http://{ApplicationConfig.get_neo4j_ip()}:{ApplicationConfig.get_neo4j_port()}/browser", user=ApplicationConfig.get_neo4j_user(), password=ApplicationConfig.get_neo4j_password()) self._node_matcher = NodeMatcher(self._graph) self._rel_matcher = RelationshipMatcher(self._graph) query = 'MATCH (n) WHERE EXISTS(n.date) RETURN DISTINCT n.date AS date' date = self._graph.run(query).to_data_frame() date = date.sort_values(by='date') date['date'] = date.apply( lambda x: datetime.strptime(x['date'], '%Y-%m-%d').date(), axis=1) self._date_integrate(date, time_gap)
def __init__(self, sentence): config = ApplicationConfig.get_corenlp_config() self._parser = CoreNLPParser(url=f"http://{config['host']}:{config['port']}") self._dependency = CoreNLPDependencyParser(url=f"http://{config['host']}:{config['port']}") sentence = sentence.replace(' ', ' ') sentence = sentence.replace('.', '') self._load(sentence) self.original = sentence
def __init__(self): self._key = ['subject', 'predicate', 'object'] self._NodeHeader = [ 'label', 'date', 'name', 'newsId', 'number', 'source' ] self._RelHeader = [ 'start', 'type', 'end', 'relation', 'date', 'newsId', 'number', 'source' ] self._path = ApplicationConfig.get_neo4j_svo_output_path()
import pandas as pd import numpy as np import pickle import string from os import listdir from datetime import datetime from tqdm import tqdm import SVO_final as SVO import re from cathay.config import ApplicationConfig import boto3 from multiprocessing import Pool import nltk import sys aws_nlu_config = ApplicationConfig.get_aws_nlu_config() comprehend = boto3.client(aws_access_key_id=aws_nlu_config['access_key'], aws_secret_access_key=aws_nlu_config['secret_key'], service_name='comprehend', region_name=aws_nlu_config['region']) def title_preprocess(sent, comprehend): if sent.find('-') == 8 and sent[:6] == 'UPDATE': sent = sent[9:] if sent.find('-') == 8 and sent[:6] == 'WRAPUP': sent = sent[9:] if sent.find('-') == 3 and sent[:3] == 'RPT': sent = sent[5:] while sent.find('-') != -1 and sent[:sent.find('-')].isupper(): sent = sent[sent.find('-') + 1:]
def __init__(self, folder): self.path = ApplicationConfig.get_neo4j_svo_output_path() + folder self._save() self._merge()
def __init__(self): self._graph = Graph( f"http://{ApplicationConfig.get_neo4j_ip()}:{ApplicationConfig.get_neo4j_port()}/browser", user=ApplicationConfig.get_neo4j_user(), password=ApplicationConfig.get_neo4j_password())