예제 #1
0
configuration = load_configuration()

search_engine = create_search_engine_interface(
    configuration.host, configuration.gazette_index
)

gazettes_query_builder = create_gazettes_query_builder(
    configuration.gazette_content_field,
    configuration.gazette_content_exact_field_suffix,
    configuration.gazette_publication_date_field,
    configuration.gazette_territory_id_field,
)
gazettes_search_engine_gateway = create_gazettes_data_gateway(
    search_engine, gazettes_query_builder, configuration.gazette_index
)
gazettes_interface = create_gazettes_interface(gazettes_search_engine_gateway)

themed_excerpts_query_builder = create_themed_excerpts_query_builder(
    configuration.themed_excerpt_content_field,
    configuration.themed_excerpt_content_exact_field_suffix,
    configuration.themed_excerpt_publication_date_field,
    configuration.themed_excerpt_territory_id_field,
    configuration.themed_excerpt_entities_field,
    configuration.themed_excerpt_subthemes_field,
    configuration.themed_excerpt_embedding_score_field,
    configuration.themed_excerpt_tfidf_score_field,
    configuration.themed_excerpt_fragment_size,
    configuration.themed_excerpt_number_of_fragments,
)
themed_excerpts_search_engine_gateway = create_themed_excerpts_data_gateway(
    search_engine, themed_excerpts_query_builder
예제 #2
0
 def test_create_gazettes_interface_should_return_a_valid_interface_object(self):
     interface = create_gazettes_interface(
         DummyDataGateway(), DummyDatabaseGateway()
     )
     self.assertIsInstance(interface, GazetteAccessInterface)
예제 #3
0
 def test_create_gazettes_interface_with_invalid_database_gateway_should_fail(self):
     interace = create_gazettes_interface(
         DummyDataGateway(), InvalidDatabaseGateway()
     )
import os

import uvicorn

from api import app, set_gazette_interface
from gazettes import create_gazettes_interface
from database import create_database_data_mapper

database = os.environ["POSTGRES_DB"]
user = os.environ["POSTGRES_USER"]
password = os.environ["POSTGRES_PASSWORD"]
host = os.environ["POSTGRES_HOST"]
database_gateway = create_database_data_mapper(database, user, password, host)
gazettes_interface = create_gazettes_interface(database_gateway)
set_gazette_interface(gazettes_interface)

uvicorn.run(app, host="0.0.0.0", port=8080)