This release is a pre-release and may not be stable for production use.
Similar articles for Pelican
A lightweight Pelican plugin to provide a list of similar articles, related to one another by a similarity calculation based on their tags.
Installation
This plugin can be installed via:
pip install pelican-similar-articles-light
Template integration
Minimal version:
{% if article.similar_articles %}
<ul>
{% for sub_article in article.similar_articles %}
<li><a href="{{ SITEURL }}/{{ sub_article.url }}">{{ sub_article.title }}</a></li>
{% endfor %}
</ul>
{% endif %}
With bootstrap and translations support:
{% if article.similar_articles %}
<div class="alert alert-warning text-left" role="alert">
<p><strong>{{ _("You might be interested in") ~ ' ' ~ ngettext("the following article:", "the following articles:", article.similar_articles|count) }}</strong></p>
<ul>
{% for sub_article in article.similar_articles %}
<li><a href="{{ SITEURL }}/{{ sub_article.url }}" class="alert-link">{{ sub_article.title }}</a></li>
{% endfor %}
</ul>
</div>
{% endif %}
Pelican configuration
Enable the plugin in pelicanconf.py:
PLUGINS = [..., 'similar_articles_light']
You you can customize some features of the plugin.
You will find below the default values which can be overwritten by a statement
in the pelicanconf.py file.
The maximum number of similar articles:
SIMILAR_ARTICLES_MAX_COUNT = 2
The the minimal score to consider an article as similar:
SIMILAR_ARTICLES_MIN_SCORE = 0.0001
About the implementation
The plugin computes a similarity score based on the tags of the articles. It consists in building a global bag of words (dictionary), and a bag of words for each article, representing this article as an n-dimensional vector.
The terms are weighted using the TF-IDF method, according to their rareness within the corpus formed by all the tags of the site.
The vector of each article is then compared to all the others via the calculation of the cosine simiarity widely used in text mining. It consists in determining the angle formed between 2 vectors. The maximum similarity obtained is 1 (the documents have all their important tags in common), while the minimum is 0 (the documents have no tag in common).
Comparison with the plugin Similar Posts
The Similar Posts plugin uses exactly the same technique, I don't think you will have any difference in the the result obtained. However, the dependencies used are a bit too large and somewhat oversized for the intended purpose: a few words (tags) summarizing an article among a handful of articles from a Pelican blog.
The implementation of Similar Articles Light is in pure Python. In any case, reinventing the wheel should never be a reason to sell a technology; therefore please consider this plugin as a proof of concept of a few dozen lines of code, fully functional and without dependencies; so probably slightly faster to run than Similar Posts.
License
This program is released under the GNU Affero General Public License.
Metadata
Release files for pelican-similar-articles-light 1.0.1.dev0
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 |
|---|---|---|---|---|
| pelican_similar_articles_light-1.0.1.dev0.tar.gz | 17.8 kB | Without provenance | Details for pelican_similar_articles_light-1.0.1.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pelican_similar_articles_light-1.0.1.dev0-py3-none-any.whl | Python 3 | none | any | Details for pelican_similar_articles_light-1.0.1.dev0-py3-none-any.whl |
Total release size: 36.2 kB
Release files / pelican_similar_articles_light-1.0.1.dev0.tar.gz
| Download URL | pelican_similar_articles_light-1.0.1.dev0.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad6e40add3e5fa76ccc5725cfda3b7123e78878bfdb41b27d1d643457cb538d3
|
|
BLAKE2b-256 checksum How to use checksums |
4bcf181cc620b5867a94227640f29e727157bb0adbaf510c1dfd6b7f980b4810
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / pelican_similar_articles_light-1.0.1.dev0-py3-none-any.whl
| Download URL | pelican_similar_articles_light-1.0.1.dev0-py3-none-any.whl |
|---|---|
| Size | 18.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b748898baccc23239dfcc09bb80ef27b05fbeed4ad15fdbc3522a93fbf1bf519
|
|
BLAKE2b-256 checksum How to use checksums |
0ffa90d2fbe3fd6530fd4c1d65c7f2f6b4851d8d00f301213438d03b39d33bab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for pelican-similar-articles-light 1.0.1.dev0
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.