main.py 644 Bytes
Newer Older
20200519040 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
import os, sys
import json
from collections import defaultdict
from business import BusinessManager
import model


def main():
	mgr = BusinessManager('data/')

	train_data, test_data = mgr.generate_model_data()

	feature_builder = model.FeatureBuilder('tfidf')

	X_train, y_train, X_test, y_test = feature_builder.get_feature(train_data, test_data)

	lrmodel = model.LinearModel()
	lrmodel.train(X_train, y_train)
	lrmodel.save(model_path)

	mgr.set_sentiment_model(lrmodel)

	business_ids = get_business_ids()
	for bid in business_ids:
		summary = mgr.aspect_based_summary(business_ids)
		print(summary)

if __name__ == "__main__":
	main()