@@ -891,47 +891,59 @@ class DatasetType(str, enum.Enum):
891891
892892
893893class TaxonomyType (str , enum .Enum ):
894- dataset_filename : str
895-
896- category = ("category" , "categories.full.json" )
897- ingredient = ("ingredient" , "ingredients.full.json" )
898- label = ("label" , "labels.full.json" )
899- brand = ("brand" , "brands.full.json" )
900- packaging_shape = ("packaging_shape" , "packaging_shapes.full.json" )
901- packaging_material = ("packaging_material" , "packaging_materials.full.json" )
902- packaging_recycling = ("packaging_recycling" , "packaging_recycling.full.json" )
903- country = ("country" , "countries.full.json" )
904- store = ("store" , "stores.full.json" )
905- nova_group = ("nova_group" , "nova_groups.full.json" )
906- packaging = ("packaging" , "packaging.full.json" )
907- additive = ("additive" , "additives.full.json" )
908- vitamin = ("vitamin" , "vitamins.full.json" )
909- mineral = ("mineral" , "minerals.full.json" )
910- amino_acid = ("amino_acid" , "amino_acids.full.json" )
911- nucleotide = ("nucleotide" , "nucleotides.full.json" )
912- allergen = ("allergen" , "allergens.full.json" )
913- state = ("state" , "states.full.json" )
914- data_quality = ("data_quality" , "data_quality.full.json" )
915- origin = ("origin" , "origins.full.json" )
916- language = ("language" , "languages.full.json" )
917- other_nutritional_substance = (
918- "other_nutritional_substance" ,
919- "other_nutritional_substances.full.json" ,
920- )
894+ category = "category"
895+ ingredient = "ingredient"
896+ label = "label"
897+ brand = "brand"
898+ packaging_shape = "packaging_shape"
899+ packaging_material = "packaging_material"
900+ packaging_recycling = "packaging_recycling"
901+ country = "country"
902+ store = "store"
903+ nova_group = "nova_group"
904+ packaging = "packaging"
905+ additive = "additive"
906+ vitamin = "vitamin"
907+ mineral = "mineral"
908+ amino_acid = "amino_acid"
909+ nucleotide = "nucleotide"
910+ allergen = "allergen"
911+ state = "state"
912+ data_quality = "data_quality"
913+ origin = "origin"
914+ language = "language"
915+ other_nutritional_substance = "other_nutritional_substance"
921916
922- def __new__ (cls , value : str , dataset_filename : str ):
923- """
924- Override __new__ to allow storing the dataset filename
925- associated with each taxonomy type.
926- """
927- obj = str .__new__ (cls , value )
928- obj ._value_ = value
929- obj .dataset_filename = dataset_filename
930- return obj
917+ def __str__ (self ) -> str :
918+ return self .name
931919
932920 @property
933921 def dataset_path (self ) -> str :
934- return f"data/taxonomies/{ self .dataset_filename } "
922+ dataset_filename_mapping = {
923+ self .category : "categories.full.json" ,
924+ self .ingredient : "ingredients.full.json" ,
925+ self .label : "labels.full.json" ,
926+ self .brand : "brands.full.json" ,
927+ self .packaging_shape : "packaging_shapes.full.json" ,
928+ self .packaging_material : "packaging_materials.full.json" ,
929+ self .packaging_recycling : "packaging_recycling.full.json" ,
930+ self .country : "countries.full.json" ,
931+ self .store : "stores.full.json" ,
932+ self .nova_group : "nova_groups.full.json" ,
933+ self .packaging : "packaging.full.json" ,
934+ self .additive : "additives.full.json" ,
935+ self .vitamin : "vitamins.full.json" ,
936+ self .mineral : "minerals.full.json" ,
937+ self .amino_acid : "amino_acids.full.json" ,
938+ self .nucleotide : "nucleotides.full.json" ,
939+ self .allergen : "allergens.full.json" ,
940+ self .state : "states.full.json" ,
941+ self .data_quality : "data_quality.full.json" ,
942+ self .origin : "origins.full.json" ,
943+ self .language : "languages.full.json" ,
944+ self .other_nutritional_substance : "other_nutritional_substances.full.json" ,
945+ }
946+ return f"data/taxonomies/{ dataset_filename_mapping [self ]} "
935947
936948
937949class NutritionV3NutrientAggregated (BaseModel ):
0 commit comments