-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from tmu-nlp/shota
- Loading branch information
Showing
10 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
text = "stressed" | ||
print(text[::-1]) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
text = "パタトクカシーー" | ||
for i in range(len(text)): | ||
if i%2 != 0: | ||
print(text[i],end = "") | ||
print("") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
text1 = "パトカー" | ||
text2 = "タクシー" | ||
for i in range(4): | ||
print(text1[i]+text2[i],end = "") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
text = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." | ||
print(text.split()) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
text = "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can." | ||
ls = text.split() | ||
num = [1,5,6,7,8,9,15,16,19] | ||
ans = {} | ||
|
||
for i in range(len(ls)): | ||
if i+1 in num: | ||
ans[ls[i][0]] = i+1 | ||
else: | ||
ans[ls[i][0:2]] = i+1 | ||
|
||
print(ans) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
def n_gram(text,n): | ||
ls = [] | ||
for i in range(0,len(text)-n+1): | ||
ls.append(text[i:i+n]) | ||
return ls | ||
|
||
text = "I am an NLPer" | ||
text_ = text.split() | ||
|
||
print(text_) | ||
|
||
print(n_gram(text,2)) | ||
print(n_gram(text_,2)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
text1 = "paraparaparadise" | ||
text2 = "paragraph" | ||
|
||
def n_gram(text,n): | ||
ls = [] | ||
for i in range(0,len(text)-n+1): | ||
ls.append(text[i:i+n]) | ||
return ls | ||
|
||
X = set(n_gram(text1,2)) | ||
Y = set(n_gram(text2,2)) | ||
|
||
print("union >>",X | Y) | ||
print("intersection >>",X & Y) | ||
print("difference >>",X - Y) | ||
|
||
if "se" in X: | ||
print("'se' is in X") | ||
else: | ||
print("'se' is not in X") | ||
|
||
if "se" in Y: | ||
print("'se' is in Y") | ||
else: | ||
print("'se' is not in Y") |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
print("input X,Y,Z >> ",end = "") | ||
X,Y,Z = map(str,input().split()) | ||
|
||
print("{}時の{}は{}".format(X,Y,Z)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
text = input() | ||
|
||
def ciper(text): | ||
cipered = "" | ||
for c in text: | ||
asc = ord(c) | ||
if 97 <= asc <= 122: | ||
c = chr(219-asc) | ||
cipered += c | ||
return cipered | ||
|
||
def deciper(text): | ||
decipered = "" | ||
for c in text: | ||
asc = ord(c) | ||
if 97 <= asc <= 122: | ||
c = chr(219-asc) | ||
decipered += c | ||
return decipered | ||
|
||
cipered_text = ciper(text) | ||
print(" cipered_text >> ",cipered_text) | ||
|
||
decipered_text = deciper(cipered_text) | ||
print("decipered_text >> ",decipered_text) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import random | ||
text = list(input().split()) | ||
|
||
for words in text: | ||
if len(words) > 4: | ||
head = words[0] | ||
tail = words[len(words)-1] | ||
|
||
body = list(words[1:len(words)-1]) | ||
random.shuffle(body) | ||
body = "".join(body) | ||
|
||
words = head + str(body) + tail | ||
|
||
print(words,end=" ") | ||
print("") |