Skip to content

Instantly share code, notes, and snippets.

View qZhang88's full-sized avatar

Qiao.Zhang qZhang88

View GitHub Profile
import string
import re
from nltk.corpus import stopwords
from nltk.tokenize import TweetTokenizer
cache_english_stopwords=stopwords.words('english')
def tweet_clean(tweet):
# 利用python的正则去解决
import re
def remove_url(txt):
regex =re.compile(r'https://[a-zA-Z0-9.?/&=:]*',re.S)
return regex.sub("",txt)
#!/usr/bin/env python
import sys
#from numpy import array, diag, zeros, ones_like, identity, amax, maximum, amin, minimum, loadtxt, kron, ones, reshape
import numpy as np
from numpy.random import rand
#from matplotlib.pyplot import *
from optparse import OptionParser
import re
import json
import math
import random
import fileinput
import collections
class LDASampler(object):
def __init__(self, docs=None, num_topics=None, alpha=0.1, beta=0.1, state=None):
if state:
@qZhang88
qZhang88 / rank_metrics.py
Last active April 12, 2018 09:14 — forked from bwhite/rank_metrics.py
Learning to Rank Metrics.
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@qZhang88
qZhang88 / letor_metrics.py
Last active November 23, 2016 05:25 — forked from mblondel/letor_metrics.py
Learning to Rank Metrics.
# (C) Mathieu Blondel, November 2013
# License: BSD 3 clause
import numpy as np
def ranking_precision_score(y_true, y_score, k=10):
"""Precision at rank k
Parameters