class article: def __init__(self, title="", content=""): self.title = title self.content = content self.keywords = [] self.weight = 0.0 def jsonify(self): d = {} d["title"] = self.title d["content"] = self.content d["keywords"] = self.keywords d["weight"] = self.weight return d def __str__(self): return str(self.jsonify()) def __repr__(self): return str(self.jsonify()) def summary(self): return "{0:20.20}, {1:5.5}, {2}".format(self.title, self.weight, self.keywords) def replace_keywords(self, keywords=[]): self.keywords = keywords def get_content(self): return self.content class article_list: def __init__(self, articles: list = []): self.list = articles def sort(self): sorted(self.list, key=compare(lambda item1, item2: item1.weight < item2.weight)) def append(self, art: article): self.list.append(art) def __str__(self): return str("\n".join([x.summary() for x in self.list]))