Skip to content

Commit

Permalink
Switch from beautifultable to tabulate
Browse files Browse the repository at this point in the history
Signed-off-by: Vartan Benohanian <[email protected]>
  • Loading branch information
vartanbeno committed Dec 4, 2018
1 parent ae6d891 commit 756aaad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 13 deletions.
Binary file modified Project Report.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The following Python packages are required to run the program:
- [scrapy](https://scrapy.org/)
- [nltk](https://pypi.org/project/nltk/)
- [afinn](https://pypi.org/project/afinn/)
- [beautifultable](https://pypi.org/project/beautifultable/)
- [tabulate](https://pypi.org/project/tabulate/)

Click [here](requirements.txt) for the specific versions of the packages used for this project.

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
scrapy==1.5.1
nltk==3.3
afinn==0.1
beautifultable==0.5.3
tabulate==0.8.2
14 changes: 3 additions & 11 deletions src/classes/query.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from helpers import clean_terms, afinn, sqrt, PAGES, TOTAL_AFINN, SENTIMENT, COSINE_SIMILARITY, AFINN_SCORE, URL
from classes.tf_idf import TFIDF

from beautifultable import BeautifulTable
from tabulate import tabulate

from abc import abstractmethod

Expand All @@ -27,9 +27,7 @@ def __init__(self, index, stats, remove_stopwords=False):
self.results = []
self.results_with_cosine_similarity = {}

self.table = BeautifulTable(max_width=140, default_alignment=BeautifulTable.ALIGN_LEFT)
self.table.column_headers = [COSINE_SIMILARITY, AFINN_SCORE, URL]
self.table.numeric_precision = 10
self.headers = [COSINE_SIMILARITY, AFINN_SCORE, URL]

@staticmethod
def ask_user():
Expand Down Expand Up @@ -122,11 +120,7 @@ def generate_results_table(self, rows):
:param rows: list of results
:return: None
"""
self.table.clear()
for row in rows:
self.table.append_row(row)

print(self.table)
print(tabulate(tabular_data=rows, headers=self.headers, tablefmt="fancy_grid", numalign="left", stralign="left"))

@abstractmethod
def execute(self, terms):
Expand Down Expand Up @@ -198,9 +192,7 @@ def execute(self, terms):
:return: list of pages containing all of the terms in the query (AND).
"""
self.original_terms = terms
print(self.original_terms)
self.terms = clean_terms(terms, self.remove_stopwords)
print(self.terms)
self.results_with_cosine_similarity = {}

lists_of_pages = self.get_pages()
Expand Down

0 comments on commit 756aaad

Please sign in to comment.