0

More than 1 year has passed since last update.

# 言語処理100本ノック解いてみた 6

Posted at
``````str1 = "paraparaparadise"
str2 = "paragraph"
def bigram(string):
return [string[i:i+2] for i in range(len(string)-1)]
X = bigram(str1)
Y = bigram(str2)
print(X+Y)
dup = [_ for _ in X if _ in Y]
print([_ for _ in X if _ not in dup],[_ for _ in Y if _ not in dup])
print([[_,__]for _ in X for __ in Y])
if "se" in X: print("X")
elif "se" in Y: print("Y")
else: print("None")
"""
['pa', 'ar', 'ra', 'ap', 'pa', 'ar', 'ra', 'ap', 'pa', 'ar', 'ra', 'ad', 'di', 'is', 'se', 'pa', 'ar', 'ra', 'ag', 'gr', 'ra', 'ap', 'ph']
['ad', 'di', 'is', 'se'] ['ag', 'gr', 'ph']
[['pa', 'pa'], ['pa', 'ar'], ['pa', 'ra'], ['pa', 'ag'], ['pa', 'gr'], ['pa', 'ra'], ['pa', 'ap'], ['pa', 'ph'], ['ar', 'pa'], ['ar', 'ar'], ['ar', 'ra'], ['ar', 'ag'], ['ar', 'gr'], ['ar', 'ra'], ['ar', 'ap'], ['ar', 'ph'], ['ra', 'pa'], ['ra', 'ar'], ['ra', 'ra'], ['ra', 'ag'], ['ra', 'gr'], ['ra', 'ra'], ['ra', 'ap'], ['ra', 'ph'], ['ap', 'pa'], ['ap', 'ar'], ['ap', 'ra'], ['ap', 'ag'], ['ap', 'gr'], ['ap', 'ra'], ['ap', 'ap'], ['ap', 'ph'], ['pa', 'pa'], ['pa', 'ar'], ['pa', 'ra'], ['pa', 'ag'], ['pa', 'gr'], ['pa', 'ra'], ['pa', 'ap'], ['pa', 'ph'], ['ar', 'pa'], ['ar', 'ar'], ['ar', 'ra'], ['ar', 'ag'], ['ar', 'gr'], ['ar', 'ra'], ['ar', 'ap'], ['ar', 'ph'], ['ra', 'pa'], ['ra', 'ar'], ['ra', 'ra'], ['ra', 'ag'], ['ra', 'gr'], ['ra', 'ra'], ['ra', 'ap'], ['ra', 'ph'], ['ap', 'pa'], ['ap', 'ar'], ['ap', 'ra'], ['ap', 'ag'], ['ap', 'gr'], ['ap', 'ra'], ['ap', 'ap'], ['ap', 'ph'], ['pa', 'pa'], ['pa', 'ar'], ['pa', 'ra'], ['pa', 'ag'], ['pa', 'gr'], ['pa', 'ra'], ['pa', 'ap'], ['pa', 'ph'], ['ar', 'pa'], ['ar', 'ar'], ['ar', 'ra'], ['ar', 'ag'], ['ar', 'gr'], ['ar', 'ra'], ['ar', 'ap'], ['ar', 'ph'], ['ra', 'pa'], ['ra', 'ar'], ['ra', 'ra'], ['ra', 'ag'], ['ra', 'gr'], ['ra', 'ra'], ['ra', 'ap'], ['ra', 'ph'], ['ad', 'pa'], ['ad', 'ar'], ['ad', 'ra'], ['ad', 'ag'], ['ad', 'gr'], ['ad', 'ra'], ['ad', 'ap'], ['ad', 'ph'], ['di', 'pa'], ['di', 'ar'], ['di', 'ra'], ['di', 'ag'], ['di', 'gr'], ['di', 'ra'], ['di', 'ap'], ['di', 'ph'], ['is', 'pa'], ['is', 'ar'], ['is', 'ra'], ['is', 'ag'], ['is', 'gr'], ['is', 'ra'], ['is', 'ap'], ['is', 'ph'], ['se', 'pa'], ['se', 'ar'], ['se', 'ra'], ['se', 'ag'], ['se', 'gr'], ['se', 'ra'], ['se', 'ap'], ['se', 'ph']]
X
"""
``````

しかし本当に解くわけがわからないので機械学習にジャンプします。

Register as a new user and use Qiita more conveniently

1. You get articles that match your needs
2. You can efficiently read back useful information
What you can do with signing up
0