Commit f07f6264 authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk

Search tag by split temp tags

parent 8992ba05
...@@ -19,19 +19,20 @@ class MLDataMaker: ...@@ -19,19 +19,20 @@ class MLDataMaker:
return tags.split(replace) return tags.split(replace)
return tags.split(char) return tags.split(char)
def is_tag_similar(self, tags, news_tags): def is_tag_similar(self, tag, news_tag):
count = 0 count = 0
for i in tags: for i in tag:
if i.lower() in news_tags.lower(): if i.lower() in news_tag.lower():
count += 1 count += 1
if count == 0 or count < len(tags) // 2: if count == 0 or count < len(tag) // 2 + 1:
return False return False
else: else:
return True return True
def make_ml_data(self, news): def make_ml_data(self, news):
ml_data = list() ml_data = list()
for i in self.tags: for news_tag in news.tags.split(','):
if self.is_tag_similar(i.tags, news.tags): for i in self.tags:
ml_data.append([news.id, i.id]) if self.is_tag_similar(i.tags, news_tag):
return ml_data ml_data.append([news.id, i.id])
\ No newline at end of file return ml_data
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment