본문 바로가기

Programming Language/Python

Fairseq 설치 에러 gcc 뭐시기 에러날 때 해결법 apt-get install gcc python3-dev libxml2-dev libxslt1-dev zlib1g-dev g++
Python 배열을 특정 사이즈로 자르기 max_batch_size = 20 total_features = [eval_features[i:i + max_batch_size] for i in range(0, len(eval_features), max_batch_size)] window_size = 3 total_keys = [keys[x:x+window_size] for x in range(len(keys) - window_size + 1 )]
colab에서 khaiii 형분석기 설치해서 사용하기 !git clone https://github.com/kakao/khaiii.git !pip install cmake !mkdir build !cd build && cmake /content/khaiii !cd /content/build/ && make all !cd /content/build/ && make resource !cd /content/build && make install !cd /content/build && make package_python !pip install /content/build/package_python from khaiii import KhaiiiApi api = KhaiiiApi() for word in api.analyze("안녕, 세상."): print(word)
Socket을 이용한 Python과 Processing 간의 통신 Processing client.pde import processing.net.*; Client myClient; void setup() { size(200, 200); myClient = new Client(this, "127.0.0.1", 3030); } void draw() { myClient.write("Hello"); // send whatever you need to send here String kk = myClient.readString(); println(kk); } Python server.py import socket HOST = '127.0.0.1' PORT = 3030 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind((H..
Python 특정 디렉토리 하위 항목 리스트 가져오고 파일 전체 옮기기 123456789101112import globimport osimport shutil results = [] for x in os.walk('.'): for y in glob.glob(os.path.join(x[0], '*.flac')): results.append(y) for result in results: shutil.move(result, 'all_files_flac')cs
[펌] 도란쓰-뽀마 (Attention is all you need) https://pozalabs.github.io/transformer/ Attention is all you need paper 뽀개기 Transformer paper review pozalabs.github.io
정규표현식 모음 import re 1. 이메일이 본문에 포함되어 있는지 검사 p = re.compile('.*[a-zA-Z0-9+-_.]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+.*') 2. HTML tag p = re.compile('.*\.*') p = re.compile('\') 3. Hash tag p = re.compile('\\#([0-9a-zA-Z가-힣]*)') 4. 개체명 추출 p = re.compile('\') 5. 특수문자 추출 result = re.sub('[^0-9a-zA-Zㄱ-힗]', '', myStr) 6. 괄호 내 문자 포함 \([^)]*(일보|기자|미디어)\) 7. 문서 분리 from pathlib import Path file_path = Path(file_path) raw_..
우분투 16.04 python설치 apt-get install software-properties-commonadd-apt-repository ppa:jonathonf/python-3.6apt-get updateapt-get install python3.6apt-get install python3-pip 매번 검색하기 짜잉나 죽겄네!