Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import difflib | |
import unicodedata | |
def get_char_width_list(text): | |
"""text の文字ごとの幅をリストで返す | |
半角の場合は1, 全角の場合は2 | |
""" | |
result = [] | |
for c in text: | |
if unicodedata.east_asian_width(c) in ["F", "W"]: |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import lzma | |
import sys | |
import glob | |
def load_xz_ngram_file(n=2): | |
ngram_dict = {} | |
ngram_freq = {} | |
files = glob.glob("/path/to/nwc2010-ngrams/word/over999/{}gms/*.xz".format(n)) | |
for file in files: | |
print(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.base import BaseEstimator | |
import MeCab | |
class OwakatiTokenizer(BaseEstimator): | |
def __init__(self, dicdir=None, rcfile=None): | |
""" | |
:param dicdir: system dicdir `-d` | |
:param rcfile: resource file `-r` | |
""" |
NewerOlder