ocp5/doc/documentation.md

55 lines
1.6 KiB
Markdown
Raw Permalink Normal View History

2018-07-22 23:59:38 +00:00
Documentation
=============
2018-07-17 17:03:28 +00:00
2018-07-23 22:49:48 +00:00
## Created with
- `python 3.6.4 `
- `Requests`
2018-08-02 09:29:42 +00:00
- `PyMySQL`
2018-07-23 22:49:48 +00:00
2018-07-22 23:59:38 +00:00
## Installation
1. get the code : `git clone git@github.com:freezed/ocp5.git`
2. create a dedicated virtualenv : `python3 -m venv .venv; source .venv/bin/activate`
3. adds dependencies : `cd ocp5; pip install -r requirements.txt`
2018-07-23 22:49:48 +00:00
## Collects data
1. [OpenFoodFacts data uses more than 170 fields][92]. Here are those we keep localy :
```
2018-08-02 09:29:42 +00:00
code / _id
url
2018-07-23 22:49:48 +00:00
product_name
2018-08-02 09:29:42 +00:00
categories_tags
nutrition_grades
2018-07-23 22:49:48 +00:00
```
2018-08-02 09:29:42 +00:00
2. Physical Data Model
![-Physical Data Model-][96]
2018-08-08 20:32:31 +00:00
3. Edit [config.py](https://github.com/freezed/ocp5/blob/master/config.py)
4. Creates local MariaDB/MySQL : `python ./populate-.py`
2018-07-23 22:49:48 +00:00
## Use de CLI to get alternate product
2018-08-08 20:32:31 +00:00
1. run it : `python ./cli.py`
2. follow instructions :
2018-08-08 20:32:31 +00:00
1. Find a substitute product
2018-07-22 13:41:23 +00:00
2018-07-23 22:49:48 +00:00
1. Type the number corresponding to the product's category
2018-08-08 20:32:31 +00:00
2. Type the number corresponding to the choosen substitute product
2018-07-23 22:49:48 +00:00
3. The system shows you the product sheet :
- description
- the product link to [OpenFoodFacts][91] website
2018-08-08 20:32:31 +00:00
4. Decide if you want to save the substitute product in DB
2018-07-22 13:41:23 +00:00
2018-08-08 20:32:31 +00:00
2. Retrieve saved substitutes
2018-07-22 13:41:23 +00:00
2018-07-23 22:49:48 +00:00
[91]: https://world.openfoodfacts.org/ "OpenFoodFacts project"
[92]: https://world.openfoodfacts.org/data/data-fields.txt "OpenFoodFacts field list"
[93]: https://static.openfoodfacts.org/data/en.openfoodfacts.org.products.csv "CSV Data Export"
[94]: https://world.openfoodfacts.org/data "OpenFoodFacts data page"
[95]: https://github.com/freezed/ocp5/blob/master/create-db.sql
[96]: https://raw.githubusercontent.com/freezed/ocp5/master/doc/pdm.png "Image of the physical data model"