History of recipe_rec
The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.
[entries] New entry: recipe_rec 1ab6dcc
diff --git a/entries/recipe_rec/__init__.py b/entries/recipe_rec/__init__.py
new file mode 100644
index 0000000..2f141b3
--- /dev/null
+++ b/entries/recipe_rec/__init__.py
@@ -0,0 +1,77 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+
+from .. import *
+
+
+title = "Food.com recipes and their ingredients (RecipeRec, 2022)"
+description = """A bipartite network of recipes of the cooking website Food.com and their ingredients, from the RecipeRec dataset of Tian et al. (collected from Food.com for a study of recipe recommendation), as distributed by XGI-data. Each recipe is connected to the ingredients it uses. Some recipes have the same set of ingredients (77,733 recipes, 74,870 distinct sets). The other parts of the RecipeRec dataset (e.g. the users and their ratings of the recipes) are not included in the XGI-data version.
+
+The network has the following properties:
+
+- `is_recipe`: whether the node is a recipe (otherwise an ingredient).
+- `name`: the name of the recipe or ingredient.
+- Recipes: `recipe_id`, the identifier of the recipe on Food.com; `url`, the address of the recipe on Food.com."""
+tags = ['Informational', 'Online', 'Unweighted', 'Metadata']
+url = ['https://github.com/meettyj/RecipeRec',
+ 'https://zenodo.org/records/14003376',
+ 'https://github.com/xgi-org/xgi-data']
+citation = [('Y. Tian, C. Zhang, Z. Guo, C. Huang, R. Metoyer, N. V. Chawla, "RecipeRec: A Heterogeneous Graph Learning Model for Recipe Recommendation." Proceedings of the Thirty-First International Joint Conference on Artificial Intelligence (IJCAI-22), 3466-3472 (2022)', 'https://doi.org/10.24963/ijcai.2022/481')]
+icon_hash = None
+upstream_license = ('CC BY 4.0', 'https://creativecommons.org/licenses/by/4.0/')
+upstream_prefix = 'https://zenodo.org/records/14003376/files'
+files = [('recipe-rec.json', None, None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ global files
+ name = __name__.split(".")[-1]
+ for fname, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ # HIF (hypergraph interchange format) of XGI
+ with open_upstream_file(name, fname, "r") as f:
+ d = json.load(f)
+ recipes = [e for e in d["edges"]]
+ for r in recipes:
+ r["id"] = int(re.search(r"-(\d+)$", r["attrs"]["url"]).group(1))
+ recipes.sort(key=lambda r: r["id"])
+ ingredients = sorted(set(x["node"] for x in d["incidences"]))
+ iindex = {x: i for i, x in enumerate(ingredients)}
+ N = len(ingredients)
+ rindex = {r["edge"]: N + i for i, r in enumerate(recipes)}
+ g = Graph(directed=False)
+ g.add_vertex(N + len(recipes))
+ g.vp.is_recipe = g.new_vp("bool")
+ g.vp.is_recipe.a[N:] = True
+ g.vp.name = g.new_vp("string", vals=ingredients +
+ [r["attrs"]["name"] for r in recipes])
+ g.vp.recipe_id = g.new_vp("int", val=-1)
+ g.vp.recipe_id.a[N:] = [r["id"] for r in recipes]
+ g.vp.url = g.new_vp("string", vals=[""] * N + [r["attrs"]["url"] for r in recipes])
+ g.add_edge_list(sorted(set((iindex[x["node"]], rindex[x["edge"]])
+ for x in d["incidences"]), key=lambda e: e[::-1]))
+ yield alt, g