Changes

Jump to navigation Jump to search
Line 3: Line 3:  
To allow users to get personalized search results, mobile and web apps can use our [https://wiki.openfoodfacts.org/Client-side_libraries_for_personalized_product_filtering_and_ranking#Flutter_library_.2F_Dart_package Flutter] or [https://wiki.openfoodfacts.org/Client-side_libraries_for_personalized_product_filtering_and_ranking#Javascript_library Javascript] libraries to filter and rank products according to user preferences. The filtering and ranking is done on the client side so that user personal preferences are kept on the client.
 
To allow users to get personalized search results, mobile and web apps can use our [https://wiki.openfoodfacts.org/Client-side_libraries_for_personalized_product_filtering_and_ranking#Flutter_library_.2F_Dart_package Flutter] or [https://wiki.openfoodfacts.org/Client-side_libraries_for_personalized_product_filtering_and_ranking#Javascript_library Javascript] libraries to filter and rank products according to user preferences. The filtering and ranking is done on the client side so that user personal preferences are kept on the client.
   −
Client-side libraries for personalized product filtering and ranking is the 3rd of the 4 sub-tasks of the [[Project:Personalized_Search]] funded by the NGI0 Discovery Fund managed by NlNet.
+
''Client-side libraries for personalized product filtering and ranking is the 3rd of the 4 sub-tasks of the [[Project:Personalized_Search]] funded by the NGI0 Discovery Fund managed by NlNet.''
    
= Overview =
 
= Overview =
Line 17: Line 17:  
= Personalized product filtering and ranking =
 
= Personalized product filtering and ranking =
   −
This section presents the general principles used to do personalized client-side product filtering and ranking.
+
This section presents the general principles and algorithms used to do personalized client-side product filtering and ranking.
   −
Apps can implement those principles directly or use the Flutter or Javascript library.
+
Apps can implement those principles and algorithms directly using the Open Food Facts API, or simply use the Flutter or Javascript library.
    
== User preferences ==
 
== User preferences ==
    
The user preferences are stored locally on the client (mobile app or browser).
 
The user preferences are stored locally on the client (mobile app or browser).
 +
 +
=== Available preference attributes and localized descriptions ===
 +
 +
Apps can query the Open Food Facts API to retrieve all the different preference attributes that are supported by Open Food Facts. The "lc" (language code) parameter can be used to retrieve the attribute names and descriptions in a specific language.
 +
 +
e.g. https://world.openfoodfacts.org/api/v2/attribute_groups?lc=en : list of all available preference attributes in English
 +
 +
The possible preference values for each attributes can also be retrieved through the API:
 +
 +
e.g. https://world.openfoodfacts.org/api/v2/preferences?lc=en : list of all possible preferences values in English
    
=== User preferences format ===
 
=== User preferences format ===
Line 31: Line 41:  
The preferences are saved in name / value pairs (hash table / associative array) of attribute ids mapping to string values.
 
The preferences are saved in name / value pairs (hash table / associative array) of attribute ids mapping to string values.
   −
The list of attribute ids will be sent by the server, along with localized names, descriptions, warnings etc.
+
The list of attribute ids is sent by the server, along with localized names, descriptions, warnings etc.
    
String values:
 
String values:
Line 59: Line 69:  
== Product Attributes ==
 
== Product Attributes ==
   −
For each product, the server returns a match value for each attribute in a standardized format.
+
For each product in a set of search results, the server returns a match value for each attribute in a standardized format.
    
See [[Product Attributes]].
 
See [[Product Attributes]].
Line 65: Line 75:  
== Scoring ==
 
== Scoring ==
   −
On the client side, a library computes a score for each product returned by a search:
+
On the client side, the app (or a library) computes a score for each product returned by a search:
    
=== Input and output values ===
 
=== Input and output values ===
Line 91: Line 101:     
The openfoodfacts dart package has been extended to add support for the new [[Product Attributes]] created for the Personal Search project. It also contains functions to manage user preferences, and filter and rank products according to those preferences.
 
The openfoodfacts dart package has been extended to add support for the new [[Product Attributes]] created for the Personal Search project. It also contains functions to manage user preferences, and filter and rank products according to those preferences.
 +
 +
== Links ==
    
* openfoodfacts Dart package on pub.dev: https://pub.dev/packages/openfoodfacts
 
* openfoodfacts Dart package on pub.dev: https://pub.dev/packages/openfoodfacts
Line 104: Line 116:  
= Javascript library =
 
= Javascript library =
   −
The Javascript library can be used on websites and browser extensions. It is used in particular on the [https://world.openfoodfacts.org Open Food Facts website] to display personalized search results.
+
The Javascript library can be used on websites and browser extensions. It has functions to allow users to select their preferences and save them locally on the browser, and functions to match, filter and rank search results according to the saved preferences.
 +
 
 +
It is used in particular on the [https://world.openfoodfacts.org Open Food Facts website] to display personalized search results:
 +
 
 +
== Interface to select user preferences and save them locally on the browser ==
 +
 
 +
[[File:Personal-search-web-preferences.png]]
 +
 
 +
== Personalized search results filtered and ranked according to locally saved user preferences ==
 +
 
 +
[[File:Personal-search-web-results.png]]
 +
 
 +
== Links ==
    
* library to display, select and store user preferences on the browser using localstorage: https://github.com/openfoodfacts/openfoodfacts-server/blob/main/html/js/product-preferences.js
 
* library to display, select and store user preferences on the browser using localstorage: https://github.com/openfoodfacts/openfoodfacts-server/blob/main/html/js/product-preferences.js

Navigation menu