View Single Post
Old 02-15-2021, 03:55 AM   #7
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,201
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
As davidfor said, you will need a combination of a tag-like column + composite column:
  • Create a new tag-like custom column called #recommendations. This column should contain the recommendations for the book. e.g Bill Gates, John ...
  • Create a composite column called #score. Set the sorting of this column to numbers. Use the following template for this column:
    Code:
    program:
        total = 0;
        default_score = 1;
        scores = 'Bill Gates:5,Naval Ravicant:10';
        for rec in '#recommendations':
            increment = ifempty(select(scores, rec), default_score);
            total = add(total, increment)
        rof;
        total
    This template should calculate the total score for you in the new composite column.

    Note that the line in blue is a comma separated pairs in the form of source:score. You must edit this to suit your needs. Every time you have a new source, you need to update this line in the template.

    The line in green is the score assigned to sources with no defined score e.g random people from the internet. Edit the value to suit your needs.

Note: You will need a recent version of calibre for this template to work. It uses a for loop which was introduced recently and not available on older versions.

Also note that the recommendations are case-sensitive. So: Bill Gates is not the same as bill gates.

Last edited by capink; 02-15-2021 at 08:34 AM.
capink is offline   Reply With Quote