niteru
This package provides a set of functions to measure the similarity between HTMLs.
Note: This is a fork of html-similarity.
Key differences
- Type hints
- All functions have proper type hints
- Dependency free
- Works along with plain Python
Installation
pip install niteru
How it works
Structural Similarity
Uses sequence comparison of the html tags to compute the similarity.
We do not implement the similarity based on tree edit distance because it is slower than sequence comparison.
Style Similarity
Extracts CSS classes of each html document and calculates the jaccard similarity of the sets of classes.
Joint Similarity (Structural Similarity and Style Similarity)
The joint similarity metric is calculated as::
k * structural_similarity(html1, html2) + (1 - k) * style_similarity(html1, html2)
All the similarity metrics take values between 0.0 and 1.0.
Recommendations for joint similarity
Using k=0.3 gives better results. The style similarity gives more information about the similarity rather than the structural similarity.
Examples
Here is an example:
html1 = '''
<h1 class="title">First Document</h1>
<ul class="menu">
<li class="active">Documents</li>
<li>Extra</li>
</ul>
'''
html2 = '''
<h1 class="title">Second document Document</h1>
<ul class="menu">
<li class="active">Extra Documents</li>
</ul>
'''
from niteru import style_similarity, structural_similarity, similarity
style_similarity(html1, html2) # => 1.0
structural_similarity(html1, html2) # => 0.8571428571428571
similarity(html1, html2) # => 0.9285714285714286
Metadata
Release files for niteru 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| niteru-0.2.1.tar.gz | 4.8 kB | Without provenance | Details for niteru-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| niteru-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for niteru-0.2.1-py3-none-any.whl |
Total release size: 11.2 kB
Release files / niteru-0.2.1.tar.gz
| Download URL | niteru-0.2.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2487f3a6e7bb75629111ecef9fa64207f1e92599c933d34defce47c94227013
|
|
BLAKE2b-256 checksum How to use checksums |
546603dd8aa3bf879f5791f8880aee3e390e7d598d26992546d76ab6a05f43f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.6 Darwin/20.6.0
|
Release files / niteru-0.2.1-py3-none-any.whl
| Download URL | niteru-0.2.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b7518cfe7ce7328690d6b2fec96c586b8c0a44aed03b3293112a194e2fd8c6c
|
|
BLAKE2b-256 checksum How to use checksums |
991bb034bfce9b37df587115a186800490c76c1c10a410f4d8693e5b3dfa0087
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.11 CPython/3.8.6 Darwin/20.6.0
|
Security for niteru 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.