Commit f07f6264 authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk

Search tag by split temp tags

parent 8992ba05
......@@ -19,19 +19,20 @@ class MLDataMaker:
return tags.split(replace)
return tags.split(char)
def is_tag_similar(self, tags, news_tags):
def is_tag_similar(self, tag, news_tag):
count = 0
for i in tags:
if i.lower() in news_tags.lower():
for i in tag:
if i.lower() in news_tag.lower():
count += 1
if count == 0 or count < len(tags) // 2:
if count == 0 or count < len(tag) // 2 + 1:
return False
else:
return True
def make_ml_data(self, news):
ml_data = list()
for news_tag in news.tags.split(','):
for i in self.tags:
if self.is_tag_similar(i.tags, news.tags):
if self.is_tag_similar(i.tags, news_tag):
ml_data.append([news.id, i.id])
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