Skip to content

Instantly share code, notes, and snippets.

😃
Excelsior

游刃 Elfsong

😃
Excelsior
Block or report user

Report or block Elfsong

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Elfsong
Elfsong / open_fd.py
Last active Jan 3, 2019
Open a file #File #Open
View open_fd.py
with open("FILE_NAME", MODE, encoding="utf-8") as file_fd:
for item in file_fd.readlines():
print(item)
@Elfsong
Elfsong / sc.py
Last active Jan 3, 2019
Scenario classifier #Keras #word2vec
View sc.py
import json
import os
import gensim
import numpy as np
from keras.layers import Dense, Activation, Dropout
from keras.models import Sequential
from keras.optimizers import RMSprop
from keras.utils import np_utils
@Elfsong
Elfsong / douban_pip.bash
Last active Jan 6, 2019
Pip downloading by douban source #pip #douban
View douban_pip.bash
sudo -H pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ipython
pip install -i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com ipython
@Elfsong
Elfsong / seperate_sentence.py
Last active Jan 7, 2019
seperate_sentence #python #NLP
View seperate_sentence.py
def cut_sent(para):
para = para.replace(u'\u3000', '')
para = re.sub('([。!?\?])([^”’])', r"\1\n\2", para) # 单字符断句符
para = re.sub('(\.{6})([^”’])', r"\1\n\2", para) # 英文省略号
para = re.sub('(\…{2})([^”’])', r"\1\n\2", para) # 中文省略号
para = re.sub('([。!?\?][”’])([^,。!?\?])', r'\1\n\2', para)
para = para.rstrip()
return [sentence for sentence in para.split("\n") if sentence]
@Elfsong
Elfsong / sentence_level_detector_CNN.py
Created Jan 7, 2019
Sentence Level scenario detector_CNN #CNN #NLP
View sentence_level_detector_CNN.py
import os
import numpy as np
import pandas as pd
from bert_serving.client import BertClient
from keras.layers import Conv1D
from keras.layers import Dense, Activation, Dropout, Flatten, AveragePooling1D
from keras.models import Sequential
from keras.optimizers import RMSprop
from keras.utils import np_utils
@Elfsong
Elfsong / fetch_ltp.py
Created Jan 9, 2019
LTP online demo fetch
View fetch_ltp.py
#############################
Wanxiang Che, Zhenghua Li, Ting Liu.
LTP: A Chinese Language Technology Platform.
In Proceedings of the Coling 2010:Demonstrations. 2010.08, pp13-16, Beijing, China.
#############################
import requests
def fetch(sentence):
@Elfsong
Elfsong / TFB.plaintext
Created Jan 18, 2019
Temporary File Bridge
View TFB.plaintext
“不许动,在动我们就开枪了!”一名尉官模样持枪大喝道。
“刷刷刷”周围的几十名士兵此刻也是拉动的手中的枪栓,打开了保险,枪头此刻也是瞄准着唐铭。
唐铭闯入了军区之中,军区中的警报四响,无数的士兵更是纷纷拿起的枪支准备迎敌。唐铭一路快速的轻功赶路正好在此处遇见了收到了警报的士兵。
“指挥部,我三连四排在***地点发现可疑人员,请求指示。。。。”尉官也是急忙的对着胸口前的对讲上报情况。
唐铭没有理会士兵的警告,更是不急不缓的继续的向前走去。
“啪”枪响了,一发子弹从枪**击而出,打在了唐铭脚前的地面上,露出了一个冒着白烟的深洞。
“不许动,再敢动一步,信不信我一枪杀了你。”尉官手中的枪口更是向上抬了一台,警告道。
唐铭停了一步,随即又仿佛没看到一般,再次的向前走去。
“啪”又是一枪响起,这一枪直奔唐铭的膝盖而去,军队的规矩是第一次鸣枪警告,警告无效第二次便是直接开枪击毙,但这尉官见唐铭手中并无武器和其他威胁,便是心软了一下,想要打中他的腿,制止他的行动。
“啪”的一声,子弹打空的,打在的地面之上,而唐铭此时却消失在了原地。
@Elfsong
Elfsong / mnist_gan.py
Last active Jan 25, 2019
MNIST_GAN #GAN #python
View mnist_gan.py
import os # Get system method
import shutil # Recursive traversing file path
import tensorflow as tf # Neural Network2
import numpy as np # Matrix Computing
from skimage.io import imsave # Image operation
from tensorflow.examples.tutorials.mnist import input_data
data = input_data.read_data_sets('MNIST_data/')
@Elfsong
Elfsong / excel_writer.py
Last active Jan 26, 2019
Excel writer #spreadsheet #python
View excel_writer.py
import xlwt
import random
import demo_night
ROOT_PATH = r"C:\Users\t-midu\PycharmProjects\Scenario_detecter"
RESOURCE_PATH = os.path.join(ROOT_PATH, "resource")
file_path = os.path.join(RESOURCE_PATH, "stories.json.txt")
# Crating a new sheet
@Elfsong
Elfsong / excel_reader
Created Jan 26, 2019
Excel Reader #spreadsheet #python
View excel_reader
import os
import xlrd
ROOT_PATH = r"C:\Users\t-midu\PycharmProjects\Scenario"
RESOURCE_PATH = os.path.join(ROOT_PATH, "resource")
file_path = os.path.join(RESOURCE_PATH, "sentence_class.xls")
data = xlrd.open_workbook(file_path)
You can’t perform that action at this time.