Skip to content

Instantly share code, notes, and snippets.

# Working example for my blog post at:
# https://danijar.github.io/structuring-your-tensorflow-models
import functools
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
def doublewrap(function):
"""
A decorator decorator, allowing to use the decorator to be used without
@ansvver
ansvver / 词性标记.md
Created January 17, 2018 07:33 — forked from luw2007/词性标记.md
词性标记: 包含 ICTPOS3.0词性标记集、ICTCLAS 汉语词性标注集、jieba 字典中出现的词性、simhash 中可以忽略的部分词性

词的分类

  • 实词:名词、动词、形容词、状态词、区别词、数词、量词、代词
  • 虚词:副词、介词、连词、助词、拟声词、叹词。

ICTPOS3.0词性标记集

n 名词

nr 人名

@ansvver
ansvver / pandas_code.py
Last active August 28, 2017 08:28
Pandas common usage.
# pandas输出格式
import pandas as pd
pd.set_option('display.height', 1000)
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)
pd.set_option('display.width', 1000)
pd.set_option('display.expand_frame_repr', False)
# 设置数据格式,避免比较大的数据以科学计数法显示
pd.set_option('display.float_format', lambda x: '%.3f' % x)
@ansvver
ansvver / dict2dot.py
Last active February 15, 2020 01:42
trans normal dict to MongoDB dot natation format dict
#!/usr/bin/env python
# coding: utf-8
def dict2dot(foo, bar):
for k, v in foo.items():
if not isinstance(v, dict):
bar[k] = v
continue
for kk, vv in v.items():
dict2dot({'{}.{}'.format(k, kk): vv}, bar)
import bisect
class NFA(object):
EPSILON = object()
ANY = object()
def __init__(self, start_state):
self.transitions = {}
self.final_states = set()
self._start_state = start_state
@ansvver
ansvver / useful_pandas_snippets.py
Created August 27, 2016 06:00 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@ansvver
ansvver / cheatsheet.py
Created August 27, 2016 06:00 — forked from fuyufjh/cheatsheet.py
My Python Cheatsheet
Python Cheatsheet
=================
################################ Input & Output ###############################
name = input('please enter your name: ')
print('hello,', name)
ageStr = input('please enter your age: ')
age = int(ageStr)
#!/usr/bin/python
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os
gmail_user = "your_email@gmail.com"