김서영

final update

Showing 74 changed files with 2197 additions and 0 deletions
# New_Musical_Genre
본 연구는 경희대학교 "데이터분석캡스톤디자인" 수업에서 진행되었습니다.
[CMU]: http://www.cs.cmu.edu/~ark/personas/ "Go CMU Movie Summary Corpus"
## Overview
### Needs
현재 뮤지컬은 오리지널 / 라이선스 / 창작 뮤지컬로 장르가 나뉘어져 있습니다.
이는 로맨스 / 판타지 / 에세이 등으로 나뉘어진 소설, SF / 코미디 / 공포 / 멜로 등으로 나누어져 있으며 영화와는 달리 장르를 보고 내용을 유추하기 어렵습니다. 공식 티켓 판매처(인터파크 티켓, 예스24 공연 등)에도 역시 관련 장르 구분이 되어있지 않은 것을 볼 수 있습니다.
장르를 모르기 때문에 작품 선택에 제한이 있으며 접근성 역시 떨어집니다. 따라서 인터넷상으로 확인할 수 있는 작품 소개와 시놉시스, 대본, 넘버(노래)를 통해 작품의 특징적인 요소로 장르를 나누어 시각적으로 표현하고자 합니다.
### Goals
뮤지컬 작품의 핵심요소를 텍스트 분석을 통해 파악하여 문학적 장르(fantasy, history, romance, social, thriller)로 구분한다. 또한, 분류된 장르를 시각화하는 방법에 대해 연구한다.
학습 데이터는 약 42,306개로, [CMU Movie Summary Corpus][CMU]의 Detaset을 이용합니다. 적용 데이터는 https://broadwaymusicalhome.com/shows.htm 의 홈페이지에서 크롤링한 시놉시스와 줄거리를 기반으로 합니다.
도출된 장르 근접도를 바탕으로 시각화 결과 이미지를 통해 해당 뮤지컬이 갖는 장르 근접도 정보를 한 눈에 볼 수 있다. 시각화 결과 이미지를 통해 한 뮤지컬이 갖는 복합 장르적 특성을 수 있습니다. 뮤지컬 속 다양한 장르의 존재성을 알림과 동시에 매니아 층이 아닌 일반 관객들의 뮤지컬에 대한 접근성을 높일 수 있습니다. 또한 소비자들이 선호하는 장르를 바탕으로 추천 시스템 등의 서비스 분야에도 다양하게 활용될 수 있습니다.
### 활용 도구
- 데이터 크롤링 : requests, BeautifulSoup 모듈을 이용해 뮤지컬 작품설명, 줄거리 등의 텍스트 크롤링
- 자연어 처리 : NLTK 패키지를 통한 형태소 / 명사 단위로 단어 추출 및 단어 빈도 분석, LSTN
- 장르 분류 : 의사결정나무 모델, RNN, k-nearest neighbor
- 장르 검증 : k-fold 교차 검증
- 장르 시각화 : matplot, Seaborn 패키지를 통한 시각화
## Model
- 데이터 수집 : [CMU Movie Summary Corpus][CMU]의 Detaset 42,306개, 뮤지컬 줄거리 255개
- 데이터 전처리 : Detaset 토큰화, 불용어 처리 후 정수 인코딩
- 데이터 분석 : 의사결정나무 모델, RNN, k-nearest neighbor < 연구중
- 데이터 검증 : k-fold 교차검증을 활용하여 장르별 정확도를 확인
- 데이터 시각화 : 분석된 장르를 장르 단어 분포도로 시각화한다.
## Schedule
__3월__
- 주제 선정
__4월__
- 뮤지컬 줄거리 웹 크롤링
- 테스트 데이터 라벨링
__5월__
- 데이터 전처리
+ 토큰화 (완료)
+ 라벨링 (진행중)
This diff is collapsed. Click to expand it.
This file is too large to display.
This diff is collapsed. Click to expand it.
No preview for this file type
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#-*- coding: utf-8 -*-\n",
"\n",
"import os\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def print_files_in_dir(root_dir, prefix):\n",
" files = os.listdir(root_dir)\n",
" fileList= []\n",
" for file in files:\n",
" if file == \".DS_Store\":\n",
" continue\n",
" path = os.path.join(root_dir, file)\n",
" fileList.append(prefix + path)\n",
" return fileList\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"C://Users//김서영//Desktop//temp//data//romance\\그리스.txt\n",
"C://Users//김서영//Desktop//temp//data//romance\\리틀잭.txt\n",
"C://Users//김서영//Desktop//temp//data//romance\\사랑은비를타고.txt\n",
"C://Users//김서영//Desktop//temp//data//romance\\시라노넘버.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\jesus_christ_superstar.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\더데빌.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\위키드.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\지저스크라이스트수퍼스타.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\지킬앤하이드.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\프랑켄슈타인.txt\n",
"C://Users//김서영//Desktop//temp//data//etc\\레미제라블.txt\n",
"C://Users//김서영//Desktop//temp//data//etc\\사운드오브뮤직.txt\n",
"C://Users//김서영//Desktop//temp//data//etc\\스웨그에이지 외쳐 조선.txt\n"
]
},
{
"ename": "UnicodeDecodeError",
"evalue": "'utf-8' codec can't decode byte 0xbd in position 4: invalid start byte",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mUnicodeDecodeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-12-2a98c34edc2f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[0mfile\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'r'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'UTF-8'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 16\u001b[1;33m \u001b[0mAll\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfile\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 17\u001b[0m \u001b[0mlines\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mAll\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'\\n'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 18\u001b[0m \u001b[0mtotWords\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0midx\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mextend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlines\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\codecs.py\u001b[0m in \u001b[0;36mdecode\u001b[1;34m(self, input, final)\u001b[0m\n\u001b[0;32m 320\u001b[0m \u001b[1;31m# decode input (taking the buffer into account)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 321\u001b[0m \u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbuffer\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 322\u001b[1;33m \u001b[1;33m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconsumed\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_buffer_decode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0merrors\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfinal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 323\u001b[0m \u001b[1;31m# keep undecoded input until the next call\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 324\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbuffer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mconsumed\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mUnicodeDecodeError\u001b[0m: 'utf-8' codec can't decode byte 0xbd in position 4: invalid start byte"
]
}
],
"source": [
"\n",
"\n",
"romanceWords = [] #모든 로맨스파일 단어 모음\n",
"etcWords = [] #모든 기타파일 단어 모음\n",
"fantasyWords = [] #모든 판타지파일 단어 모음\n",
"\n",
"totWords = [[],[],[]] #로맨스 - 판타지 - 기타\n",
"\n",
"folderDir = [\"C://Users//김서영//Desktop//temp//data//romance\",\"C://Users//김서영//Desktop//temp//data//fantasy\",\n",
" \"C://Users//김서영//Desktop//temp//data//etc\"]\n",
"\n",
"\n",
"for idx, folder in enumerate(folderDir):\n",
" subPaths = print_files_in_dir(folder,\"\") #각 폴더 하위 파일 경로\n",
" for path in subPaths:\n",
" print(path)\n",
" file = open(path,'r',encoding='UTF-8')\n",
" All = file.read()\n",
" lines = All.split('\\n')\n",
" totWords[idx].extend(lines)\n",
"print(totWords)\n",
" \n",
"\n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 3, [5]]\n"
]
}
],
"source": [
"a = [1,2,3]\n",
"a.append([5])\n",
"print(a)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"from konlpy.tag import Okt\n",
"okt = Okt()\n",
"\n",
"\n",
"#형태소로 분류하는게 맞을듯,,!\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['유일하게', '항공기', '체계', '종합', '개발', '경험', '을', '갖고', '있는', 'kai', '는']\n"
]
}
],
"source": [
"okt.morphs(u'유일하게 항공기 체계 종합개발 경험을 갖고 있는 kai는')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def remove_values_from_list(the_list, val):\n",
" return [value for value in the_list if value != val]\n",
"\n",
"x = [1, 2, 3, 4, 2, 2, 3]\n",
"x = remove_values_from_list(x, 2)\n",
"\n",
"#이런식으로 조사 제거..??\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"#-*- coding: utf-8 -*-\n",
"\n",
"import os\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"def print_files_in_dir(root_dir, prefix):\n",
" files = os.listdir(root_dir)\n",
" fileList= []\n",
" for file in files:\n",
" if file == \".DS_Store\":\n",
" continue\n",
" path = os.path.join(root_dir, file)\n",
" fileList.append(prefix + path)\n",
" return fileList\n"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"C://Users//김서영//Desktop//temp//data//romance\\그리스.txt\n",
"C://Users//김서영//Desktop//temp//data//romance\\리틀잭.txt\n",
"C://Users//김서영//Desktop//temp//data//romance\\사랑은비를타고.txt\n",
"C://Users//김서영//Desktop//temp//data//romance\\시라노넘버.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\jesus_christ_superstar.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\더데빌.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\위키드.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\지저스크라이스트수퍼스타.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\지킬앤하이드.txt\n",
"C://Users//김서영//Desktop//temp//data//fantasy\\프랑켄슈타인.txt\n",
"C://Users//김서영//Desktop//temp//data//etc\\레미제라블.txt\n",
"C://Users//김서영//Desktop//temp//data//etc\\사운드오브뮤직.txt\n",
"C://Users//김서영//Desktop//temp//data//etc\\스웨그에이지 외쳐 조선.txt\n"
]
},
{
"ename": "UnicodeDecodeError",
"evalue": "'utf-8' codec can't decode byte 0xbd in position 4: invalid start byte",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mUnicodeDecodeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-12-2a98c34edc2f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 14\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[0mfile\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mopen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mpath\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m'r'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mencoding\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'UTF-8'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 16\u001b[1;33m \u001b[0mAll\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mfile\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 17\u001b[0m \u001b[0mlines\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mAll\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msplit\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m'\\n'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 18\u001b[0m \u001b[0mtotWords\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0midx\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mextend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlines\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;32mC:\\ProgramData\\Anaconda3\\lib\\codecs.py\u001b[0m in \u001b[0;36mdecode\u001b[1;34m(self, input, final)\u001b[0m\n\u001b[0;32m 320\u001b[0m \u001b[1;31m# decode input (taking the buffer into account)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 321\u001b[0m \u001b[0mdata\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbuffer\u001b[0m \u001b[1;33m+\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 322\u001b[1;33m \u001b[1;33m(\u001b[0m\u001b[0mresult\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mconsumed\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_buffer_decode\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0merrors\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mfinal\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 323\u001b[0m \u001b[1;31m# keep undecoded input until the next call\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 324\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbuffer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mconsumed\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mUnicodeDecodeError\u001b[0m: 'utf-8' codec can't decode byte 0xbd in position 4: invalid start byte"
]
}
],
"source": [
"\n",
"\n",
"romanceWords = [] #모든 로맨스파일 단어 모음\n",
"etcWords = [] #모든 기타파일 단어 모음\n",
"fantasyWords = [] #모든 판타지파일 단어 모음\n",
"\n",
"totWords = [[],[],[]] #로맨스 - 판타지 - 기타\n",
"\n",
"folderDir = [\"C://Users//김서영//Desktop//temp//data//romance\",\"C://Users//김서영//Desktop//temp//data//fantasy\",\n",
" \"C://Users//김서영//Desktop//temp//data//etc\"]\n",
"\n",
"\n",
"for idx, folder in enumerate(folderDir):\n",
" subPaths = print_files_in_dir(folder,\"\") #각 폴더 하위 파일 경로\n",
" for path in subPaths:\n",
" print(path)\n",
" file = open(path,'r',encoding='UTF-8')\n",
" All = file.read()\n",
" lines = All.split('\\n')\n",
" totWords[idx].extend(lines)\n",
"print(totWords)\n",
" \n",
"\n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 2, 3, [5]]\n"
]
}
],
"source": [
"a = [1,2,3]\n",
"a.append([5])\n",
"print(a)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
This diff is collapsed. Click to expand it.
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"#-*- coding:utf-8 -*-\n",
"#CP949\n",
"\n",
"path = 'C://Users//김서영//Desktop//temp//data//romance\\그리스.txt'\n",
"file = open(path,'r',encoding='UTF-8')\n",
"\n",
"All = file.read()\n",
"file.close()\n",
"lines = All.split('\\n')\n",
"\n",
" \n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 졸업했으면 얼마나 좋아? 야! 너 위장에 빵구난 거 아니니? \n"
]
}
],
"source": [
"print(lines[5])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from konlpy.tag import Okt\n",
"allMorphs = []\n",
"spliter = Okt()\n",
"for i in lines:\n",
" allMorphs.extend(spliter.morphs(i))\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'allMorphs' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-4-bbaecbdc51ad>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mallMorphs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mallMorphs\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mNameError\u001b[0m: name 'allMorphs' is not defined"
]
}
],
"source": [
"print(allMorphs)\n",
"print(len(allMorphs))\n",
"#phrases로 변경 시 빈도순 출력\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import urllib.request\n",
"from bs4 import BeautifulSoup\n",
"import requests\n",
"\n",
"url = \"http://www.playdb.co.kr/playdb/playdblist.asp?Page=40&sReqMainCategory=000001&sReqSubCategory=&sReqDistrict=&sReqTab=2&sPlayType=1&sStartYear=2019&sSelectType=1\"\n",
"req = urllib.request.urlopen(url)\n",
"res = req.read()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"soup = BeautifulSoup(res,'html.parser')\n",
"for link in soup.find_all('a'):\n",
" #a= link.get('href')\n",
" if 'PlaydbDetail' in link.get('href'):\n",
" paramcode = link.get('href')\n",
" print(link.get('href'))\n",
" print(paramcode)\n",
"\n",
" \n",
"##keywords = soup.find_all('span',class_='ah_k')\n",
"#get_text() == 데이터에서 문자열만 추출\n",
"#strip() == 데이터의 양옆 공백제거\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"웹 크롤링 후 csv 파일로 저장.\n",
"뒷페이지로 갈 수록 링크 사라지는 문제 해결 요청."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"import time\n",
"time.sleep(5)\n",
"\n",
"toturl = []\n",
"whole_source = \"\"\n",
"#171페이지까지 있음\n",
"for pageNo in range(1,172):\n",
" url = \"http://www.playdb.co.kr/playdb/playdblist.asp?Page=\" + str(pageNo) +\"&sReqMainCategory=000001&sReqSubCategory=&sReqDistrict=&sReqTab=2&sPlayType=1&sStartYear=2019&sSelectType=1\"\n",
" response = requests.get(url)\n",
" whole_source = whole_source + response.text\n",
" \n",
"f = open(\"/Users/김서영/Desktop/temp/data/playdblink.csv\", \"w\")\n",
"soup = BeautifulSoup(whole_source, 'html.parser')\n",
"for link in soup.find_all('a'):\n",
" if 'PlaydbDetail' in link.get('href'):\n",
" paramcode = link.get('href')\n",
" print(link.get('href'))\n",
" f.write(paramcode+\",\")\n",
" #toturl.append(link.get('href'))\n",
" #paramcode = soup.find('a')\n",
" #for link in soup.find_all('a'):\n",
" \n",
" \n",
"#print(toturl)\n",
" \n",
"##keywords = soup.find_all('span',class_='ah_k')\n",
"#get_text() == 데이터에서 문자열만 추출\n",
"#strip() == 데이터의 양옆 공백제거\n",
"#중복되는 url지우기!!!!!\n",
" \n",
" \n",
"# 데이터의 헤더부분을 입력한다.\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"f.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"이 아래로는 연습 해둔 것들. 실행 x"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"toturl = []\n",
"whole_source = \"\"\n",
"#171페이지까지 있음\n",
"for pageNo in range(1,172):\n",
" url = \"http://www.playdb.co.kr/playdb/playdblist.asp?Page=\" + str(pageNo) +\"&sReqMainCategory=000001&sReqSubCategory=&sReqDistrict=&sReqTab=2&sPlayType=1&sStartYear=2019&sSelectType=1\"\n",
" response = requests.get(url)\n",
" whole_source = whole_source + response.text\n",
"\n",
"soup = BeautifulSoup(whole_source, 'html.parser')\n",
" #soup = BeautifulSoup(res,'html.parser')\n",
"for link in soup.find_all('a'):\n",
" if 'PlaydbDetail' in link.get('href'):\n",
" paramcode = link.get('href')\n",
" #print(link.get('href'))\n",
" toturl.append(link.get('href'))\n",
" #paramcode = soup.find('a')\n",
" #for link in soup.find_all('a'):\n",
"print(toturl)\n",
" \n",
"##keywords = soup.find_all('span',class_='ah_k')\n",
"#get_text() == 데이터에서 문자열만 추출\n",
"#strip() == 데이터의 양옆 공백제거\n",
"#중복되는 url지우기!!!!!\n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"dataframe = pd.DataFrame(toturl)\n",
"dataframe.to_csv(\"/Users/김서영/Desktop/temp/mUrl.csv\", header = False, index = False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import urllib.request\n",
"from bs4 import BeautifulSoup\n",
"import requests\n",
"\n",
"url = \"http://www.playdb.co.kr/playdb/playdblist.asp?Page=40&sReqMainCategory=000001&sReqSubCategory=&sReqDistrict=&sReqTab=2&sPlayType=1&sStartYear=2019&sSelectType=1\"\n",
"req = urllib.request.urlopen(url)\n",
"res = req.read()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"soup = BeautifulSoup(res,'html.parser')\n",
"for link in soup.find_all('a'):\n",
" #a= link.get('href')\n",
" if 'PlaydbDetail' in link.get('href'):\n",
" paramcode = link.get('href')\n",
" print(link.get('href'))\n",
" print(paramcode)\n",
"\n",
" \n",
"##keywords = soup.find_all('span',class_='ah_k')\n",
"#get_text() == 데이터에서 문자열만 추출\n",
"#strip() == 데이터의 양옆 공백제거\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"웹 크롤링 후 csv 파일로 저장.\n",
"뒷페이지로 갈 수록 링크 사라지는 문제 해결 요청."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [],
"source": [
"import time\n",
"time.sleep(5)\n",
"\n",
"toturl = []\n",
"whole_source = \"\"\n",
"#171페이지까지 있음\n",
"for pageNo in range(1,172):\n",
" url = \"http://www.playdb.co.kr/playdb/playdblist.asp?Page=\" + str(pageNo) +\"&sReqMainCategory=000001&sReqSubCategory=&sReqDistrict=&sReqTab=2&sPlayType=1&sStartYear=2019&sSelectType=1\"\n",
" response = requests.get(url)\n",
" whole_source = whole_source + response.text\n",
" \n",
"f = open(\"/Users/김서영/Desktop/temp/data/playdblink.csv\", \"w\")\n",
"soup = BeautifulSoup(whole_source, 'html.parser')\n",
"for link in soup.find_all('a'):\n",
" if 'PlaydbDetail' in link.get('href'):\n",
" paramcode = link.get('href')\n",
" print(link.get('href'))\n",
" f.write(paramcode+\",\")\n",
" #toturl.append(link.get('href'))\n",
" #paramcode = soup.find('a')\n",
" #for link in soup.find_all('a'):\n",
" \n",
" \n",
"#print(toturl)\n",
" \n",
"##keywords = soup.find_all('span',class_='ah_k')\n",
"#get_text() == 데이터에서 문자열만 추출\n",
"#strip() == 데이터의 양옆 공백제거\n",
"#중복되는 url지우기!!!!!\n",
" \n",
" \n",
"# 데이터의 헤더부분을 입력한다.\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"f.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"이 아래로는 연습 해둔 것들. 실행 x"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"toturl = []\n",
"whole_source = \"\"\n",
"#171페이지까지 있음\n",
"for pageNo in range(1,172):\n",
" url = \"http://www.playdb.co.kr/playdb/playdblist.asp?Page=\" + str(pageNo) +\"&sReqMainCategory=000001&sReqSubCategory=&sReqDistrict=&sReqTab=2&sPlayType=1&sStartYear=2019&sSelectType=1\"\n",
" response = requests.get(url)\n",
" whole_source = whole_source + response.text\n",
"\n",
"soup = BeautifulSoup(whole_source, 'html.parser')\n",
" #soup = BeautifulSoup(res,'html.parser')\n",
"for link in soup.find_all('a'):\n",
" if 'PlaydbDetail' in link.get('href'):\n",
" paramcode = link.get('href')\n",
" #print(link.get('href'))\n",
" toturl.append(link.get('href'))\n",
" #paramcode = soup.find('a')\n",
" #for link in soup.find_all('a'):\n",
"print(toturl)\n",
" \n",
"##keywords = soup.find_all('span',class_='ah_k')\n",
"#get_text() == 데이터에서 문자열만 추출\n",
"#strip() == 데이터의 양옆 공백제거\n",
"#중복되는 url지우기!!!!!\n",
" \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"dataframe = pd.DataFrame(toturl)\n",
"dataframe.to_csv(\"/Users/김서영/Desktop/temp/mUrl.csv\", header = False, index = False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 계획한 방법을 간단한 모델을 통해 test"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"romance = ['사랑','열정','편지','감성','약혼','고백','결혼식','첫날밤',\n",
" '낭만','황홀','아름다운','로맨틱','감동적','외사랑','따뜻','순수']\n",
"#그리스, 리틀잭, 로미오와 줄리엣, 시라노\n",
"\n",
"fantasy = ['마법사','예언','운명','전설','영웅','빛','어둠','선','악']\n",
"#킹아더, 엑스칼리버, 더데빌\n",
"\n",
"drama = ['인생','재출발','성장','이야기','꿈','생애','세월','평생','탄생',\n",
" '평화','가족']\n",
"#헤드윅, 호프, 라이언킹\n",
"\n",
"history = ['조선','왕','양반','백성','역모','국가','전쟁','정권']\n",
"#스웨그에이지 외쳐 조선, 여명의 눈동자\n",
"\n",
"thriller = ['공포','스릴러','서스펜스','정체','광기','복수','사건','살해',\n",
" '처참','피','진실']\n",
"#레베카, 스위니토드, 쓰릴 미"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 계획한 방법을 간단한 모델을 통해 test"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"romance = ['사랑','열정','편지','감성','약혼','고백','결혼식','첫날밤',\n",
" '낭만','황홀','아름다운','로맨틱','감동적','외사랑','따뜻','순수']\n",
"#그리스, 리틀잭, 로미오와 줄리엣, 시라노\n",
"\n",
"fantasy = ['마법사','예언','운명','전설','영웅','빛','어둠','선','악']\n",
"#킹아더, 엑스칼리버, 더데빌\n",
"\n",
"drama = ['인생','재출발','성장','이야기','꿈','생애','세월','평생','탄생',\n",
" '평화','가족']\n",
"#헤드윅, 호프, 라이언킹\n",
"\n",
"history = ['조선','왕','양반','백성','역모','국가','전쟁','정권']\n",
"#스웨그에이지 외쳐 조선, 여명의 눈동자\n",
"\n",
"thriller = ['공포','스릴러','서스펜스','정체','광기','복수','사건','살해',\n",
" '처참','피','진실']\n",
"#레베카, 스위니토드, 쓰릴 미"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"각 장르에 해당하는 단어들을 그 장르에 속하도록 학습시키고싶다.\n",
"\n",
"(1) 각 단어를 포함하는 문장들을 이용해서 학습..?\n",
"(2) "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['브로드웨이 역사상 가장 매혹적인 입맞춤', '2020년 오디컴퍼니가 선사하는 또 하나의 대작', '한 여인을 사랑하기 위해 영원의 삶을 선택한 ‘드라큘라’와', '그를 사랑할 수밖에 없는 운명의 여인 ‘미나’ 죽음을 초월한 세기의 러브스토리를', '입체적인 무대 예술과 웅장하고 아름다운 음악으로 표현하며 깊은 인상을 남긴 뮤지컬 <드라큘라>', '2020년 2월, 뮤지컬 <드라큘라>의 새로운 역사가 시작된다.', '', '품격 있는 작품의 완성도를 높일 초호화 캐스트', '수백 년 동안 한 여인에 대한 사랑을 간직한 신비로운 매력의 ‘드라큘라’ 역에는', '압도적인 실력으로 막강한 티켓파워를 자랑하는 김준수와 가창력과 섬세함으로 여심을 사로잡는 전동석,', '드라큘라가 사랑한 아름답고 총명한 여인 ‘미나’ 역으로는 깊이 있는 연기력으로 감동을 주는 조정은,', '청아한 목소리와 진정성을 가진 임혜영, 안정된 보컬로 자리매김한 린지(임민지)가 출연한다.', '', '스페셜 캐스트 류정한', '오랜 시간 뮤지컬계를 이끌어 온 최정상 배우이자', '독보적인 존재감으로 뮤지컬 <드라큘라> 초연의 흥행을 이끌었던 류정한이', '신춘수 프로듀서의 지속적인 러브콜로 스페셜 리미티드 공연으로 돌아온다.', '', '눈을 뗄 수 없는 환상적인 무대 예술', '‘프랭크 와일드혼’의 아름답고 매력적인 넘버', '19세기 유럽의 고딕풍 디자인과 트란실바니아 성을 감싸는 몽환적인 푸른 안개', '4중 회전 턴테이블과 플라잉(Flying) 기술이 어우러진 입체적인 연출은 무대 예술의 정점을 보여준다.', '', '여기에 천재 작곡가 ‘프랭크 와일드혼’의 서정적이고 애절한 넘버는', '음악이 그 자체로 스토리와 캐릭터가 되어 더욱 감동을 더한다.', '특히 뮤지컬 <드라큘라>의 대표 넘버 ‘Loving You Keeps Me Alive’는', '‘드라큘라’와 ‘미나’의 애절한 마음을 표현한 아름다운 듀엣곡으로 손꼽힌다.', '', '슬픔과 아름다움이 공존하는', '매혹적이고 신비로운 캐릭터', '거부할 수 없는 유혹, 숨 막히는 매력과 신비로움의 존재 ‘드라큘라’', '애틋하고 슬픈 운명적인 사랑을 지닌 아름다운 여인 ‘미나’', '드라큘라에 의해 사랑하는 여자를 잃고 복수를 꿈꾸는 뱀파이어 헌터 ‘반 헬싱’', '미나를 끝까지 포기하지 않고 사랑하는 그녀의 약혼자 ‘조나단’', '미나의 절친한 친구로 재기 발랄한 여인 ‘루시’']\n"
]
}
],
"source": [
"plot = open('/Users/yangyoonji/Documents/dataCapstone/data/source_code/test_plot/드라큘라.txt','r')\n",
"lines = plot.readlines()\n",
"lines = list(map(lambda s: s.strip(), lines))\n",
"print(lines)\n",
"plot.close()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
"from nltk.tokenize import word_tokenize\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['브로드웨이', '역사상', '가장', '매혹적인', '입맞춤', '2020년', '오디컴퍼니가', '선사하는', '또', '하나의', '대작', '한', '여인을', '사랑하기', '위해', '영원의', '삶을', '선택한', '‘드라큘라’와', '그를', '사랑할', '수밖에', '없는', '운명의', '여인', '‘미나’', '죽음을', '초월한', '세기의', '러브스토리를', '입체적인', '무대', '예술과', '웅장하고', '아름다운', '음악으로', '표현하며', '깊은', '인상을', '남긴', '뮤지컬', '<드라큘라>', '2020년', '2월,', '뮤지컬', '<드라큘라>의', '새로운', '역사가', '시작된다.', '', '품격', '있는', '작품의', '완성도를', '높일', '초호화', '캐스트', '수백', '년', '동안', '한', '여인에', '대한', '사랑을', '간직한', '신비로운', '매력의', '‘드라큘라’', '역에는', '압도적인', '실력으로', '막강한', '티켓파워를', '자랑하는', '김준수와', '가창력과', '섬세함으로', '여심을', '사로잡는', '전동석,', '드라큘라가', '사랑한', '아름답고', '총명한', '여인', '‘미나’', '역으로는', '깊이', '있는', '연기력으로', '감동을', '주는', '조정은,', '청아한', '목소리와', '진정성을', '가진', '임혜영,', '안정된', '보컬로', '자리매김한', '린지(임민지)가', '출연한다.', '', '스페셜', '캐스트', '류정한', '오랜', '시간', '뮤지컬계를', '이끌어', '온', '최정상', '배우이자', '독보적인', '존재감으로', '뮤지컬', '<드라큘라>', '초연의', '흥행을', '이끌었던', '류정한이', '신춘수', '프로듀서의', '지속적인', '러브콜로', '스페셜', '리미티드', '공연으로', '돌아온다.', '', '눈을', '뗄', '수', '없는', '환상적인', '무대', '예술', '‘프랭크', '와일드혼’의', '아름답고', '매력적인', '넘버', '19세기', '유럽의', '고딕풍', '디자인과', '트란실바니아', '성을', '감싸는', '몽환적인', '푸른', '안개', '4중', '회전', '턴테이블과', '플라잉(Flying)', '기술이', '어우러진', '입체적인', '연출은', '무대', '예술의', '정점을', '보여준다.', '', '여기에', '천재', '작곡가', '‘프랭크', '와일드혼’의', '서정적이고', '애절한', '넘버는', '음악이', '그', '자체로', '스토리와', '캐릭터가', '되어', '더욱', '감동을', '더한다.', '특히', '뮤지컬', '<드라큘라>의', '대표', '넘버', '‘Loving', 'You', 'Keeps', 'Me', 'Alive’는', '‘드라큘라’와', '‘미나’의', '애절한', '마음을', '표현한', '아름다운', '듀엣곡으로', '손꼽힌다.', '', '슬픔과', '아름다움이', '공존하는', '매혹적이고', '신비로운', '캐릭터', '거부할', '수', '없는', '유혹,', '숨', '막히는', '매력과', '신비로움의', '존재', '‘드라큘라’', '애틋하고', '슬픈', '운명적인', '사랑을', '지닌', '아름다운', '여인', '‘미나’', '드라큘라에', '의해', '사랑하는', '여자를', '잃고', '복수를', '꿈꾸는', '뱀파이어', '헌터', '‘반', '헬싱’', '미나를', '끝까지', '포기하지', '않고', '사랑하는', '그녀의', '약혼자', '‘조나단’', '미나의', '절친한', '친구로', '재기', '발랄한', '여인', '‘루시’']\n"
]
}
],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"romance = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/romancePlot.csv')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>index</th>\n",
" <th>plot</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>The film follows the adventures of a group of ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>The film tells the story of two girls, Agnes a...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2</td>\n",
" <td>The first part of the film begins with a narr...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>The film opens at a school where a boy is pick...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4</td>\n",
" <td>The story may not be linear and exhibits sever...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" index plot\n",
"0 0 The film follows the adventures of a group of ...\n",
"1 1 The film tells the story of two girls, Agnes a...\n",
"2 2 The first part of the film begins with a narr...\n",
"3 3 The film opens at a school where a boy is pick...\n",
"4 4 The story may not be linear and exhibits sever..."
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"romance.head(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#thriller, history, social"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"romance = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/romancePlot.csv')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>index</th>\n",
" <th>plot</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>0</td>\n",
" <td>The film follows the adventures of a group of ...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>1</td>\n",
" <td>The film tells the story of two girls, Agnes a...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2</td>\n",
" <td>The first part of the film begins with a narr...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>3</td>\n",
" <td>The film opens at a school where a boy is pick...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>4</td>\n",
" <td>The story may not be linear and exhibits sever...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" index plot\n",
"0 0 The film follows the adventures of a group of ...\n",
"1 1 The film tells the story of two girls, Agnes a...\n",
"2 2 The first part of the film begins with a narr...\n",
"3 3 The film opens at a school where a boy is pick...\n",
"4 4 The story may not be linear and exhibits sever..."
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"romance.head(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#thriller, history, social"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tqdm import tqdm\n",
"stop_words = set(stopwords.words('english'))\n",
"\n",
"vocab = {} \n",
"sentences = []\n",
"\n",
"def processing(arr,all_word_to_index):\n",
" global all_word_to_index\n",
" for i in tqdm(arr):\n",
" sentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
"\n",
" for word in RMsentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in stop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in vocab_r:\n",
" vocab[word] = 0 \n",
" vocab[word] += 1\n",
" sentences.append(result) \n",
"\n",
" encoded = []\n",
" for s in sentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" encoded.append(temp)\n",
" return encoded\n",
"\n",
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
This diff could not be displayed because it is too large.
This file is too large to display.
#!/usr/bin/env python
# coding: utf-8
# In[1]:
import pandas as pd
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
import re
thriller_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/thrillerPlot.csv')
drama_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/dramaPlot.csv')
fantasy_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/fantasyPlot.csv')
history_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/historyPlot.csv')
social_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/socialPlot.csv')
romance_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/romancePlot.csv')
# /Users/김서영/Desktop/datacap/data/moviedata/moviePlot/romancePlot.csv
print(len(romance_plot)) #5699 ==> train 2500 test 2500
print(len(thriller_plot)) #9823 ==> train 2500 test 2500
print(len(drama_plot))
print(len(fantasy_plot))
print(len(history_plot))
print(len(social_plot))
train_data_size = 1463
test_data_size = 1463
#전처리(1) 전부 소문자로 변환
#romance_plot.줄거리 = romance_plot.줄거리.str.lower()
#thriller_plot.줄거리 = thriller_plot.줄거리.str.lower()
#전처리(1-1) 데이터 csv 파일로 옮기기
#romance_plot 2899개 train_data로 to_csv || 2800개 test_data로 to_csv
#thriller_plot 2899개 train_data로 to_csv || 2800개 test_data로 to_csv
# In[2]:
RM = [[] for _ in range(5699)]
for i in range(5699):
RM[i].append(''.join(thriller_plot.줄거리[i]))
TH = [[] for _ in range(9823)]
for i in range(9823):
TH[i].append(''.join(thriller_plot.줄거리[i]))
FN = [[] for _ in range(2727)]
for i in range(2727):
FN[i].append(''.join(fantasy_plot.줄거리[i]))
HS = [[] for _ in range(1498)]
for i in range(1498):
HS[i].append(''.join(history_plot.줄거리[i]))
SC = [[] for _ in range(1464)]
for i in range(1464):
SC[i].append(''.join(social_plot.줄거리[i]))
DR = [[] for _ in range(14019)]
for i in range(14019):
DR[i].append(''.join(drama_plot.줄거리[i]))
allplot = RM+TH+FN+HS+SC+DR #모든 드라마 줄거리
# In[4]:
print(len(allplot))
# ## 모든 장르 줄거리
# In[5]:
# 토큰화+전처리(3) 전체 불용어 처리
# 전체 플롯
from tqdm import tqdm
all_vocab = {}
all_sentences = []
stop_words = set(stopwords.words('english'))
for i in tqdm(allplot):
all_sentences = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.
result = []
for word in all_sentences:
word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.
if word not in stop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.
if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.
result.append(word)
if word not in all_vocab:
all_vocab[word] = 0
all_vocab[word] += 1
all_sentences.append(result)
# In[6]:
all_vocab_sorted = sorted(all_vocab.items(), key = lambda x:x[1], reverse = True)
#전처리(4) 인덱스 부여
all_word_to_index = {}
i=0
for (word, frequency) in all_vocab_sorted :
if frequency > 1 : # 정제(Cleaning) 챕터에서 언급했듯이 빈도수가 적은 단어는 제외한다.
i=i+1
all_word_to_index[word] = i
#print(all_word_to_index)
vocab_size = 15000 #상위 15000개 단어만 사용
words_frequency = [w for w,c in all_word_to_index.items() if c >= vocab_size + 1] # 인덱스가 200 초과인 단어 제거
for w in words_frequency:
del all_word_to_index[w] # 해당 단어에 대한 인덱스 정보를 삭제
all_word_to_index['OOV'] = len(all_word_to_index) + 1
# ## 로맨스
# In[7]:
# 토큰화+전처리(3) 불용어 처리
# 로맨스 플롯
vocab_r = {}
RMsentences = []
RMstop_words = set(stopwords.words('english'))
for i in tqdm(RM):
RMsentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.
result = []
for word in RMsentence:
word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.
if word not in RMstop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.
if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.
result.append(word)
if word not in vocab_r:
vocab_r[word] = 0
vocab_r[word] += 1
RMsentences.append(result)
R_encoded = []
for s in RMsentences:
temp = []
for w in s:
try:
temp.append(all_word_to_index[w])
except KeyError:
temp.append(all_word_to_index['OOV'])
R_encoded.append(temp)
# ## 스릴러
# In[8]:
# 토큰화+전처리(3) 불용어 처리
# 스릴러 플롯
vocab_th = {}
THsentences = []
THstop_words = set(stopwords.words('english'))
for i in tqdm(TH):
THsentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.
result = []
for word in THsentence:
word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.
if word not in THstop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.
if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.
result.append(word)
if word not in vocab_th:
vocab_th[word] = 0
vocab_th[word] += 1
THsentences.append(result)
TH_encoded = []
for s in THsentences:
temp = []
for w in s:
try:
temp.append(all_word_to_index[w])
except KeyError:
temp.append(all_word_to_index['OOV'])
TH_encoded.append(temp)
# In[ ]:
#전처리 방법에는 NLTK의 FreqDist, 케라스(Keras) 토크나이저도 사용 가능.
# 로맨스 플롯, 스릴러 따로 토큰화 해서 x train에 넣을지... 고민중
#
# 이번주 : 전처리 완료,
# 이번 달 목표 : 뮤지컬 장르 분류 << 다양한 모델 사용해보기.
#
# 6월에 교차검증 및 장르 시각화 설계까지.
#
# 다음주 : 2진분류(LSTM) 완료, RNN 분류기 만들어보기
# ## 학습데이터
# In[ ]:
# 영화 줄거리는 X_train에, 장르 정보는 y_train에 저장된다.
# 테스트용 줄거리 X_test에, 테스트용 줄거리의 장르 정보는 y_test에 저장된다.
#맞춰서 저장하기. (진행중)
#X_train = train_sc_df.dropna().drop(‘trade_price_idx_value’, axis=1)
# In[9]:
X_train = []
Y_train = [] #0 : romance, 1 : thriller
for i in range(train_data_size):
X_train.append(R_encoded[i])
Y_train.append(0)
X_train.append(TH_encoded[i])
Y_train.append(1)
# In[10]:
#print(X_train[2])
#print(Y_train[2])
# In[11]:
import matplotlib.pyplot as plt
len_result = [len(s) for s in X_train]
print("줄거리 최대 길이 : ",max(len_result))
print("줄거리 평균 길이 : ",sum(len_result)/len(len_result))
plt.subplot(1,2,1)
plt.boxplot(len_result)
plt.subplot(1,2,2)
plt.hist(len_result, bins=50)
plt.show()
# ## 테스트 데이터
#
#
# In[12]:
X_test = []
Y_test = [] #0 : romance, 1 : thriller
for i in range(test_data_size):
X_test.append(R_encoded[train_data_size+i])
Y_test.append(0)
X_test.append(TH_encoded[train_data_size+i])
Y_test.append(1)
# In[13]:
import matplotlib.pyplot as plt
len_result = [len(s) for s in X_test]
print("줄거리 최대 길이 : ",max(len_result))
print("줄거리 평균 길이 : ",sum(len_result)/len(len_result))
plt.subplot(1,2,1)
plt.boxplot(len_result)
plt.subplot(1,2,2)
plt.hist(len_result, bins=50)
plt.show()
# ## LSTM 분류
#
# In[14]:
from tensorflow.keras.preprocessing.sequence import pad_sequences
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, LSTM, Embedding
from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
max_len = 100
X_train = pad_sequences(X_train, maxlen=max_len)
X_test = pad_sequences(X_train, maxlen=max_len)
# In[ ]:
model = Sequential()
model.add(Embedding(5000, 120))
model.add(LSTM(120))
model.add(Dense(1, activation='sigmoid'))
es = EarlyStopping(monitor='val_loss', mode='min', verbose=1, patience=4)
mc = ModelCheckpoint('best_model.h5', monitor='val_acc', mode='max', verbose=1, save_best_only=True)
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['acc'])
model.fit(X_train, Y_train, validation_data=(X_test, Y_test), epochs=10, batch_size=64, callbacks=[es, mc])
# In[ ]:
# In[ ]:
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from tqdm import tqdm\n",
"stop_words = set(stopwords.words('english'))\n",
"\n",
"vocab = {} \n",
"sentences = []\n",
"\n",
"def processing(arr,all_word_to_index):\n",
" global all_word_to_index\n",
" for i in tqdm(arr):\n",
" sentence = word_tokenize(str(i)) # 단어 토큰화를 수행합니다.\n",
" result = []\n",
"\n",
" for word in RMsentence: \n",
" word = word.lower() # 모든 단어를 소문자화하여 단어의 개수를 줄입니다.\n",
" if word not in stop_words: # 단어 토큰화 된 결과에 대해서 불용어를 제거합니다.\n",
" if len(word) > 2: # 단어 길이가 2이하인 경우에 대하여 추가로 단어를 제거합니다.\n",
" result.append(word)\n",
" if word not in vocab_r:\n",
" vocab[word] = 0 \n",
" vocab[word] += 1\n",
" sentences.append(result) \n",
"\n",
" encoded = []\n",
" for s in sentences:\n",
" temp = []\n",
" for w in s:\n",
" try:\n",
" temp.append(all_word_to_index[w])\n",
" except KeyError:\n",
" temp.append(all_word_to_index['OOV'])\n",
" encoded.append(temp)\n",
" return encoded\n",
"\n",
" "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
import pandas as pd
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
import re
romance_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/romancePlot.csv')
thriller_plot = pd.read_csv('/Users/yangyoonji/Documents/2020-1/2020-dataCapstone/data/moviedata/moviePlot/thrillerPlot.csv')
print(len(romance_plot)) #5699 ==> train 2500 test 2500
print(len(thriller_plot)) #9823 ==> train 2500 test 2500
#전처리(1) 전부 소문자로 변환
romance_plot.줄거리 = romance_plot.줄거리.str.lower()
thriller_plot.줄거리 = thriller_plot.줄거리.str.lower()
#전처리(1-1) 데이터 csv 파일로 옮기기
#romance_plot 2899개 train_data로 to_csv || 2800개 test_data로 to_csv
#thriller_plot 2800개 train_data로 to_csv || 2899개 test_data로 to_csv
#전처리(2) 토큰화, 불용어 처리
stop_words = set(stopwords.words('english'))
word_tokens = word_tokenize(romance_plot.줄거리)#오류
result = []
for w in word_tokens:
if w not in stop_words:
result.append(w)
print(word_tokens)
print(result)
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
import nltk
nltk.download(stopwords)
#nltk
X_train, X_test,
y_train, y_test
x = 줄거리
y = 결과(로맨스, 스릴러 )
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
No preview for this file type
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# <4월 20일 ~ 4월 24일>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"(1) 플레이DB 웹크롤링 -> 에러처리, csv파일로 옮기기 남음\n",
"\n",
"(2) **tf-idf**로 키워드 추출 고려 <br/>\n",
" -> 줄거리가 짧아서 단어 빈도수가 커야 6정도 ==> 따라서 장르별 대표작들 줄거리를 모아서 해보기로 계획\n",
"\n",
"(3) **word2vec**로 문맥이 비슷한 단어 파악하려했지만<br/>\n",
" ->학습 시간이 오래걸리는 문제 <br/>\n",
" ->단어 관계 파악 후에 어떻게 처리할지 고민,,<br/>\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# <다음주 계획>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"-장르별 키워드 생각(크롤링x, 생각대로) <br/>\n",
"ex) 로맨스 = ['사랑','연인','애틋',........]<br/>\n",
"-가볍게 테스트<br/>\n",
"\n",
"\n",
"### 테스트 결과가 잘 나온다면,, 장르별 키워드 추출 모델 만들기\n",
"#### (잘 나오지 못하면,, 새로운 방법 고려)\n",
"---\n",
"\n",
"(1-1) **불용어 대표 사전 제작**<br/>\n",
"\n",
"- 뮤지컬정보관련된거 ('뮤지컬','제작사','콘텐츠', 뮤지컬이름, '창작','티켓', '매진'....)<br/>\n",
"- 고유 명사<br/>\n",
"- 시간관련 명사, 부사 모든것, (시작 ,나이, '최초','전날' '작년', OOOO년 OO월 OO일, '당시')<br/>\n",
"- 장소는 애매,, ('감옥'이런 장소는 유의미,,)(그런데 지명은 무의미)<br/>\n",
"- 감정이 아닌 단어 예를 들면 ('표현', '세상',...) <br/>\n",
"- 흔한 불용어('우리' ,,)<br/>\n",
"- 한국어가 아닌 단어(한자, 영어)<br/>\n",
"\n",
"(1-2) **장르 대표작 30편씩 고르기**<br/>\n",
"=> 장르별 대표작 30편씩은 줄거리 + 그 이외 기사, 대본 가능한대로 긁어와..<br/>\n",
"\n",
"*키워드 추출은 불용어 사전을 통해 불필요한 단어를 제외하고, 나머지 단어들의 사용된 빈도를 기준으로함.<br/>\n",
"*이때 키워드를 사전 api와 비교해서 나오지 않는것은 이름으로 간주하고 제거.<br/>\n",
"\n",
"(1-3) 장르 대표작들을 통해 **‘장르별 대표 키워드 사전 만들기’** => 이때 키워드가 포함된 문장도 추출<br/>\n",
"(왜냐하면 word2vec을 사용하려면 문장 필요)<br/>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 1. 불용어 처리\n",
"## 2. 어근 추출\n",
"## 3. 인코딩\n",
"## 4. 패딩 \n",
"\n",
"## 5. "
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
This diff is collapsed. Click to expand it.
No preview for this file type
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# <4월 20일 ~ 4월 24일>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"(1) 플레이DB 웹크롤링 -> 에러처리, csv파일로 옮기기 남음\n",
"\n",
"(2) **tf-idf**로 키워드 추출 고려 <br/>\n",
" -> 줄거리가 짧아서 단어 빈도수가 커야 6정도 ==> 따라서 장르별 대표작들 줄거리를 모아서 해보기로 계획\n",
"\n",
"(3) **word2vec**로 문맥이 비슷한 단어 파악하려했지만<br/>\n",
" ->학습 시간이 오래걸리는 문제 <br/>\n",
" ->단어 관계 파악 후에 어떻게 처리할지 고민,,<br/>\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# <다음주 계획>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"-장르별 키워드 생각(크롤링x, 생각대로) <br/>\n",
"ex) 로맨스 = ['사랑','연인','애틋',........]<br/>\n",
"-가볍게 테스트<br/>\n",
"\n",
"\n",
"### 테스트 결과가 잘 나온다면,, 장르별 키워드 추출 모델 만들기\n",
"#### (잘 나오지 못하면,, 새로운 방법 고려)\n",
"---\n",
"\n",
"(1-1) **불용어 대표 사전 제작**<br/>\n",
"\n",
"- 뮤지컬정보관련된거 ('뮤지컬','제작사','콘텐츠', 뮤지컬이름, '창작','티켓', '매진'....)<br/>\n",
"- 고유 명사<br/>\n",
"- 시간관련 명사, 부사 모든것, (시작 ,나이, '최초','전날' '작년', OOOO년 OO월 OO일, '당시')<br/>\n",
"- 장소는 애매,, ('감옥'이런 장소는 유의미,,)(그런데 지명은 무의미)<br/>\n",
"- 감정이 아닌 단어 예를 들면 ('표현', '세상',...) <br/>\n",
"- 흔한 불용어('우리' ,,)<br/>\n",
"- 한국어가 아닌 단어(한자, 영어)<br/>\n",
"\n",
"(1-2) **장르 대표작 30편씩 고르기**<br/>\n",
"=> 장르별 대표작 30편씩은 줄거리 + 그 이외 기사, 대본 가능한대로 긁어와..<br/>\n",
"\n",
"*키워드 추출은 불용어 사전을 통해 불필요한 단어를 제외하고, 나머지 단어들의 사용된 빈도를 기준으로함.<br/>\n",
"*이때 키워드를 사전 api와 비교해서 나오지 않는것은 이름으로 간주하고 제거.<br/>\n",
"\n",
"(1-3) 장르 대표작들을 통해 **‘장르별 대표 키워드 사전 만들기’** => 이때 키워드가 포함된 문장도 추출<br/>\n",
"(왜냐하면 word2vec을 사용하려면 문장 필요)<br/>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 다음주 목표 : 영화(영어) 데이터 전처리 완료\n",
"\n",
"## 1. 불용어 처리\n",
"## 2. 어근 추출\n",
"## 3. 인코딩\n",
"## 4. 패딩 \n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
No preview for this file type
<4월 20일 ~ 4월 24일>
(1) 플레이 DB 웹크롤링 -> 에러처리, csv파일로 옮기기 남음
(2) tf-idf로 키워드 추출 고려
-> 줄거리가 짧아서 단어 빈도수가 커야 6정도 ==> 따라서 장르별 대표작들 줄거리를 모아서 해보기로 계획
(3) word2vec로 문맥이 비슷한 단어 파악하려했지만
->학습 시간이 오래걸리는 문제
->단어 관계 파악 후에 어떻게 처리할지 고민,,
--------------------------------------------------------------------------
<다음주 계획>
-장르별 키워드 생각(크롤링x, 생각대로)
ex) 로맨스 = ['사랑','연인','애틋',........]
-가볍게 테스트
(1-1). 불용어 대표 사전 제작
- 뮤지컬정보관련된거 ('뮤지컬','제작사','콘텐츠', 뮤지컬이름, '창작','티켓', '매진'....)
- 고유 명사
- 시간관련 명사, 부사 모든것, (시작 ,나이, '최초','전날' '작년', OOOO년 OO월 OO일, '당시')
- 장소는 애매,, ('감옥'이런 장소는 유의미,,)(그런데 지명은 무의미)
- 감정이 아닌 단어 예를 들면 ('표현', '세상',
- 흔한 불용어('우리' ,,)
- 한국어가 아닌 단어(한자, 영어)
(1-2). 2000편 중에 장르 대표작 30편씩 고르기
=> 장르별 대표작 30편씩은 줄거리 + 그 이외 기사, 대본 가능한대로 긁어와..
*키워드 추출은 불용어 사전을 통해 불필요한 단어를 제외하고, 나머지 단어들의 사용된 빈도를 기준으로함.
*이때 키워드를 사전 api와 비교해서 나오지 않는것은 이름으로 간주하고 제거.
(1-3). 장르 대표작들을 통해 ‘장르별 대표 키워드 사전 만들기’ => 이때 키워드가 포함된 문장도 추출
(왜냐하면 word2vec을 사용하려면 문장 필요)
---------------------------------------------------------------------------
(2). 2000편 각각의 키워드(5개)와 키워드 찾고 -> 키워드 담고있는 문장 추출
*키워드 개수는 성능을 확인하면서 조절
(3). word2vec 을 활용해서 ‘장르별 대표 키워드 문장’과 과정(2)에서 추출한 문장 비교하면서
문장의미 유사도 비교..????해서 장르 분류
ex) 과정(2)에서 로맨스 대표작품 문장들 “따뜻한 사랑이 가득 담긴 작품” “~~사랑 이야기~~~~”
과정(3)에서 임의의 작품 대표문장. “아름답고 매력적인 사랑”
=> 그 결과 임의의 작품의 장르는 로맨스가 맞다고 판정
This diff is collapsed. Click to expand it.
No preview for this file type
This diff is collapsed. Click to expand it.