NLP
-
문제 05. n-gramNLP/NLP100 2021. 1. 4. 18:16
주어진 시퀀스(문자열이나 리스트 등)에서 n-gram을 만드는 함수를 작성하시오. 이 함수를 이용해 "I am an NLPer"라는 문장에서 단어 Bigram과 문자 Bigram을 구하시오. s = "I am an NLPer" def bigram(idx, n): return [idx[i:i+n] for i in range(len(idx)-n+1)] w = s.split(" ") print(bigram(w,2)) print(bigram(s,2)) [출력 결과] [['I', 'am'], ['am', 'an'], ['an', 'NLPer']] ['I ', ' a', 'am', 'm ', ' a', 'an', 'n ', ' N', 'NL', 'LP', 'Pe', 'er'] - 언어 모델 (language mod..
-
문제 04. 원소 기호NLP/NLP100 2021. 1. 4. 18:09
Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can 라는 문장을 단어 단위로 분할하고, 1,5,6,7,8,9,15,16,19 번째 단어는 앞글자, 그 밖의 단어는 앞에서 두 글자씩 추출하여 꺼낸 문자열에서 단어의 위치순으로 나열한 배열을 만드시오. def sol(i, word): if i in [1, 5, 6, 7, 8, 9, 15, 16, 19]: return (word[0], i) else: return (word[:2], i) text = 'Hi He Lied Because Boron Could Not Oxidize Fluorine. Ne..
-
문제 03. 원주율NLP/NLP100 2021. 1. 4. 18:08
"Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." 라는 문장을 단어로 분할하여 각 단어의(알파벳) 글자 수를 앞에서부터 나열한 배열을 만드시오. s = "Now I need a drink, alcoholic of course, after the heavy lectures involving quantum mechanics." s = s.split(' ') s1 = [len(w.rstrip(',.')) for w in s] print(s1) [출력 결과] [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9]
-
NLP100 문제 풀이NLP/NLP100 2021. 1. 4. 17:59
https://nlp100.github.io/ko/about.html 100문제로 두드려 보는 자연어처리에 대하여 NLP 100 Exercise is a workbook designed for learning skills for programming, data analysis, and research activities by taking practical and exciting assignments. nlp100.github.io 총 10개의 챕터로 구성된 자연어처리의 기본을 공부하기 좋은 사이트이다. 1. 준비운동 2. UNIX 명령어 3. 정규표현식 4. 형태소 분석 5. 구문 분석 6. 기계 학습 7. 단어 벡터 8. 신경망 9. RNN과 CNN 10. 기계 번역 원 사이트는 일본 사이트로, 현재 ..