lilingxi01's picture
chore: init commit.
25eab98
import logging
import bloark
from grimm import clean_syntax # Need to install separately.
# Define a modifier profile.
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__':
# Create a modifier instance with 8 processes (CPUs) and INFO-level logging.
modifier = bloark.Modifier(
output_dir='./output',
num_proc=8, # TODO: Adjust accordingly!
log_level=logging.INFO
)
# Preload all files from the input directory (original warehouses).
modifier.preload('./input')
# Add the modifier profile to the modifier instance.
# You can even add multiple profiles to the same modifier.
modifier.add_profile(MyModifier())
# Start modifying the warehouses (this command will take a long time).
modifier.start()