김건

3차 개발사항 일부 기능 함수 추가

...@@ -120,16 +120,6 @@ def download_comments(youtube_id, sleep=1): ...@@ -120,16 +120,6 @@ def download_comments(youtube_id, sleep=1):
120 yield comment 120 yield comment
121 time.sleep(sleep) 121 time.sleep(sleep)
122 122
123 -
124 -
125 -def goto_Menu(result_List) :
126 - for i in range (len(result_List)) :
127 - a = str(result_List[i]['text'])
128 - if('상무' in a) :
129 - print((result_List)[i]['text'])
130 - else :
131 - print('Not Found')
132 -
133 ## input video 값 parsing 123 ## input video 값 parsing
134 def video_id(value): 124 def video_id(value):
135 query = urlparse(value) 125 query = urlparse(value)
...@@ -174,7 +164,6 @@ def main(): ...@@ -174,7 +164,6 @@ def main():
174 raise ValueError('올바른 입력 값을 입력하세요') 164 raise ValueError('올바른 입력 값을 입력하세요')
175 165
176 print('Downloading Youtube comments for video:', youtube_id) 166 print('Downloading Youtube comments for video:', youtube_id)
177 - count = 0
178 Number = input(' 저장 - 0 저장 안함- 1 : ') 167 Number = input(' 저장 - 0 저장 안함- 1 : ')
179 if Number == '0' : 168 if Number == '0' :
180 Output1 = input('결과를 받을 파일 입력 :') 169 Output1 = input('결과를 받을 파일 입력 :')
...@@ -198,14 +187,22 @@ def main(): ...@@ -198,14 +187,22 @@ def main():
198 break 187 break
199 188
200 else : 189 else :
190 + count = 0
201 i = 0 191 i = 0
192 + limit = 40
202 for comment in download_comments(youtube_id): 193 for comment in download_comments(youtube_id):
203 - result_List.append(comment) 194 + dic = {}
195 + dic['cid'] = comment['cid']
196 + dic['text'] = comment['text']
197 + dic['time'] = comment['time']
198 + dic['author'] = comment['author']
199 + result_List.append(dic)
204 count += 1 200 count += 1
205 i += 1 201 i += 1
206 - if limit and count >= limit: 202 + if limit == count :
203 + print(' Comment Thread 생성 완료')
204 + print ('\n\n\n\n\n\n\n')
207 break 205 break
208 - print('\nDone!')
209 return result_List 206 return result_List
210 #goto_Menu(result_List) 207 #goto_Menu(result_List)
211 208
......
1 import downloader 1 import downloader
2 from time import sleep 2 from time import sleep
3 3
4 +def print_result(Comment_List) :
5 + for var in Comment_List :
6 + print(var)
7 + print('******* 검색 완료 *******')
8 + print('\n\n\n')
9 +
10 +def search_by_author(Comment_List,author_name) :
11 + result_List = []
12 +
13 + for var in Comment_List :
14 + if (var['author'] == author_name) :
15 + result_List.append(var)
16 +
17 + return result_List
18 +def search_by_keyword(Comment_List,keyword) :
19 + result_List = []
20 + for var in Comment_List :
21 + print(var['text'])
22 + if ( keyword in var['text']) :
23 + result_List.append(var)
24 +
25 + return result_List
4 def call_main (): 26 def call_main ():
5 print(' Comment Thread 생성중 \n') 27 print(' Comment Thread 생성중 \n')
6 28
...@@ -13,6 +35,10 @@ def call_main (): ...@@ -13,6 +35,10 @@ def call_main ():
13 print(' **************************************************************') 35 print(' **************************************************************')
14 print(' **************************************************************') 36 print(' **************************************************************')
15 a = downloader.main() 37 a = downloader.main()
38 + author_results = search_by_author(a,'광고제거기')
39 + text_resutls = search_by_keyword(a,'지현')
40 + print_result(author_results)
41 + print_result(text_resutls)
16 return a 42 return a
17 43
18 CommentList = call_main() 44 CommentList = call_main()
......
1 -Youtube Comment Threads를 받아오는 코드 2차 수정 사항 1 +Youtube 3차 수정 사항
2 ----------------------------------------------------- 2 -----------------------------------------------------
3 1차에서 추가적으로 구현 할 사항 3 1차에서 추가적으로 구현 할 사항
4 4
...@@ -20,4 +20,17 @@ Youtube Comment Threads를 받아오는 코드 2차 수정 사항 ...@@ -20,4 +20,17 @@ Youtube Comment Threads를 받아오는 코드 2차 수정 사항
20 20
21 1. Module 분리 (List 반환 모듈, Main 부분) -> 굳이 분리하지 않을 경우 21 1. Module 분리 (List 반환 모듈, Main 부분) -> 굳이 분리하지 않을 경우
22 추가적으로 함수를 구현해야함 22 추가적으로 함수를 구현해야함
23 -2. 본격적으로 Data Set을 어떤 식으로 분리하여 제공 할지에 대한 추가적인 기능 구현 필요
...\ No newline at end of file ...\ No newline at end of file
23 +2. 본격적으로 Data Set을 어떤 식으로 분리하여 제공 할지에 대한 추가적인 기능 구현 필요
24 +
25 +-----------------------------------------------------
26 +
27 +1. 2차 개발사항에서 오류가 있던 부분을 수정하였음
28 +2. 가져온 Comment를 가공하여 처리할 수 있도록 일부 함수 구현
29 + (1) 키워드를 통해 검색할 수 있도록 함수 구현
30 + (2) 작성자 이름을 통해 검색할 수 있도록 함수 구현
31 +
32 +-----------------------------------------------------
33 +추가 구현 사항
34 +
35 +1. konlpy (http://konlpy.org/ko/latest/)를 통하여 명사 추출 후 keyword 분석하기
36 +2. 시간대를 추출하여 시간대 별로 Comment 정리하기
......