File size: 981 Bytes
6c50d1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from nltk.stem import PorterStemmer


class WordUtil:

    @staticmethod
    def extract_specific_resource_name(word):
        res = set()
        for target in word.split('-'):
            if len(target) > 0:
                res.add(target)
        for target in word.split('.'):
            if len(target) > 0:
                res.add(target)
        for target in word.split('_'):
            if len(target) > 0:
                res.add(target)
        return res

    @staticmethod
    def get_path_resource_list(path):
        stemmer = PorterStemmer()
        res = []
        target = path
        target = target.replace('{', '')
        target = target.replace('}', '')
        target = target.split('/')
        for word in target:
            if len(word) == 0:
                continue
            for split_word in WordUtil.extract_specific_resource_name(word):
                stemmed = stemmer.stem(split_word)
                res.append(stemmed)
        return res