History of bag_of_words
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] bag_of_words: remove the Bipartite tag 14b05c1
It was the only entry with that tag; whether networks are bipartite is shown by their analyses (and counted in the statistics) instead.
diff --git a/entries/bag_of_words/__init__.py b/entries/bag_of_words/__init__.py
index e29c333..b3b2adf 100644
--- a/entries/bag_of_words/__init__.py
+++ b/entries/bag_of_words/__init__.py
@@ -23,7 +23,7 @@ description = """Five text collections in the form of bags-of-words, i.e. a bipa
After tokenization and removal of stopwords, the vocabulary of unique words was truncated by only keeping words that occurred more than ten times. Individual document names (i.e. a identifier for each docID) are not provided for copyright reasons.
"""
-tags = ['Informational', 'Text', 'Bipartite', 'Weighted', 'Metadata']
+tags = ['Informational', 'Text', 'Weighted', 'Metadata']
url = 'http://archive.ics.uci.edu/ml/datasets/Bag+of+Words'
citation = [('David Newman, "Bag of Words Data Set"', 'http://archive.ics.uci.edu/ml/datasets/Bag+of+Words'),
("Dua, D. and Graff, C. (2019). UCI Machine Learning Repository. Irvine, CA: University of California, School of Information and Computer Science.", "http://archive.ics.uci.edu/ml")]
[entries] Fix parse bugs and improve descriptions and metadata 6bb6851
- parse fixes from the review of the descriptions, e.g. us_patents (directed), celegans_2019 (synapse direction), ecoli_transcription and yeast_transcription (regulator to target), bitcoin (direction, phantom node), ego_social (Google+ features and circles), scotus_majority, arxiv_authors and social_location (as in SNAP), caida_as, dnc, dom, mist, reuters and bibsonomy (names on the right nodes), uci_zoo - every description now states explicitly what the nodes and edges represent; corrected titles, years, tags, citations and licences - the "Hypergraph" tag is removed; very large entries are marked `huge = True` (see --skip-huge) - ICON ids of partial duplicates added (hiv_transmission, congress_bills, openflights, dutch_school)
diff --git a/entries/bag_of_words/__init__.py b/entries/bag_of_words/__init__.py
index f3797b3..e29c333 100644
--- a/entries/bag_of_words/__init__.py
+++ b/entries/bag_of_words/__init__.py
@@ -19,7 +19,7 @@
from .. import *
title = "Bag of words (2008)"
-description = """Five text collections in the form of bags-of-words, i.e. a bipartite document–word network. Left nodes are documents and right nodes are words. Edge weights are multiplicities.
+description = """Five text collections in the form of bags-of-words, i.e. a bipartite document–word network. Nodes are documents and words, and an edge connects a document to each word that occurs in it, with the edge property `count` giving the number of occurrences of the word in the document.
After tokenization and removal of stopwords, the vocabulary of unique words was truncated by only keeping words that occurred more than ten times. Individual document names (i.e. a identifier for each docID) are not provided for copyright reasons.
"""
@@ -28,6 +28,8 @@ url = 'http://archive.ics.uci.edu/ml/datasets/Bag+of+Words'
citation = [('David Newman, "Bag of Words Data Set"', 'http://archive.ics.uci.edu/ml/datasets/Bag+of+Words'),
("Dua, D. and Graff, C. (2019). UCI Machine Learning Repository. Irvine, CA: University of California, School of Information and Computer Science.", "http://archive.ics.uci.edu/ml")]
icon_hash = None
+# Too large to process on an ordinary machine (see --skip-huge)
+huge = True
upstream_prefix = 'http://archive.ics.uci.edu/ml/machine-learning-databases/bag-of-words/'
files = [(('docword.enron.txt.gz','vocab.enron.txt'), "enron", None),
(('docword.kos.txt.gz','vocab.kos.txt'), "kos", None),
Update copyright information 73a4f0d
diff --git a/entries/bag_of_words/__init__.py b/entries/bag_of_words/__init__.py
index ef89946..f3797b3 100644
--- a/entries/bag_of_words/__init__.py
+++ b/entries/bag_of_words/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020-2024 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-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
Update copyright information 3d288ea
diff --git a/entries/bag_of_words/__init__.py b/entries/bag_of_words/__init__.py
index 0d37701..ef89946 100644
--- a/entries/bag_of_words/__init__.py
+++ b/entries/bag_of_words/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2020-2023 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2024 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
Update copyright information 8d005ae
diff --git a/entries/bag_of_words/__init__.py b/entries/bag_of_words/__init__.py
index ef7d799..0d37701 100644
--- a/entries/bag_of_words/__init__.py
+++ b/entries/bag_of_words/__init__.py
@@ -1,7 +1,7 @@
#! /usr/bin/env python
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2021 Tiago de Paula Peixoto <tiago@skewed.de>
+# Copyright (C) 2020-2023 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
Add bag_of_words b307cf6
diff --git a/entries/bag_of_words/__init__.py b/entries/bag_of_words/__init__.py
new file mode 100644
index 0000000..ef7d799
--- /dev/null
+++ b/entries/bag_of_words/__init__.py
@@ -0,0 +1,81 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2021 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 = "Bag of words (2008)"
+description = """Five text collections in the form of bags-of-words, i.e. a bipartite document–word network. Left nodes are documents and right nodes are words. Edge weights are multiplicities.
+
+After tokenization and removal of stopwords, the vocabulary of unique words was truncated by only keeping words that occurred more than ten times. Individual document names (i.e. a identifier for each docID) are not provided for copyright reasons.
+"""
+tags = ['Informational', 'Text', 'Bipartite', 'Weighted', 'Metadata']
+url = 'http://archive.ics.uci.edu/ml/datasets/Bag+of+Words'
+citation = [('David Newman, "Bag of Words Data Set"', 'http://archive.ics.uci.edu/ml/datasets/Bag+of+Words'),
+ ("Dua, D. and Graff, C. (2019). UCI Machine Learning Repository. Irvine, CA: University of California, School of Information and Computer Science.", "http://archive.ics.uci.edu/ml")]
+icon_hash = None
+upstream_prefix = 'http://archive.ics.uci.edu/ml/machine-learning-databases/bag-of-words/'
+files = [(('docword.enron.txt.gz','vocab.enron.txt'), "enron", None),
+ (('docword.kos.txt.gz','vocab.kos.txt'), "kos", None),
+ (('docword.nips.txt.gz','vocab.nips.txt'), "nips", None),
+ (('docword.nytimes.txt.gz','vocab.nytimes.txt'), "nytimes", None),
+ (('docword.pubmed.txt.gz','vocab.pubmed.txt'), "pubmed", 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 fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ if isinstance(fnames, str):
+ fnames = [fnames]
+ with ExitStack() as stack:
+ fs = [stack.enter_context(open_upstream_file(name, fn, "r")) for fn in fnames]
+
+ g = Graph(directed=False)
+ g.vp.is_word = g.new_vp("bool")
+ g.ep.count = count = g.new_ep("int")
+ g.vp.name = g.new_vp("string")
+
+ for i, line in enumerate(fs[0]):
+ if i == 0:
+ D = int(line.strip())
+ elif i == 1:
+ W = int(line.strip())
+ g.add_vertex(D + W)
+ g.vp.is_word.fa[D:] = True
+ elif i == 2:
+ continue
+ else:
+ vals = [int(x) for x in line.strip().split()]
+ d = vals[0] - 1
+ w = vals[1] - 1
+ c = vals[2]
+ e = g.add_edge(d, w + D)
+ count[e] = c
+
+ for i, line in enumerate(fs[1]):
+ g.vp.name[i + D] = line.strip()
+
+ yield alt, g