コード例 #1
0
ファイル: WordCount.py プロジェクト: FoVNull/NLPDemo_py
    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)
コード例 #2
0
ファイル: test.py プロジェクト: TAOJIANGCAI/myPythonNotes
def intersect(nums1, nums2):
    a, b = map(Counter, (nums1, nums2))
    return list((a & b).elements())
    Counter.elements()