Skip to main content

warc2summary

PyPI Status Python Version License

Read the documentation at https://warc2summary.readthedocs.io/ Tests Codecov

pre-commit Black

Features

Implementation of Heuristics to process WARC Files

Requirements

  • Python 3.9>

Installation

You can install warc2summary via [pip] from [PyPI]:

pip install warc2summary

Usage

There exists 3 parts to this library: warc_processor, heuristics, pipeline

WARC Processor

This module converts WARC Files to a Pandas DataFrame. It uses WARCIO as the processing engine.

from warc2summary import warc_processor
#process WARC Files Directly
warc_processor.process_warc_files(folder_path, max_workers=4)

Heuristics

This module applies the 3 heuristics developed

Heuristic 1: Takes the about page of the website, else take shortest url(likely to be main page)

Heuristic 2: Takes the shortest url

Heuristic 3: Takes shortest url and applies a Regex Filter

from warc2summary import heuristics
#process dataframe
heuristics.heuristics_1(dataframe)
from warc2summary import heuristics
#process dataframe
heuristics.heuristics_2(dataframe)
from warc2summary import heuristics
#process dataframe
heuristics.heuristics_3(dataframe)

The dataframe must contain the url and the web text content

This module transforms the dataframe for processing using LLMs reducing costs by reducing number of tokens needed

Feel free to contribute new heuristics

pipeline

This module merges the previous 2 modules and joins it with a ground truth dataset for llm evaluation. Only OpenAI api supported for now. This code requires a human labelled dataset.

To combine all 3 parts and replicate our findings

from warc2summary import pipeline
#process WARC Files Directly
pipeline.execute_pipeline(warc_df,human_df,prompt,heuristic,max_tokens=1000,temperature=0.5,top_p=0.95,frequency_penalty=0.0,presence_penalty=0.0,model="gpt-4o",debug=False)

To perform batch inference

from warc2summary import pipeline
pipeline.batch_prompt(df, prompt ,max_tokens=150,temperature=0.5,top_p=0.95,frequency_penalty=0.0,presence_penalty=0.0,model="gpt-4o",debug=False)

Issues

If some module is not found, please try pip installing the package and refreshing Please post a issue on github if something goes wrong

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, warc2summary is free and open source software. This package is brought to you by the National Library Board. By using any part of this package, you agree to not hold NLB or the developers liable for any damages, physical or otherwise in perpetuity throughout the universe

Issues

If you encounter any problems, please [file an issue] along with a detailed description.

Metadata

Release files for warc2summary 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for warc2summary 0.0.12
File Size Uploaded
warc2summary-0.0.12.tar.gz 14.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for warc2summary 0.0.12
File Interpreter ABI Platform
warc2summary-0.0.12-py3-none-any.whl Python 3 none any Details

Total release size: 29.3 kB

Release files / warc2summary-0.0.12.tar.gz

Download URL warc2summary-0.0.12.tar.gz
Size 14.4 kB
Tags Source
SHA-256 checksum
How to use checksums
603c5259de82a9bb9b42797ce45d0684f3a20a4b555ae1f0edd6e8b35aad0b79
BLAKE2b-256 checksum
How to use checksums
92c3ff944d0f6928a66aec0b00f9a35a7180660a90af19a13a67cae47a0cd478
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.7 Windows/10

Release files / warc2summary-0.0.12-py3-none-any.whl

Download URL warc2summary-0.0.12-py3-none-any.whl
Size 14.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39f4fd833b64a780a4e194f57e1a4455614a043b42f1f203c8150ebd8c00f123
BLAKE2b-256 checksum
How to use checksums
ae4edf7f8eaa9eea2d1558ab6a097fd7362428dd947ea7f58554540492640cda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.7 Windows/10

Release history Release notifications | RSS feed

This release

0.0.12 This release

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page