Commit 7cf0a47e authored by Vasyl Bodnaruk's avatar Vasyl Bodnaruk

Add class for updating ML data

parent 6fa88c1d
from collections import namedtuple
Tags = namedtuple('Tag', 'id, tags')
News = namedtuple('News', 'id, tags')
class MLDataMaker:
def __init__(self, tags_list):
self.tags = [self.split_tags(i, ' /') for i in tags_list]
def split_tags(self, tags, char, replace=' '):
if len(char) > 1:
for i in char:
tags = tags.replace(i, replace)
return tags.split(replace)
return tags.split(char)
def is_tag_exist(self, tags, news_tags):
return any(tag in news_tags for tag in tags)
def make_ml_data(self, news, tags):
ml_data = list()
\ No newline at end of file
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