def open(self, filename):
        """Method to open a file in the corpus.
        Returns a file object.

        :param filename: Name of a particular file in the corpus.
        """
        return utils.load_txt(self.abspath(filename))
Beispiel #2
0
    def open(self, filename):
        """Method to open a file in the corpus.
        Returns a file object.

        :param filename: Name of a particular file in the corpus.
        """
        return utils.load_txt(self.abspath(filename))
Beispiel #3
0
 def open(self, encoding='utf-8'):
     return utils.load_txt(self.path)
Beispiel #4
0
    return dict


def wordCount(name, f):
    file = open(f, 'r', encoding="utf-8")
    wordcount = Counter(file.read().split())
    with open('c:\\temp\\text\\' + name + '.count', mode="w",
              encoding="utf8") as f:
        for item in wordcount.items():
            print(item[0] + ',' + str(item[1]), file=f)


def getName(path):
    s = path.rfind(os.sep)
    e = path.rfind('.')
    return path[s + 1:e]


if __name__ == '__main__':
    kkma = Kkma()
    files = glob.glob("c:\\temp\\text\\*.txt")
    for f in files:
        print(f)
        name = getName(f)
        info = getDiv(f)
        writeResult1(name, 'info', info)
        doc = utils.load_txt(f).read()
        pos = Kkma().pos(doc)
        writeResult(name, 'pos', getTags(pos), info)
 def open(self, encoding='utf-8'):
     return utils.load_txt(self.path)
Beispiel #6
0
def wordCount(name, f):
    file = open(f,'r', encoding="utf-8")
    wordcount = Counter(file.read().split())
    with open('c:\\temp\\text\\' + name + '.count', mode="w", encoding="utf8") as f:
        for item in wordcount.items():
            print(item[0] + ',' + str(item[1]), file=f)

def getName(path):
    s = path.rfind(os.sep)
    e = path.rfind('.')
    return path[s+1:e]

if __name__=='__main__':
    kkma = Kkma()
    files = glob.glob("c:\\temp\\text\\*.txt")
    for f in files:
        print(f)
        name = getName(f)
        info = getDiv(f)
        writeResult1(name, 'info', info)
        doc = utils.load_txt(f).read()
        pos = Kkma().pos(doc)
        writeResult(name, 'pos', getTags(pos), info)