Exemple #1
0
def test_item1() :
    """ Testing for item
    """
    assert Item(value="value") == Item(value="value")
    assert Item(value="value") != Item(value="not value")

    item = Item(value="val", string="str", integer="int")

    # assert str(item) == "int str val"
    assert set(item.values) == {'int', 'str', 'val'}
    assert set(item.keys) == {'integer', 'string', 'value'}
Exemple #2
0
def test_pipeline1():
    """ Testing for pipeline
    """
    pipeline = Pipeline()
    items = [[], []]
    for item, v in zip(pipeline.capture_item(), list(range(10))):
        items[v % 2].append(item)
        assert item == Item(value=str(v))

    for dump in items:
        pipeline.dress_item(dump)
Exemple #3
0
 def capture_item(self):
     for text, keyword in zip(test_text, test_keyword):
         with codecs.open('tests/data/' + text, 'r', 'utf-8') as f:
             content = f.read()
         yield Item(title=text, content=content, keyword=keyword, date='')
Exemple #4
0
 def capture_item(self):
     for v in range(10):
         yield Item(value=str(v))
Exemple #5
0
 def capture_item(self):
     for idx, row in self.frame.iterrows():
         yield Item(title=row.title,content=row.content,keyword=row.actor,date=row.date)
Exemple #6
0
 def dump(self, iid: itemID) -> Item:
     items, vectors, counters = list(map(list, list(zip(*self.__c.dumps[iid]))))
     return Item(**{e: f(self, items, vectors, counters) for e, f in list(extractable.s.items())})