Chatbot
- Sentiment Analysis : 감정분석
- Tokenization : 토큰화
- Named Entity Recognition : 주제파악하기
- Normalization : 의도된 오타 파악하기
- Dependency Parsing : 문장 구성 성분의 분석
SIRI
- Feature Analysis : 음성데이터로부터 특징을 추출
- Language Model : 언어별로 갖고 있는 특성을 반영
- Deep Learning : 학습된 데이터로부터 음성 신호 처리
- HMM(Hidden Markov Model) : 앞으로 나올 단어 예측
- Similarity Analysis : 음성 신호가 어떤 기준에 맞는가?
Translator
- Encoding : 유사도 기반 자연어의 특징 추출
- Time Series Modeling : 문장을 시간에 따른 데이터로 처리
- Attention Mechanism : 번역에 필요한 부분에만 집중
- Self-Attention : 문장 사이의 상관관계를 분석
- Transformer : Attention 구조를 이용한 번역 원리
<언어의 전처리 과정>
- sentence - Tokenization - Cleaning,Stemming - Encoding - Sorting - Padding, Similarity
from nltk.tokenize import TreebankWordTokenizer
tokenizer = TreebankWordTokenizer()
text = "Model-based RL don't need a value function for the policy."
print(tokenizer.tokenize(text))
['Model-based', 'RL', 'do', "n't", 'need', 'a', 'value', 'function', 'for', 'the', 'policy', '.']
import nltk
nltk.download('stopwords') # stopwords 패키지에서 다운로드
from nltk.corpus import stopwords
print(stopwords.words('english')[:5])
# 불용어 목록에 있으면 지워준다.
['i', 'me', 'my', 'myself', 'we']
import nltk
nltk.download('stopwords')
nltk.download('punkt')
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
input_sentence = 'We should all study hard for the exam.'
stop_words = set(stopwords.words('english'))
word_tokens = word_tokenize(input_sentence)
result = []
for w in word_tokens:
if w not in stop_words:
result.append(w)
print(word_tokens)
print(result)
['We', 'should', 'all', 'study', 'hard', 'for', 'the', 'exam', '.']
['We', 'study', 'hard', 'exam', '.']
mylist = ['English', 'Math', 'Science']
for n, name in enumerate(mylist):
print("Course : {}, Number : {}".format(name,n))
Course : English, Number : 0
Course : Math, Number : 1
Course : Science, Number : 2
# 빈도수 순서로 정렬한 다음에 번호를 매겨준다.
vocab = [('apple',8), ('July',6), ('piano', 4), ('cup', 2), ('orange', 1)]
word2inx = {word[0] : index + 1 for index, word in enumerate(vocab)}
- One-hot Encoding
- 저장공간이 많이 든다. - 평소에는 정수형으로 나뒀다가 필요할때만 원핫 인코딩으로 바꿔준다.
- Word2vec Encoding
- 단어의 유사성을 인코딩에 반영
- 인코딩 벡터가 비슷하다 = 단어가 유사하다.
- TF-IDF
- Term Frequency - Inverse Document Frequency
- 단어들의 중요한 정도를 가중치로 매기는 방법
- d: 특정 문서 번호
- t: 특정 단어 번호
- : 특정 문서 d에서 특정 단어 t의 등장 횟수
- : 특정 단어 t가 등장한 문서의 수
- N: 총 문서의 수
< 규칙 >
동일 = 대각선 수
변경 = 대간선 수 + 1
삽입 = 상단수 + 1
삭제 = 좌측 수 + 1
이중 가장 낮은 수를 책정