Sort related nodes in block views based on a score calculated with common vocabulary
To place the php code to calculate the score there are several approaches:


Add an extra field for the score to your content type and calculate it in submit or
presave.
Add a custom views field plugin:
http://enzolutions.com/articles/2015/10/11/how-to-include-php-code-in-drupal-8-views/ or a custom sort plugin: https://chromatichq.com/blog/create-custom-views-sort-plugin-drupal-8
Use the module Computed Field.


With (1) you save the value in the database. This is best for calculations that don't change after saving the content.

A custom views plugin (2) is more dynamic and needs no space in the database, but it has to be recalculated each time.

The extra module (3) can do both, but it is not ready for production, still in alpha. If you read the linked how-to for views field plugins in (2) there are some good points that in D8 plugins are often more powerful than contrib modules to extend Drupal with custom php code.