Exemplo n.º 1
0
    def filterStopwords(self, counter: collections.Counter,
                        stopListPath: str) -> collections.Counter:
        wordList = []
        for i in counter.elements():
            wordList.append(i)

        stopSets = self.generateStopSets(stopListPath)
        filterRes = filter(
            lambda i: not stopSets.__contains__(i) and i != '' and i != ' ',
            wordList)

        return collections.Counter(filterRes)
Exemplo n.º 2
0
def intersect(nums1, nums2):
    a, b = map(Counter, (nums1, nums2))
    return list((a & b).elements())
    Counter.elements()