Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit my name #5

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions HW1_R10631036/HW1_R10631036.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"HW1_R10631036.ipynb","provenance":[],"collapsed_sections":[],"authorship_tag":"ABX9TyOsUhFTdgiiW8RVaGR7DeN+"},"kernelspec":{"name":"python3","display_name":"Python 3"},"language_info":{"name":"python"}},"cells":[{"cell_type":"code","source":["from google.colab import drive\n","drive.mount('/content/drive')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"SDqvyuFwultw","executionInfo":{"status":"ok","timestamp":1657184768121,"user_tz":-480,"elapsed":22146,"user":{"displayName":"許伯豪","userId":"04905258514356166770"}},"outputId":"b7fa6d8f-d79f-471b-c95c-23bd5136786b"},"execution_count":4,"outputs":[{"output_type":"stream","name":"stdout","text":["Mounted at /content/drive\n"]}]},{"cell_type":"code","source":["raw_path = '/content/drive/MyDrive/Bioimformatic algorithem/week1/2022summer-git-python_basics/HW1'\n","data = '/HW1.txt'\n"],"metadata":{"id":"bQ5GuPyrupxW","executionInfo":{"status":"ok","timestamp":1657184769315,"user_tz":-480,"elapsed":6,"user":{"displayName":"許伯豪","userId":"04905258514356166770"}}},"execution_count":5,"outputs":[]},{"cell_type":"code","source":["count = 0\n","random_noise = '!?+-'\n","without_noise = 0\n","with open(raw_path+data, 'r') as f:\n"," for i in f:\n"," count += 1\n"," if (random_noise in i):\n"," without_noise += 1\n"," continue\n"," print('total number of sentences is %d' % count)\n"," print('total number of sentences without noise is %d' % without_noise)\n"],"metadata":{"colab":{"base_uri":"https://localhost:8080/"},"id":"9kxLLbxzxcUT","executionInfo":{"status":"ok","timestamp":1657197483172,"user_tz":-480,"elapsed":280,"user":{"displayName":"許伯豪","userId":"04905258514356166770"}},"outputId":"ea5ac619-ccff-4d10-d729-9dc97bf89166"},"execution_count":59,"outputs":[{"output_type":"stream","name":"stdout","text":["total number of sentences is 539\n","total number of sentences without noise is 21\n"]}]},{"cell_type":"code","source":["def lensort(len_dic, i):\n"," if len(i) <= 40:\n"," len_dic['<=40'] += 1\n"," elif 40 < len(i) <= 50:\n"," len_dic['<=50'] += 1\n"," elif 50 < len(i) <= 60:\n"," len_dic['<=60'] += 1\n"," elif 60 < len(i) <= 70:\n"," len_dic['<=70'] += 1\n"," elif 70 < len(i) <= 80:\n"," len_dic['<=80'] += 1 \n"," elif len(i) > 80:\n"," len_dic['>80'] += 1\n"," return len_dic"],"metadata":{"id":"NVI47_0Fgzlk","executionInfo":{"status":"ok","timestamp":1657195610591,"user_tz":-480,"elapsed":314,"user":{"displayName":"許伯豪","userId":"04905258514356166770"}}},"execution_count":52,"outputs":[]},{"cell_type":"code","source":["count = 0\n","random_noise = '!?+-'\n","without_noise = 0\n","len_dic_before = {'<=40':0, '<=50':0, '<=60':0, '<=70':0, '<=80':0, '>80':0}\n","len_dic_after = {'<=40':0, '<=50':0, '<=60':0, '<=70':0, '<=80':0, '>80':0}\n","with open(raw_path+data, 'r') as f:\n"," for i in f:\n"," len_dic_before = lensort(len_dic_before, i)\n","with open(raw_path+data, 'r') as f:\n"," for i in f:\n"," if (random_noise not in i):\n"," len_dic_after = lensort(len_dic_after, i)\n","\n","with open(raw_path+data, 'r') as f:\n"," for i in f:\n"," if (random_noise in i):\n"," for a in i:\n"," if (a in random_noise):\n"," i=i.replace(a, '')\n"," len_dic_after = lensort(len_dic_after, i)\n"," \n"," \n"],"metadata":{"id":"IoLU_w_p9cQa","executionInfo":{"status":"ok","timestamp":1657195613133,"user_tz":-480,"elapsed":345,"user":{"displayName":"許伯豪","userId":"04905258514356166770"}}},"execution_count":53,"outputs":[]},{"cell_type":"code","source":["with open('/content/drive/MyDrive/Bioimformatic algorithem/week1/2022summer-git-python_basics/HW1_R10631036/HW1_R10631036.txt', 'w')as f:\n"," f.write('There are {} sentences in HW1.txt. {} of them include !?+-.'.format(count,without_noise)+'\\n')\n"," f.write('{} {} {}'.format('length', 'before trim', 'after trim')+'\\n')\n"," for i in len_dic_after.keys():\n"," f.write('{0:>6}{1:>12}{2:>11}'.format(i, len_dic_before['%s'%i], len_dic_after['%s'%i])+'\\n')"],"metadata":{"id":"r6Oxbh5lnlTn","executionInfo":{"status":"ok","timestamp":1657201909181,"user_tz":-480,"elapsed":288,"user":{"displayName":"許伯豪","userId":"04905258514356166770"}}},"execution_count":100,"outputs":[]}]}
8 changes: 8 additions & 0 deletions HW1_R10631036/HW1_R10631036.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
There are 539 sentences in HW1.txt. 21 of them include !?+-.
length before trim after trim
<=40 27 28
<=50 161 164
<=60 156 155
<=70 121 121
<=80 61 60
>80 13 11
1 change: 1 addition & 0 deletions python_basics/0705.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
push test
1 change: 1 addition & 0 deletions python_basics/name.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
my name is BaronHsu