2023-02-02 03:34:05 +00:00
|
|
|
import logging
|
|
|
|
|
2023-02-02 04:01:31 +00:00
|
|
|
from .config import config, DATA_SET_SIZE
|
|
|
|
from .database import mongo_reviews_collection_from_config, get_reviews_dataset_polar, get_reviews_dataset_uniform
|
2023-02-02 15:03:07 +00:00
|
|
|
from .analysis.vanilla import VanillaReviewSA, polar_categorizer, stars_categorizer
|
2023-02-02 03:34:05 +00:00
|
|
|
from .analysis.potts import PottsReviewSA
|
2023-02-01 16:46:25 +00:00
|
|
|
from .log import install_log_handler
|
2023-02-01 03:20:09 +00:00
|
|
|
|
2023-02-02 03:34:05 +00:00
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2023-02-01 01:33:42 +00:00
|
|
|
|
|
|
|
def main():
|
2023-02-02 01:56:37 +00:00
|
|
|
with mongo_reviews_collection_from_config() as reviews:
|
2023-02-02 04:01:31 +00:00
|
|
|
reviews_polar_training = get_reviews_dataset_polar(collection=reviews, amount=DATA_SET_SIZE.__wrapped__)
|
|
|
|
reviews_polar_evaluation = get_reviews_dataset_polar(collection=reviews, amount=DATA_SET_SIZE.__wrapped__)
|
|
|
|
reviews_uniform_training = get_reviews_dataset_uniform(collection=reviews, amount=DATA_SET_SIZE.__wrapped__)
|
|
|
|
reviews_uniform_evaluation = get_reviews_dataset_uniform(collection=reviews, amount=DATA_SET_SIZE.__wrapped__)
|
2023-02-02 01:56:37 +00:00
|
|
|
|
2023-02-02 15:03:07 +00:00
|
|
|
vanilla_polar = VanillaReviewSA(categorizer=polar_categorizer)
|
2023-02-02 04:01:31 +00:00
|
|
|
vanilla_polar.train(reviews_polar_training)
|
|
|
|
log.info("Vanilla polar evaluation results: %s", vanilla_polar.evaluate(reviews_polar_evaluation))
|
|
|
|
|
|
|
|
potts_polar = PottsReviewSA()
|
|
|
|
potts_polar.train(reviews_polar_training)
|
|
|
|
log.info("Potts polar evaluation results: %s", potts_polar.evaluate(reviews_polar_evaluation))
|
|
|
|
|
2023-02-02 15:03:07 +00:00
|
|
|
vanilla_uniform = VanillaReviewSA(categorizer=stars_categorizer)
|
2023-02-02 04:01:31 +00:00
|
|
|
vanilla_uniform.train(reviews_uniform_training)
|
|
|
|
log.info("Vanilla uniform evaluation results: %s", vanilla_polar.evaluate(reviews_polar_evaluation))
|
|
|
|
|
|
|
|
while True:
|
|
|
|
print(vanilla_uniform.use(input("> ")))
|
2023-02-02 03:34:05 +00:00
|
|
|
|
2023-02-01 01:33:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-02-01 16:46:25 +00:00
|
|
|
install_log_handler()
|
|
|
|
config.proxies.resolve()
|
2023-02-01 01:33:42 +00:00
|
|
|
main()
|