angelosalatino / cso-classifier

Python library that classifies content from scientific papers with the topics of the Computer Science Ontology (CSO).
https://cso.kmi.open.ac.uk
Apache License 2.0
84 stars 18 forks source link

running issue with collections package #10

Closed immorBen closed 2 years ago

immorBen commented 2 years ago

When running "test.test_classifier_single_paper()",

>>> import cso_classifier as test
>>> test.test_classifier_single_paper()

got the following messages:

De-anonymizing Social Networks Operators of online social networks are increasingly sharing potentially sensitive information about users and their relationships with advertisers, application developers, and data-mining researchers. Privacy is typically protected by anonymization, i.e., removing names, addresses, etc. We present a framework for analyzing privacy and anonymity in social networks and develop a new re-identification algorithm targeting anonymized social-network graphs. To demonstrate its effectiveness on real-world networks, we show that a third of the users who can be verified to have accounts on both Twitter, a popular microblogging service, and Flickr, an online photo-sharing site, can be re-identified in the anonymous Twitter graph with only a 12% error rate. Our de-anonymization algorithm is based purely on the network topology, does not require creation of a large number of dummy "sybil" nodes, is robust to noise and all existing defenses, and works even when the overlap between the target network and the adversary's auxiliary information is small. data mining, data privacy, graph theory, social networking (online) Computer Science Ontology loaded. Model loaded. Traceback (most recent call last): File "", line 1, in File "[my-personal-path]python3.10/site-packages/cso_classifier/test.py", line 35, in test_classifier_single_paper result = cso_classifier.run(paper) File "[my-personal-path]/python3.10/site-packages/cso_classifier/classifier.py", line 80, in run self.model = MODEL(use_full_model=self.use_full_model, silent = self.silent) File "[my-personal-path]/python3.10/site-packages/cso_classifier/model.py", line 27, in _init_ self.load_models() File "[my-personal-path]/python3.10/site-packages/cso_classifier/model.py", line 35, in load_models self.__load_word2vec_model() File "[my-personal-path]python3.10/site-packages/cso_classifier/model.py", line 167, in __load_word2vec_model self.full_model = pickle.load(open(self.config.get_model_pickle_path(), "rb")) File "[my-personal-path]/python3.10/site-packages/gensim/_init_.py", line 5, in from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401 File "[my-personal-path]/python3.10/site-packages/gensim/corpora/_init_.py", line 12, in from .dictionary import Dictionary # noqa:F401 File "[my-personal-path]/python3.10/site-packages/gensim/corpora/dictionary.py", line 11, in from collections import Mapping, defaultdict ImportError: cannot import name 'Mapping' from 'collections' ([my-personal-path]lib/python3.10/collections/_init_.py)

and "from collections.abc import Mapping" works well. @angelosalatino

If changing File "[my-personal-path]lib/python3.10/site-packages/gensim/corpora/dictionary.py", modify the import as "from collections.abc import Mapping", another importing error occurred:

ImportError: cannot import name 'Iterable' from 'collections' ([my-personal-path]/lib/python3.10/collections/_init_.py)

gensim/models/fasttext.py also uses "Iterable"...

details about my environment os: ubuntu 18.04.6 LTS versions:

immorBen commented 2 years ago

A somewhat similar issue happened in Azure related issues, they suggested modifying "import Mapping/Iterable from collections.abc" in related scripts.

immorBen commented 2 years ago

As reflected somewhere else, this import error is along with python 3.10. Re-install with python 3.8.8 can figure out this problem.