Wolfram 언어

풍부한 Knowledgebase 액세스

간식, 식사, 음식의 품질

Wolfram Knowledgebase는 37,000 가지 이상의 "Food" 엔티티와 1,000개 이상 항목의 "FoodType" 엔티티에 대한 상세한 영양 정보 특성을 포함하고 있습니다. 자유 형식 입력으로 EntityInstance, EntityGroup, 그리고 Quantity를 사용하면 음식 집합에 대한 영양 특성, 특히 점심과 저녁 식사의 열량, 섬유질, 당질 함량을 쉽게 나타내고 계산할 수 있습니다.

In[1]:=
Click for copyable input
Table[EntityValue[foodtype, "EntityCount"], {foodtype, {"Food", "FoodType"}}]
Out[1]=

Ctrl+= (자유 형식 입력)을 사용하여 주어진 음식의 양을 EntityInstance로 표현된 암묵적으로 정의된 음식 엔티티의 지정된 수량을 간단히 얻을 수 있습니다.

In[2]:=
Click for copyable input
\!\( NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "2 tbsp peanut butter", Typeset`boxes$$ = RowBox[{"EntityInstance", "[", RowBox[{ InterpretationBox[ DynamicModuleBox[{EntityFramework`Formatting`Private`open = False}, TemplateBox[{ TemplateBox[{"\"foods\""}, "GeneralizedEntityBase"], TagBox[ GridBox[{{ TemplateBox[{ TemplateBox[{"\"food type\"", RowBox[{"EntityProperty", "[", RowBox[{"\"Food\"", ",", "\"FoodType\""}], "]"}], "\"EntityProperty[\\\"Food\\\", \\\"FoodType\\\"]\ \""}, "EntityProperty"], StyleBox["\":\"", "GeneralizedEntityInfoItem"], RowBox[{"ContainsExactly", "[", RowBox[{"{", TemplateBox[{"\"peanut butter\"", RowBox[{"Entity", "[", RowBox[{"\"FoodType\"", ",", "\"PeanutButter\""}], "]"}], "\"Entity[\\\"FoodType\\\", \\\"PeanutButter\\\"]\ \"", "\"food type\""}, "Entity"], "}"}], "]"}]}, "GeneralizedEntityInfoRow"]}, { TemplateBox[{ TemplateBox[{"\"added food types\"", RowBox[{"EntityProperty", "[", RowBox[{"\"Food\"", ",", "\"AddedFoodTypes\""}], "]"}], "\"EntityProperty[\\\"Food\\\", \ \\\"AddedFoodTypes\\\"]\""}, "EntityProperty"], StyleBox["\":\"", "GeneralizedEntityInfoItem"], RowBox[{"ContainsExactly", "[", RowBox[{"{", "}"}], "]"}]}, "GeneralizedEntityInfoRow"]}}, GridBoxAlignment -> {"Columns" -> {{Left}}}, DefaultBaseStyle -> "GeneralizedEntityInfoGrid", GridBoxItemSize -> { "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}], "Column"], Dynamic[EntityFramework`Formatting`Private`open], "\"Entity[\\\"Food\\\", {EntityProperty[\\\"Food\\\", \ \\\"FoodType\\\"] -> ContainsExactly[{Entity[\\\"FoodType\\\", \ \\\"PeanutButter\\\"]}], EntityProperty[\\\"Food\\\", \ \\\"AddedFoodTypes\\\"] -> ContainsExactly[{}]}]\""}, "GeneralizedEntityToggle"]], Entity["Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "PeanutButter"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], SelectWithContents -> True], ",", " ", TemplateBox[{"2", "\"tbsp\"", "tablespoons", "\"Tablespoons\""}, "Quantity", SyntaxForm -> Mod]}], "]"}], Typeset`allassumptions$$ = {{ "type" -> "Unit", "word" -> "tbsp", "template" -> "Assuming ${desc1} for \"${word}\". Use ${desc2} \ instead", "count" -> "4", "Values" -> {{ "name" -> "Tablespoons", "desc" -> "US tablespoons", "input" -> "UnitClash_*tbsp.*Tablespoons--"}, { "name" -> "TablespoonsUK", "desc" -> "UK tablespoons", "input" -> "UnitClash_*tbsp.*TablespoonsUK--"}, { "name" -> "MetricTablespoons", "desc" -> "metric tablespoons", "input" -> "UnitClash_*tbsp.*MetricTablespoons--"}, { "name" -> "TablespoonsAustralian", "desc" -> "Australian tablespoons", "input" -> "UnitClash_*tbsp.*TablespoonsAustralian--"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.574756`6.211028507153325, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{138., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)
Out[2]=

토대가 되고있는 Quantity (기본적으로 출력 포맷 된 형태로 표시되는) 식을 살펴 봅니다.

In[3]:=
Click for copyable input
\!\( NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "2 tbsp peanut butter", Typeset`boxes$$ = RowBox[{"EntityInstance", "[", RowBox[{ InterpretationBox[ DynamicModuleBox[{EntityFramework`Formatting`Private`open = False}, TemplateBox[{ TemplateBox[{"\"foods\""}, "GeneralizedEntityBase"], TagBox[ GridBox[{{ TemplateBox[{ TemplateBox[{"\"food type\"", RowBox[{"EntityProperty", "[", RowBox[{"\"Food\"", ",", "\"FoodType\""}], "]"}], "\"EntityProperty[\\\"Food\\\", \\\"FoodType\\\"]\ \""}, "EntityProperty"], StyleBox["\":\"", "GeneralizedEntityInfoItem"], RowBox[{"ContainsExactly", "[", RowBox[{"{", TemplateBox[{"\"peanut butter\"", RowBox[{"Entity", "[", RowBox[{"\"FoodType\"", ",", "\"PeanutButter\""}], "]"}], "\"Entity[\\\"FoodType\\\", \\\"PeanutButter\\\"]\ \"", "\"food type\""}, "Entity"], "}"}], "]"}]}, "GeneralizedEntityInfoRow"]}, { TemplateBox[{ TemplateBox[{"\"added food types\"", RowBox[{"EntityProperty", "[", RowBox[{"\"Food\"", ",", "\"AddedFoodTypes\""}], "]"}], "\"EntityProperty[\\\"Food\\\", \ \\\"AddedFoodTypes\\\"]\""}, "EntityProperty"], StyleBox["\":\"", "GeneralizedEntityInfoItem"], RowBox[{"ContainsExactly", "[", RowBox[{"{", "}"}], "]"}]}, "GeneralizedEntityInfoRow"]}}, GridBoxAlignment -> {"Columns" -> {{Left}}}, DefaultBaseStyle -> "GeneralizedEntityInfoGrid", GridBoxItemSize -> { "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}], "Column"], Dynamic[EntityFramework`Formatting`Private`open], "\"Entity[\\\"Food\\\", {EntityProperty[\\\"Food\\\", \ \\\"FoodType\\\"] -> ContainsExactly[{Entity[\\\"FoodType\\\", \ \\\"PeanutButter\\\"]}], EntityProperty[\\\"Food\\\", \ \\\"AddedFoodTypes\\\"] -> ContainsExactly[{}]}]\""}, "GeneralizedEntityToggle"]], Entity["Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "PeanutButter"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], SelectWithContents -> True], ",", " ", TemplateBox[{"2", "\"tbsp\"", "tablespoons", "\"Tablespoons\""}, "Quantity", SyntaxForm -> Mod]}], "]"}], Typeset`allassumptions$$ = {{ "type" -> "Unit", "word" -> "tbsp", "template" -> "Assuming ${desc1} for \"${word}\". Use ${desc2} \ instead", "count" -> "4", "Values" -> {{ "name" -> "Tablespoons", "desc" -> "US tablespoons", "input" -> "UnitClash_*tbsp.*Tablespoons--"}, { "name" -> "TablespoonsUK", "desc" -> "UK tablespoons", "input" -> "UnitClash_*tbsp.*TablespoonsUK--"}, { "name" -> "MetricTablespoons", "desc" -> "metric tablespoons", "input" -> "UnitClash_*tbsp.*MetricTablespoons--"}, { "name" -> "TablespoonsAustralian", "desc" -> "Australian tablespoons", "input" -> "UnitClash_*tbsp.*TablespoonsAustralian--"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.574756`6.211028507153325, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{138., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\); Cases[%, _Quantity] // InputForm
Out[3]//InputForm=

[+]를 클릭하여 위의 암묵적으로 정의된 엔티티를 확장합니다.

In[4]:=
Click for copyable input
EntityInstance[Entity[ "Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "PeanutButter"]}], EntityProperty["Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], Quantity[2, "Tablespoons"]]

자유 형식 입력은 프로그램 문장에 직접 사용할 수 있습니다.

In[5]:=
Click for copyable input
peanutButter = \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "2 tbsp peanut butter", Typeset`boxes$$ = RowBox[{"EntityInstance", "[", RowBox[{ InterpretationBox[ DynamicModuleBox[{EntityFramework`Formatting`Private`open = False}, TemplateBox[{ TemplateBox[{"\"foods\""}, "GeneralizedEntityBase"], TagBox[ GridBox[{{ TemplateBox[{ TemplateBox[{"\"food type\"", RowBox[{"EntityProperty", "[", RowBox[{"\"Food\"", ",", "\"FoodType\""}], "]"}], "\"EntityProperty[\\\"Food\\\", \\\"FoodType\\\"]\ \""}, "EntityProperty"], StyleBox["\":\"", "GeneralizedEntityInfoItem"], RowBox[{"ContainsExactly", "[", RowBox[{"{", TemplateBox[{"\"peanut butter\"", RowBox[{"Entity", "[", RowBox[{"\"FoodType\"", ",", "\"PeanutButter\""}], "]"}], "\"Entity[\\\"FoodType\\\", \\\"PeanutButter\\\"]\ \"", "\"food type\""}, "Entity"], "}"}], "]"}]}, "GeneralizedEntityInfoRow"]}, { TemplateBox[{ TemplateBox[{"\"added food types\"", RowBox[{"EntityProperty", "[", RowBox[{"\"Food\"", ",", "\"AddedFoodTypes\""}], "]"}], "\"EntityProperty[\\\"Food\\\", \ \\\"AddedFoodTypes\\\"]\""}, "EntityProperty"], StyleBox["\":\"", "GeneralizedEntityInfoItem"], RowBox[{"ContainsExactly", "[", RowBox[{"{", "}"}], "]"}]}, "GeneralizedEntityInfoRow"]}}, GridBoxAlignment -> {"Columns" -> {{Left}}}, DefaultBaseStyle -> "GeneralizedEntityInfoGrid", GridBoxItemSize -> { "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}], "Column"], Dynamic[EntityFramework`Formatting`Private`open], "\"Entity[\\\"Food\\\", {EntityProperty[\\\"Food\\\", \\\ \"FoodType\\\"] -> ContainsExactly[{Entity[\\\"FoodType\\\", \ \\\"PeanutButter\\\"]}], EntityProperty[\\\"Food\\\", \ \\\"AddedFoodTypes\\\"] -> ContainsExactly[{}]}]\""}, "GeneralizedEntityToggle"]], Entity["Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "PeanutButter"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], SelectWithContents -> True], ",", " ", TemplateBox[{"2", "\"tbsp\"", "tablespoons", "\"Tablespoons\""}, "Quantity", SyntaxForm -> Mod]}], "]"}], Typeset`allassumptions$$ = {{ "type" -> "Unit", "word" -> "tbsp", "template" -> "Assuming ${desc1} for \"${word}\". Use ${desc2} \ instead", "count" -> "4", "Values" -> {{ "name" -> "Tablespoons", "desc" -> "US tablespoons", "input" -> "UnitClash_*tbsp.*Tablespoons--"}, { "name" -> "TablespoonsUK", "desc" -> "UK tablespoons", "input" -> "UnitClash_*tbsp.*TablespoonsUK--"}, { "name" -> "MetricTablespoons", "desc" -> "metric tablespoons", "input" -> "UnitClash_*tbsp.*MetricTablespoons--"}, { "name" -> "TablespoonsAustralian", "desc" -> "Australian tablespoons", "input" -> "UnitClash_*tbsp.*TablespoonsAustralian--"}}}}, Typeset`assumptions$$ = {}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.574756`6.211028507153325, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{138., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)
Out[5]=
In[6]:=
Click for copyable input
twoSlicesOfBread = \!\(\* NamespaceBox["LinguisticAssistant", DynamicModuleBox[{Typeset`query$$ = "2 slices of bread", Typeset`boxes$$ = RowBox[{"EntityInstance", "[", RowBox[{ InterpretationBox[ DynamicModuleBox[{EntityFramework`Formatting`Private`open = False}, TemplateBox[{ TemplateBox[{"\"foods\""}, "GeneralizedEntityBase"], TagBox[ GridBox[{{ TemplateBox[{ TemplateBox[{"\"food type\"", RowBox[{"EntityProperty", "[", RowBox[{"\"Food\"", ",", "\"FoodType\""}], "]"}], "\"EntityProperty[\\\"Food\\\", \\\"FoodType\\\"]\ \""}, "EntityProperty"], StyleBox["\":\"", "GeneralizedEntityInfoItem"], RowBox[{"ContainsExactly", "[", RowBox[{"{", TemplateBox[{"\"bread\"", RowBox[{"Entity", "[", RowBox[{"\"FoodType\"", ",", "\"Bread\""}], "]"}], "\"Entity[\\\"FoodType\\\", \\\"Bread\\\"]\"", "\"food type\""}, "Entity"], "}"}], "]"}]}, "GeneralizedEntityInfoRow"]}, { TemplateBox[{ TemplateBox[{"\"added food types\"", RowBox[{"EntityProperty", "[", RowBox[{"\"Food\"", ",", "\"AddedFoodTypes\""}], "]"}], "\"EntityProperty[\\\"Food\\\", \ \\\"AddedFoodTypes\\\"]\""}, "EntityProperty"], StyleBox["\":\"", "GeneralizedEntityInfoItem"], RowBox[{"ContainsExactly", "[", RowBox[{"{", "}"}], "]"}]}, "GeneralizedEntityInfoRow"]}}, GridBoxAlignment -> {"Columns" -> {{Left}}}, DefaultBaseStyle -> "GeneralizedEntityInfoGrid", GridBoxItemSize -> { "Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}], "Column"], Dynamic[EntityFramework`Formatting`Private`open], "\"Entity[\\\"Food\\\", {EntityProperty[\\\"Food\\\", \\\ \"FoodType\\\"] -> ContainsExactly[{Entity[\\\"FoodType\\\", \ \\\"Bread\\\"]}], EntityProperty[\\\"Food\\\", \ \\\"AddedFoodTypes\\\"] -> ContainsExactly[{}]}]\""}, "GeneralizedEntityToggle"]], Entity["Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "Bread"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], SelectWithContents -> True], ",", " ", TemplateBox[{"2", "\"slices\"", "slices", "\"Slices\""}, "Quantity", SyntaxForm -> Mod]}], "]"}], Typeset`allassumptions$$ = {{ "type" -> "Clash", "word" -> "bread", "template" -> "Assuming \"${word}\" is ${desc1}. Use as \ ${desc2} instead", "count" -> "2", "Values" -> {{ "name" -> "FoodType", "desc" -> "a food type", "input" -> "*C.bread-_*FoodType-"}, { "name" -> "FoodTypeGroup", "desc" -> " referring to food type group", "input" -> "*C.bread-_*FoodTypeGroup-"}}}}, Typeset`assumptions$$ = {"*C.bread-_*FoodType-"}, Typeset`open$$ = {1}, Typeset`querystate$$ = { "Online" -> True, "Allowed" -> True, "mparse.jsp" -> 0.662875`6.2729766336225925, "Messages" -> {}}}, DynamicBox[ToBoxes[ AlphaIntegration`LinguisticAssistantBoxes["", 4, Automatic, Dynamic[Typeset`query$$], Dynamic[Typeset`boxes$$], Dynamic[Typeset`allassumptions$$], Dynamic[Typeset`assumptions$$], Dynamic[Typeset`open$$], Dynamic[Typeset`querystate$$]], StandardForm], ImageSizeCache->{117., {7., 16.}}, TrackedSymbols:>{ Typeset`query$$, Typeset`boxes$$, Typeset`allassumptions$$, Typeset`assumptions$$, Typeset`open$$, Typeset`querystate$$}], DynamicModuleValues:>{}, UndoTrackedVariables:>{Typeset`open$$}], BaseStyle->{"Deploy"}, DeleteWithContents->True, Editable->False, SelectWithContents->True]\)
Out[6]=

음식의 그룹 (식사, 간식 등)은 EntityGroup으로 나타낼 수 있습니다.

In[7]:=
Click for copyable input
pbjSandwich = EntityGroup[{ twoSlicesOfBread, peanutButter, EntityInstance[Entity[ "Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "Jelly"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], Quantity[1, "Servings"]] }];

음식 그룹을 하나로 묶어 식품의 영양소 함량을 전체적으로 알아봅니다.

In[8]:=
Click for copyable input
pbjSandwich[{EntityProperty["Food", "AbsoluteTotalCaloriesContent"], EntityProperty["Food", "AbsoluteTotalProteinContent"]}, "PropertyAssociation"]
Out[8]=

EntityGroupEntityInstance를 사용하여 스파게티 저녁 식사를 분석합니다.

In[9]:=
Click for copyable input
dinner = EntityGroup[{ EntityInstance[Entity[ "Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "Spaghetti"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], Quantity[1, "Servings"]], EntityInstance[Entity[ "Food", {EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "Meatball"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], Quantity[3, "Items"]], EntityInstance[Entity[ "Food", { EntityProperty["Food", "BrandName"] -> Entity[ "FoodBrandName", "Bertolli"], EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "Sauce"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], Quantity[1.5, "Servings"]], EntityInstance[Entity[ "Food", { EntityProperty["Food", "Flavor"] -> Entity[ "FoodFlavor", "Cola"], EntityProperty["Food", "FoodType"] -> ContainsExactly[{ Entity["FoodType", "CarbonatedBeverage"]}], EntityProperty[ "Food", "AddedFoodTypes"] -> ContainsExactly[{}]}], Quantity[1, "USSodaCanVolumes"]] }];
In[10]:=
Click for copyable input
dinner[{EntityProperty["Food", "AbsoluteTotalCaloriesContent"], EntityProperty["Food", "AbsoluteTotalSugarContent"]}, "PropertyAssociation"]
Out[10]=

관련 예제

de en es fr ja pt-br ru zh