Commit ed7da7e9 authored by Luciano's avatar Luciano

Imported Upstream version 0.7.3

parent f4ba211d
Pipeline #3977911 failed with stage
in 1 minute and 11 seconds
before_script:
- ./install_dependencies.sh
- sudo pip2 install flake8
- /usr/bin/python2 -m apprecommender.main.cli --init
- /usr/bin/python2 -m apprecommender.main.cli --train
- sudo /usr/bin/python2 -m apprecommender.main.cli --init
- sudo /usr/bin/python2 -m apprecommender.main.cli --train
test:
script:
......
DPkg::Post-Invoke {"apprec-apt --post-invoke";};
DPkg::Pre-Install-Pkgs {"apprec-apt --pre-install-pkgs";};
DPkg::Post-Invoke {"[ ! -x /usr/bin/apprec-apt ] || apprec-apt --post-invoke";};
DPkg::Pre-Install-Pkgs {"[ ! -x /usr/bin/apprec-apt ] || apprec-apt --pre-install-pkgs";};
#!/usr/bin/env python
import apt
import xapian
class AptCache:
DEFAULT_AXI_PATH = "/var/lib/apt-xapian-index/index"
def __init__(self):
self.axi = xapian.Database(AptCache.DEFAULT_AXI_PATH)
self.cache = apt.Cache()
def __getitem__(self, pkg_name):
return self.get(pkg_name)
def __contains__(self, pkg_name):
return self.xapian_has_pkg(pkg_name) and pkg_name in self.cache
def get(self, pkg_name):
if self.xapian_has_pkg(pkg_name):
return self.cache[pkg_name]
raise KeyError("The cache has no package named '{}'".format(pkg_name))
def xapian_has_pkg(self, pkg_name):
term = 'XP' + pkg_name
return self.axi.get_termfreq(term) > 0L
......@@ -45,7 +45,7 @@ class Config(Singleton):
['/etc/apprecommender/recommender.conf',
os.path.expanduser('~/.app_recommender.rc'),
os.path.expanduser('app_recommender.cfg')])
self.home_dir = os.path.expanduser('~/.app-recommender')
self.home_dir = os.path.expanduser('~/.apprecommender')
except (MissingSectionHeaderError), err:
logging.error("Error in config file syntax: %s", str(err))
......@@ -53,7 +53,7 @@ class Config(Singleton):
if not hasattr(self, 'initialized'):
# data_source options
self.base_dir = os.environ.get(
'APPREC_DATA', '~/.apprecommender')
'APPREC_DATA', '/var/lib/apprecommender')
self.base_dir = os.path.expanduser(self.base_dir)
self.output = os.path.join(self.home_dir, 'apprec.log')
self.user_data_dir = os.path.join(self.base_dir, "user_data/")
......@@ -129,7 +129,7 @@ class Config(Singleton):
self.debug = int(self.read_option('general', 'debug'))
self.debug = int(self.read_option('general', 'verbose'))
self.base_dir = os.environ.get(
'APPREC_DATA', '~/.apprecommender')
'APPREC_DATA', '/var/lib/apprecommender')
self.base_dir = os.path.expanduser(self.base_dir)
self.output = os.path.join(
self.home_dir, self.read_option('data_sources',
......
#!/usr/bin/env python
import apt
import commands
import re
import xapian
from apprecommender.apt_cache import AptCache
from sklearn.feature_extraction.stop_words import ENGLISH_STOP_WORDS
......@@ -21,7 +22,7 @@ class PkgInitDecider():
'fonts', 'png', 'core', 'default'}
def __init__(self):
self.cache = apt.Cache()
self.cache = AptCache()
self.user_role_programs = self.get_user_role_programs()
def is_in_apt_cache(self, pkg):
......@@ -195,7 +196,7 @@ class PkgReverseDependeciesDecider(xapian.MatchDecider):
self.reverse_dependencies = reverse_dependencies
self.pkg_init_decider = PkgInitDecider()
self.pkg_match_decider = PkgMatchDecider(user_installed_pkgs)
self.cache = apt.Cache()
self.cache = AptCache()
def __call__(self, xapian_document):
"""
......
#!/usr/bin/env python
import apt
import commands
import data
import datetime
......@@ -24,7 +23,6 @@ class Initialize:
def __init__(self):
self.config = Config()
self.cache = apt.Cache()
self.pkg_init_decider = PkgInitDecider()
def get_tags(self):
......
#!/usr/bin/env python
import apt
import binascii
import commands
import datetime as dt
......@@ -12,14 +11,15 @@ import tarfile
import time
import xapian
from apprecommender.main.app_recommender import AppRecommender
from apprecommender.apt_cache import AptCache
from apprecommender.config import Config
from apprecommender.data import get_user_installed_pkgs
from apprecommender.data_classification import get_alternative_pkg
from apprecommender.main.app_recommender import AppRecommender
from apprecommender.main.ml_cross_validation import ml_cross_validation
from apprecommender.ml.data import MachineLearningData
from apprecommender.ml.pkg_time import PkgTime
from apprecommender.utils import print_progress_bar
from apprecommender.main.ml_cross_validation import ml_cross_validation
LOG_PATH = os.path.expanduser('~/app_recommender_log')
SUFIX = dt.datetime.now().strftime('%Y%m%d%H%M')
......@@ -210,7 +210,7 @@ def collect_user_preferences():
message_error = "\nPlease use digits 1-4 to rank a package: "
apt_cache = apt.Cache()
apt_cache = AptCache()
for i in range(len(all_recommendations)):
pkg = all_recommendations[i]
pkg_description = apt_cache[pkg].versions[0].description
......
import os
import pickle
from apt import Cache
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.naive_bayes import GaussianNB
from apprecommender.apt_cache import AptCache
from apprecommender.config import Config
from apprecommender.ml.data import MachineLearningData
......@@ -134,7 +134,7 @@ class BagOfWords():
pickle.dump(pkgs_classification, bow_pkgs_classification)
def train_model(self, pkgs_list, axi, save_files=True):
cache = Cache()
cache = AptCache()
ml_data = MachineLearningData()
pkgs_description, pkg_classification = self.prepare_data(
......
from os import path
from os import makedirs
import apt
import Stemmer
import pickle
import xapian
import Stemmer
from apprecommender.ml.pkg_time import PkgTime
from apprecommender.apt_cache import AptCache
from apprecommender.config import Config
from apprecommender.decider import FilterTag, FilterDescription
from apprecommender.ml.pkg_time import PkgTime
class MachineLearningData():
......@@ -41,7 +41,7 @@ class MachineLearningData():
pkgs = self.get_pkgs_classification(labels)
cache = apt.Cache()
cache = AptCache()
terms_name = self.get_terms_for_all_pkgs(cache, pkgs.keys())
debtags_name = self.get_debtags_for_all_pkgs(self.axi, pkgs.keys())
......
......@@ -19,7 +19,6 @@ __license__ = """
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import apt
import heapq
import inspect
import logging
......@@ -32,6 +31,8 @@ from fuzzywuzzy import fuzz
from operator import attrgetter
import apprecommender.strategy
from apprecommender.apt_cache import AptCache
from apprecommender.config import Config
......@@ -46,7 +47,7 @@ class RecommendationResult:
self.item_score = item_score
self.size = len(item_score)
self.limit = limit
self.cache = apt.Cache()
self.cache = AptCache()
self.pkg_descriptions = {}
if ranking:
......
......@@ -20,7 +20,6 @@ __license__ = """
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import apt
import collections
import logging
import operator
......@@ -34,6 +33,7 @@ import numpy as np
from abc import ABCMeta, abstractmethod
from apprecommender.apt_cache import AptCache
from apprecommender.config import Config
from apprecommender.decider import (PkgMatchDecider,
PkgReverseDependeciesDecider)
......@@ -145,7 +145,7 @@ class PackageReference(ContentBased):
self.content = content
self.description = 'Package-reference'
self.profile_size = profile_size
self.cache = apt.Cache()
self.cache = AptCache()
self.pkgs_regex = re.compile(r'^\s+(?:\|)?(.+)$', re.MULTILINE)
def get_reverse_dependencies_pkgs(self, reference_pkgs):
......@@ -209,7 +209,7 @@ class MachineLearning(ContentBased):
self.description = 'Machine-learning'
self.profile_size = profile_size
self.suggestion_size = suggestion_size
self.cache = apt.Cache()
self.cache = AptCache()
self.ml_data = MachineLearningData()
self.axi = xapian.Database(XAPIAN_DATABASE_PATH)
......
#!/usr/bin/env python
import apt
import unittest
import xapian
from mock import patch
from apprecommender.apt_cache import AptCache
from apprecommender.ml.data import MachineLearningData
......@@ -13,7 +13,7 @@ class PkgClassificationTests(unittest.TestCase):
def setUp(self):
self.ml_data = MachineLearningData()
self.cache = apt.Cache()
self.cache = AptCache()
def test_get_pkg_debtags(self):
vim_debtags = ['devel::editor', 'implemented-in::c',
......
......@@ -20,7 +20,6 @@ __license__ = """
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import apt
import commands
import datetime
import glob
......@@ -33,11 +32,12 @@ import xapian
import apprecommender.data as data
from apprecommender.error import Error
from apprecommender.singleton import Singleton
from apprecommender.apt_cache import AptCache
from apprecommender.config import Config
from apprecommender.decider import (FilterTag, FilterDescription,
FilterTag_or_Description)
from apprecommender.config import Config
from apprecommender.error import Error
from apprecommender.singleton import Singleton
class DemographicProfile(Singleton):
......@@ -257,7 +257,7 @@ class User:
Return list of packages that are not dependence of any other package in
the list.
"""
cache = apt.Cache()
cache = AptCache()
old_profile_size = len(self.pkg_profile)
for p in self.pkg_profile[:]: # iterate list copy
......
#!/bin/sh
APPREC_DATA=~/.apprecommender python -m apprecommender.main.cli $@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment