|
import logging |
|
import bloark |
|
from grimm import clean_syntax |
|
|
|
|
|
|
|
class MyModifier(bloark.ModifierProfile): |
|
def block(self, content: dict, metadata: dict): |
|
text_content = content['text']['#text'] |
|
text, external_links, internal_links, images = clean_syntax(text_content) |
|
new_content = { |
|
"article_id": content["article_id"], |
|
"revision_id": content["revision_id"], |
|
"timestamp": content["timestamp"], |
|
"clean_text": text, |
|
"external_links": external_links, |
|
"internal_links": internal_links, |
|
"images": images, |
|
} |
|
return new_content, metadata |
|
|
|
|
|
if __name__ == '__main__': |
|
|
|
modifier = bloark.Modifier( |
|
output_dir='./output', |
|
num_proc=8, |
|
log_level=logging.INFO |
|
) |
|
|
|
|
|
modifier.preload('./input') |
|
|
|
|
|
|
|
modifier.add_profile(MyModifier()) |
|
|
|
|
|
modifier.start() |
|
|
|
|