-
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 #10 from tmu-nlp/tomoki
testcommit
- Loading branch information
Showing
10 changed files
with
493 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,48 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "8eb58b71", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"ename": "SyntaxError", | ||
"evalue": "invalid syntax (Temp/ipykernel_12420/270510482.py, line 2)", | ||
"output_type": "error", | ||
"traceback": [ | ||
"\u001b[1;36m File \u001b[1;32m\"C:\\Users\\81807\\AppData\\Local\\Temp/ipykernel_12420/270510482.py\"\u001b[1;36m, line \u001b[1;32m2\u001b[0m\n\u001b[1;33m $ git clone https://github.com/tmu-nlp/100knock2024.git\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"#No0(文字列の逆順)\n", | ||
"$ git clone https://github.com/tmu-nlp/100knock2024.git\n", | ||
"s=\"stressed\"\n", | ||
"s_reversed=s[::-1]\n", | ||
"print(s_reversed)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,38 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5f253e2f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#No1(「パタトクカシー」)\n", | ||
"word=\"パタトクカシー\"\n", | ||
"answer=word[::2]\n", | ||
"print(answer)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,39 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6621d739", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#No2(「パトカー」+「タクシー」=「パタトクカシーー」)\n", | ||
"answer = \"\"\n", | ||
"for i in range(0,4):\n", | ||
" answer += \"パトカー\"[i] + \"タクシー\"[i]\n", | ||
"print(answer)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,44 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "28967523", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#No3(円周率)\n", | ||
"sentence=\"Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics.\"\n", | ||
"k={\",\":None,\".\":None}\n", | ||
"l=str.maketrans(k)\n", | ||
"sentence2=sentence.translate(l)\n", | ||
"Pi=sentence2.split()\n", | ||
"list=[]\n", | ||
"for i in Pi:\n", | ||
" list.append(len(i))\n", | ||
"print(list)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,44 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "b76dbf8f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#No4(元素記号)\n", | ||
"sentence=\"Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can.\"\n", | ||
"num=[1,5,6,7,8,9,15,16,19]\n", | ||
"element_dict={}\n", | ||
"for i, j in enumerate(sentence.split(),1):\n", | ||
" if i in num:\n", | ||
" element_dict[j[0]]=i\n", | ||
" else:\n", | ||
" element_dict[j[0:2]]=i\n", | ||
"print(element_dict)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,62 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "b18c669a", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"[['I', 'am'], ['am', 'an'], ['an', 'NLPer'], ['NLPer']]\n", | ||
"['I ', ' a', 'am', 'm ', ' a', 'an', 'n ', ' N', 'NL', 'LP', 'Pe', 'er', 'r']\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"#No05(n-gram)\n", | ||
"sentence='I am an NLPer'\n", | ||
"\n", | ||
"def ngram(S,n):\n", | ||
" list=[]\n", | ||
" #ngramを作成する時、繰り返し回数は必ずlen(S)以下になる。\n", | ||
" for i in range(len(S)):\n", | ||
" try:\n", | ||
" list.append(S[i:i+n])\n", | ||
" \n", | ||
" # list out of range(余分な繰り返し)はNoneにする。 \n", | ||
" except IndexError:\n", | ||
" None\n", | ||
" return list\n", | ||
" \n", | ||
"print(ngram(sentence.split(),2))\n", | ||
"print(ngram(sentence,2))\n", | ||
"\n", | ||
"#n-gram 任意の文字数(単語数)で文章を分割する手法のこと" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.18" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,74 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "53c3fd9e", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"{'di', 'ar', 'ap', 'se', 'is', 'e', 'ra', 'ad', 'pa'}\n", | ||
"{'ar', 'ap', 'ph', 'h', 'gr', 'ra', 'ag', 'pa'}\n", | ||
"{'di', 'ar', 'ap', 'ph', 'h', 'se', 'is', 'e', 'gr', 'ra', 'ag', 'ad', 'pa'}\n", | ||
"{'ar', 'ap', 'pa', 'ra'}\n", | ||
"{'di', 'se', 'is', 'e', 'ad'}\n", | ||
"Xにreが含まれる\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"#NO6(集合)\n", | ||
"sentence='paraparaparadise'\n", | ||
"sentence2=\"paragraph\"\n", | ||
"\n", | ||
"def ngram(S,n):\n", | ||
" list=[]\n", | ||
" for i in range(len(S)):\n", | ||
" try:\n", | ||
" list.append(S[i:i+n])\n", | ||
" \n", | ||
" except IndexError:\n", | ||
" None\n", | ||
" return list\n", | ||
" \n", | ||
"X=set(ngram(sentence,2))\n", | ||
"Y=set(ngram(sentence2,2))\n", | ||
"\n", | ||
"print(X)\n", | ||
"print(Y)\n", | ||
"print(X.union(Y))\n", | ||
"print(X.intersection(Y))\n", | ||
"print(X.difference(Y))\n", | ||
"\n", | ||
"if \"se\" in X:\n", | ||
" print(\"Xにreが含まれる\")\n", | ||
"if \"se\" in Y:\n", | ||
" print(\"Yにreが含まれる\")" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
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,38 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "7f176f90", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#No07(テンプレートによる文作成)\n", | ||
"def template(x,y,z):\n", | ||
" print(str(x)+\"時の\"+y+\"は\"+str(z))\n", | ||
"template(12,\"気温\",22.4)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.