Exemplo n.º 1
0
    def __init__(self):
        """
        Open client for Stanford NERTagger
        :return: protocol open
        """

        ser_path = get_project_path(
        ) + '/nltk_libs/english.all.3class.distsim.crf.ser'
        jar_path = get_project_path() + '/nltk_libs/stanford-ner-3.8.0.jar'

        self.st = StanfordNERTagger(ser_path, jar_path)
Exemplo n.º 2
0
def make_report(interface: InterFaceReport, period: dict) -> None:
    """
    Make interface for report
    :param interface: Data needed only for interface (dict)
    :param period: dict containing the respective period with the following keys: {start_year, start_week, end_year, end_week}
    :return: make the interface to filter the data needed to make report
    """
    write_report = WriteReport(period=period)
    write_report.write_header()

    write_report.write_table(cons.subtitle_sr, False,
                             interface.table_surveys_replies,
                             cons.columns_names_surveys_reply_percentage)

    write_report.write_image(cons.subtitle_sr_wc, True,
                             interface.image_base64_sr,
                             interface.table_surveys_replies)

    write_report.write_table(cons.subtitle_topics, True,
                             interface.table_topics,
                             cons.columns_names_topics_percentage)
    write_report.write_table(cons.subtitle_topics_comments, True,
                             interface.table_topic_comment,
                             cons.columns_names_topics_percentage)
    write_report.write_image(cons.subtitle_topics_wc, True,
                             interface.image_base64_topics,
                             interface.table_topics)

    target_dir = get_project_path() + cons.output_pdf_file

    write_report.save_pdf(target_week,
                          target_year,
                          target_dir,
                          company_id=None)
    Storage.upload_files(target_dir)
Exemplo n.º 3
0
    def notify_logging_event() -> None:
        """
        Notifies the system in use, using the last logging message.
        :return:
        """
        log_file = open("%s/engage-analytics.log" % get_project_path(), 'r').readlines()

        msg = generate_slack_message(message_heading="New Job Finished",
                                     status=False,
                                     logging_message=log_file[-1:][0])
        AlertMessage.send_slack_message("Active Companies Workflow", msg)
Exemplo n.º 4
0
def task():
  # Logger
  from utils.data_connection.source_manager import Connector
  from utils.utilities import set_log_level, get_project_path
  from active_companies.src.workflows.validation import ActiveCompanies

  logging.config.fileConfig("%s/logging.ini" % get_project_path())
  set_log_level()

  conn = Connector(os.getenv("DB_USER"), os.getenv("DB_PASSWORD"), os.getenv("DB_HOST"), os.getenv("DB_PORT"))
  actv_companies = ActiveCompanies(db_connector=conn)

  # Active companies validation
  actv_companies.check_active_companies()
Exemplo n.º 5
0
def write_main_header(html_document: HtmlDocument) -> None:
    """
    Write main header of report_html file
    :param html_document:
    :return:
    """
    html_document.open_html_document()
    write_head(html_document)
    html_document.open_body()
    logo_kununu = convert_path_image_64(get_project_path() +
                                        cons.path_image_kununu)
    html_document.insert_image(logo_kununu,
                               class_txt="\"spacer--xs\"",
                               height=51,
                               width=224)
Exemplo n.º 6
0
    def open_client():
        """
        Open client for google service
        :return: protocol open
        """

        credentials_path = get_project_path() + '/keys/credentials.json'

        if not is_dev_env():
            credentials_path = os.getenv("GOOGLE_NLP_CREDENTIALS")

        google_client = language.LanguageServiceClient(
            credentials=service_account.Credentials.from_service_account_file(
                credentials_path))

        return google_client
Exemplo n.º 7
0
import argparse
import logging.config

import os

import newrelic.agent

from sentiment_analysis.src.managers.topics_manager import TopicsManager
from utils.data_connection.api_data_manager import APISourcesFetcher
from utils.gcloud.nlp_client import NLPGoogleClient
from utils.utilities import get_last_week, set_log_level, get_project_path
from utils.data_connection.source_manager import Connector
from utils.data_connection.factory.redis_factory import RedisFactory

logging.config.fileConfig("%s/logging.ini" % get_project_path())
set_log_level()
logger = logging.getLogger()


@newrelic.agent.background_task()
def task():
    parser = argparse.ArgumentParser(
        description='Run sentiment analysis for topics')
    parser.add_argument('--year_start',
                        type=int,
                        help='year start of the topics')
    parser.add_argument('--week_start',
                        type=int,
                        help='week start of the topics')
    parser.add_argument('--year_end', type=int, help='year end of the topics')
    parser.add_argument('--week_end', type=int, help='week end of the topics')