Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. namespace Knowledge
  2. {
  3. /* Knowledge Utility Functions */
  4.  
  5. void Print (std::string Conclusion)
  6. {
  7. std::cout << Conclusion << '\n';
  8. }
  9.  
  10. void PrintData (std::string Key = "", std::string Value = "")
  11. {
  12. Print(" \"" + Key + "\": \"" + Value + "\",");
  13. }
  14.  
  15. bool StartsWith (std::string Argument, std::string Prefix)
  16. {
  17. if(Argument.substr(0, Prefix.size()) == Prefix)
  18. return true;
  19. else return false;
  20. }
  21.  
  22. std::string Extract (std::string Characters, int Length)
  23. {
  24. Characters = Characters.substr(Length);
  25. if (Characters[0] == ' ')
  26. Characters = Characters.substr(1);
  27. return Characters;
  28. }
  29.  
  30. /* Knowledge Intelligent Agents */
  31.  
  32. namespace Nutrition
  33. {
  34. void Notion ()
  35. {
  36. Print("{");
  37. PrintData("1", "Knowledge://Knowledge:80/%Notion=Nutrition Notion");
  38. PrintData("1", "Knowledge://Knowledge:80/%Notion=Nutrition Facts %Food");
  39. Print("}");
  40. }
  41.  
  42. void Facts (std::string Food)
  43. {
  44. Print("{");
  45. PrintData("Facts.Name", Food);
  46. PrintData("Facts.Kcal", "200");
  47. PrintData("Facts.SFat", "20%");
  48. PrintData("Facts.TFat", "20%");
  49. PrintData("Facts.Salt", "10%");
  50. PrintData("Facts.Carbs", "8g");
  51. PrintData("Facts.Fiber", "8g");
  52. PrintData("Facts.Sugar", "2g");
  53. PrintData("Facts.Vitamins.A", "1%");
  54. PrintData("Facts.Vitamins.C", "1%");
  55. PrintData("Facts.Vitamins.E", "1%");
  56. Print("}");
  57. }
  58. }
  59.  
  60. void Notion ()
  61. {
  62. Print("{");
  63. PrintData("1", "Knowledge://Knowledge:80/%Notion=Knowledge Notion");
  64. Print("}");
  65. }
  66.  
  67. void Interpret (std::string Notion)
  68. {
  69. if (Notion == "Knowledge Notion")
  70. Knowledge::Notion();
  71.  
  72. else if (Notion == "Nutrition Notion")
  73. Nutrition::Notion();
  74. else if (StartsWith(Notion, "Nutrition Facts"))
  75. Nutrition::Facts(Extract(Notion, 15));
  76.  
  77. else
  78. {
  79. Print("{");
  80. PrintData("String.Length", "1");
  81. PrintData("String.Values", "['0']");
  82. PrintData("String.Counts", "['0']");
  83. Print("}");
  84. }
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement