def load_index(self, fn):
     """
     Loads a pre-computed index (or indices) so we can answer queries.
     Input:
         fn - file name of pickled index.
     """
     return utils.load_obj(name=fn)
    def update_tweets_postings(self):
        """

        :return:
        """
        for i in range(self.tweets_postings_counter):
            tweets_postings_file = utils.load_obj(
                str(i + 1), self.config.get_tweets_postings_path())
            for doc_id in tweets_postings_file.keys():
                tweet_posting = tweets_postings_file[doc_id]
                self.update_single_tweet_postings(tweet_posting)
            utils.save_obj(tweets_postings_file, str(i + 1),
                           self.config.get_tweets_postings_path())
Пример #3
0
 def get_relevant_tweets_postings(self, relevant_tweets):
     """
     iterates over tweets postings and extracts postings of all relevant tweets.
     :param relevant_tweets: set of relevant tweets based on query's terms
     :return: postings of every relevant tweet.
     """
     relevant_tweets_information = dict()
     for i in range(self._indexer.get_tweets_postings_counter()):
         tweets_postings_file = utils.load_obj(
             str(i + 1),
             self._indexer.get_config().get_tweets_postings_path())
         for doc_id in relevant_tweets:
             if doc_id in tweets_postings_file.keys():
                 relevant_tweets_information[doc_id] = tweets_postings_file[
                     doc_id]
     return relevant_tweets_information