Skip to content

Commit

Permalink
add ability to use with keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
vtyushkevich committed Oct 9, 2023
1 parent 658981d commit d6cc62b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
16 changes: 11 additions & 5 deletions lab/check_proximity_one_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Read text from file and create tokens
"""
import sys

from settings import DICTIONARY, TOP_ELEMENT # pylint: disable=import-error

sys.path.append("../")
Expand All @@ -14,7 +15,9 @@
)
from analytics.functions import get_item_find_list # pylint: disable=wrong-import-position

FILENAME = "tokenize_one.txt"

SEPARATOR = "///"
FILENAME = "find_similar_one.txt"

print("Read data from file...")
with open(FILENAME, "r", encoding="utf-8") as f:
Expand All @@ -25,12 +28,15 @@
base_list_tokens = get_all_base_tokens(base_list)
print(f"{len(base_list_tokens)} items loaded")

one = line.strip()
one, two = line.split(SEPARATOR)
keywords_str = two.split()
keywords = dict(zip(keywords_str, [1]*len(keywords_str)))
print(keywords)
print(f"{one} has been loaded")
one_item = get_analog_token_by_name(one, id_shop=1)
for item in one_item:
find_list = get_item_find_list(item, base_list_tokens, DICTIONARY)
print("found:", find_list[TOP_ELEMENT].text)
find_list = get_item_find_list(item, base_list_tokens, DICTIONARY, keywords=keywords)
print("found:", find_list[TOP_ELEMENT].text, find_list[TOP_ELEMENT].cos, find_list[TOP_ELEMENT].key)
item_must_be = get_base_token_by_id(base_list, item.id_base_item)
print("must be:", item_must_be.text)
print("one_rating:", find_list.index(item) + 1)
print("one_rating:", find_list.index(item) + 1)
6 changes: 4 additions & 2 deletions lab/check_total_rating.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
else:
filename = str(datetime.now()).replace(":", "-") # pylint: disable=invalid-name
path = os.path.join("reports", filename)
with open(path, "w", encoding="utf-8") as f:
output = lambda s: f.write(f"{s}\n") # pylint: disable=unnecessary-lambda-assignment
f = open(path, 'w', encoding='utf-8')
output = lambda s: f.write(f'{s}\n')
# with open(path, "w", encoding="utf-8") as f:
# output = lambda s: f.write(f"{s}\n") # pylint: disable=unnecessary-lambda-assignment

output("CREATE REPORT")
get_report_total(rating_total, output=output)
Expand Down

0 comments on commit d6cc62b

Please sign in to comment.