File size: 4,589 Bytes
e5de092
 
d93f20c
1c8b854
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d93f20c
1c8b854
 
e5de092
 
 
 
4edd87e
e5de092
 
4edd87e
 
 
e5de092
4edd87e
 
1c28270
4edd87e
 
 
 
d93f20c
e5de092
 
 
 
 
 
 
 
 
 
 
 
 
 
1c8b854
e5de092
 
 
 
 
d93f20c
e5de092
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d93f20c
e5de092
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a288ad
d93f20c
e5de092
 
1c8b854
e5de092
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d93f20c
 
e5de092
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
from utils import clean_word

def generic_template(input_word, cleaned_word=None, similarity_score=None, confidence_score=None, similar_words=None, is_food=None, food_nonfood_score=None, dictionary_word=None, sr_legacy_food_category=None, wweia_category=None, dry_matter_content=None, water_content=None, leakage=None, specificity=None):
    if cleaned_word is None:
        cleaned_word = clean_word(input_word)

    return {
        'input_word': input_word, 
        'cleaned_word': cleaned_word,
        'similarity_score': similarity_score, 
        'confidence_score': confidence_score,
        'similar_words': similar_words,
        'is_food': is_food,
        'food_nonfood_score': food_nonfood_score,
        'dictionary_word': dictionary_word,
        'sr_legacy_food_category': sr_legacy_food_category,
        'wweia_category': wweia_category,
        'dry_matter_content': dry_matter_content,
        'water_content': water_content,
        'leakage': leakage,
        'specificity': specificity
    }

def empty_template(input_word, cleaned_word=None):
    if cleaned_word is None:
        cleaned_word = clean_word(input_word)

    return {
        'input_word': input_word, 
        'cleaned_word': cleaned_word,
        'similarity_score': None, 
        'confidence_score': None,
        'similar_words': None,
        'is_food': None,
        'food_nonfood_score': None,
        'dictionary_word': None,
        'sr_legacy_food_category': None,
        'wweia_category': None,
        'dry_matter_content': None,
        'water_content': None,
        'leakage': None,
        'specificity': None
    }

def usda_template(input_word, cleaned_word=None):
    if cleaned_word is None:
        cleaned_word = clean_word(input_word)

    return {
        'input_word': input_word, 
        'cleaned_word': cleaned_word,
        'dictionary_word': 'USDA Food Item', 
        'similarity_score': 1.0, 
        'confidence_score': 1.0, 
        'similar_words': None,
        'is_food': True,
        'food_nonfood_score': 1.0,
        'sr_legacy_food_category': 'Government Donation (Not Counted)',
        'wweia_category': 'Government Donation (Not Counted)',
        'dry_matter_content': None,
        'water_content': None,
        'leakage': None,
        'specificity': None
    }

def nonfood_template(input_word, cleaned_word=None, food_nonfood_score=None, similar_words=None):
    if cleaned_word is None:
        cleaned_word = clean_word(input_word)

    return {
        'input_word': input_word,
        'cleaned_word': cleaned_word,
        'similarity_score': None, 
        'confidence_score': None,
        'similar_words': similar_words,
        'is_food': False,
        'food_nonfood_score': food_nonfood_score,
        'dictionary_word': 'Non-Food Item',
        'sr_legacy_food_category': 'Non-Food Item',
        'wweia_category': 'Non-Food Item',
        'dry_matter_content': 0,
        'water_content': 0,
        'leakage': 0,
        'specificity': None
    }

def heterogeneous_template(input_word, cleaned_word=None):
    if cleaned_word is None:
        cleaned_word = clean_word(input_word)
    
    return {
        'input_word': input_word, 
        'cleaned_word': cleaned_word,
        'similarity_score': 1, 
        'confidence_score': 1,
        'similar_words': None,
        'is_food': True,
        'food_nonfood_score': 1,
        'dictionary_word': 'Heterogeneous Mixture',
        'wweia_category': 'Heterogeneous Mixture',
        'sr_legacy_food_category': 'Heterogeneous Mixture',
        'dry_matter_content': 0.27,
        'water_content': 0.73,
        'leakage': 0.1,
        'specificity': 'Heterogeneous Mixture'
    }
    
def multi_item_template(input_word, cleaned_word=None, conservative_mapping=None):
    if cleaned_word is None:
        cleaned_word = clean_word(input_word)
    
    return {
        'input_word': input_word, 
        'cleaned_word': cleaned_word,
        'similarity_score': 1, 
        'confidence_score': 1,
        'similar_words': None,
        'is_food': True,
        'food_nonfood_score': 1,
        'dictionary_word': f"{conservative_mapping['dictionary_word']} (Lowest DMC)",
        'wweia_category': conservative_mapping['wweia_category'],
        'sr_legacy_food_category': conservative_mapping['sr_legacy_food_category'],
        'dry_matter_content': conservative_mapping['dry_matter_content'],
        'water_content': conservative_mapping['water_content'],
        'leakage': conservative_mapping['leakage'],
        'specificity': conservative_mapping['specificity']
    }