fishlib 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fishlib/__init__.py +94 -0
- fishlib/data/species_aliases.json +640 -0
- fishlib/data/standard_codes.json +571 -0
- fishlib/matcher.py +365 -0
- fishlib/parser.py +337 -0
- fishlib/reference/__init__.py +421 -0
- fishlib/species/__init__.py +283 -0
- fishlib/standards.py +324 -0
- fishlib-0.1.0.dist-info/METADATA +207 -0
- fishlib-0.1.0.dist-info/RECORD +15 -0
- fishlib-0.1.0.dist-info/WHEEL +5 -0
- fishlib-0.1.0.dist-info/licenses/LICENSE +21 -0
- fishlib-0.1.0.dist-info/top_level.txt +2 -0
- tests/__init__.py +1 -0
- tests/test_fishlib.py +297 -0
fishlib/__init__.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"""
|
|
2
|
+
fishlib - A Python library for parsing, standardizing, and comparing foodservice seafood products.
|
|
3
|
+
|
|
4
|
+
Created by Karen Morton
|
|
5
|
+
License: MIT
|
|
6
|
+
|
|
7
|
+
THE PROBLEM THIS SOLVES:
|
|
8
|
+
You need deep fish knowledge to know if a PMI comparison is accurate. A 6oz salmon
|
|
9
|
+
portion might be $4/lb more than industry - but that's because it's a center-cut
|
|
10
|
+
bias portion vs block-cut with tails. Without the right attributes, it looks like
|
|
11
|
+
you're overpriced when you're comparing apples to oranges.
|
|
12
|
+
|
|
13
|
+
THE GOAL:
|
|
14
|
+
Capture attributes correctly so ANYONE can trust the data without being a fish expert.
|
|
15
|
+
|
|
16
|
+
Example usage:
|
|
17
|
+
import fishlib
|
|
18
|
+
|
|
19
|
+
# Parse an item description
|
|
20
|
+
item = fishlib.parse("SALMON FIL ATL SKON DTRM 6OZ IVP")
|
|
21
|
+
print(item)
|
|
22
|
+
# {'species': 'Atlantic Salmon', 'form': 'FIL', 'skin': 'SKON',
|
|
23
|
+
# 'trim': 'D', 'size': '6OZ', 'pack': 'IVP'}
|
|
24
|
+
|
|
25
|
+
# Get comparison key for matching
|
|
26
|
+
key = fishlib.comparison_key(item)
|
|
27
|
+
print(key)
|
|
28
|
+
# 'SALMON|ATLANTIC|FIL|SKON|D|6OZ'
|
|
29
|
+
|
|
30
|
+
# Check if two items are comparable
|
|
31
|
+
result = fishlib.match("SALMON FIL ATL 6OZ", "Portico Salmon Fillet 6oz")
|
|
32
|
+
print(result['is_comparable']) # True
|
|
33
|
+
print(result['confidence']) # 0.92
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
__version__ = "0.1.0"
|
|
37
|
+
__author__ = "Karen Morton"
|
|
38
|
+
__license__ = "MIT"
|
|
39
|
+
|
|
40
|
+
from .parser import parse, parse_description
|
|
41
|
+
from .standards import (
|
|
42
|
+
standardize_form,
|
|
43
|
+
standardize_skin,
|
|
44
|
+
standardize_bone,
|
|
45
|
+
standardize_trim,
|
|
46
|
+
standardize_pack,
|
|
47
|
+
standardize_storage,
|
|
48
|
+
standardize_cut_style,
|
|
49
|
+
standardize_harvest,
|
|
50
|
+
standardize_origin,
|
|
51
|
+
standardize_size,
|
|
52
|
+
get_standard_code,
|
|
53
|
+
list_codes
|
|
54
|
+
)
|
|
55
|
+
from .matcher import (
|
|
56
|
+
comparison_key,
|
|
57
|
+
match,
|
|
58
|
+
is_comparable,
|
|
59
|
+
find_matches,
|
|
60
|
+
match_score
|
|
61
|
+
)
|
|
62
|
+
from . import species
|
|
63
|
+
from . import reference
|
|
64
|
+
|
|
65
|
+
__all__ = [
|
|
66
|
+
# Parser functions
|
|
67
|
+
'parse',
|
|
68
|
+
'parse_description',
|
|
69
|
+
|
|
70
|
+
# Standardization functions
|
|
71
|
+
'standardize_form',
|
|
72
|
+
'standardize_skin',
|
|
73
|
+
'standardize_bone',
|
|
74
|
+
'standardize_trim',
|
|
75
|
+
'standardize_pack',
|
|
76
|
+
'standardize_storage',
|
|
77
|
+
'standardize_cut_style',
|
|
78
|
+
'standardize_harvest',
|
|
79
|
+
'standardize_origin',
|
|
80
|
+
'standardize_size',
|
|
81
|
+
'get_standard_code',
|
|
82
|
+
'list_codes',
|
|
83
|
+
|
|
84
|
+
# Matcher functions
|
|
85
|
+
'comparison_key',
|
|
86
|
+
'match',
|
|
87
|
+
'is_comparable',
|
|
88
|
+
'find_matches',
|
|
89
|
+
'match_score',
|
|
90
|
+
|
|
91
|
+
# Submodules
|
|
92
|
+
'species',
|
|
93
|
+
'reference',
|
|
94
|
+
]
|