Skip to content

Instantly share code, notes, and snippets.

View seozed's full-sized avatar
🌴
On vacation

zed seozed

🌴
On vacation
View GitHub Profile
@seozed
seozed / mongo.js
Last active May 21, 2020 10:32
mongo 统计字段的长度并汇总
db.getCollection("mastersportal_counrse").aggregate([
{
"$project": {
"overview": {
"$strLenCP": "$overview"
},
"about": {
"$strLenCP": "$about"
}
@seozed
seozed / ratelimit.py
Created June 8, 2020 08:06
[限制客户端请求速度的装饰器] #qps
from ratelimit import limits, sleep_and_retry
import requests
FIFTEEN_MINUTES = 900
@sleep_and_retry
@limits(calls=15, period=FIFTEEN_MINUTES)
# 900秒内最多请求15次。
def call_api(url):
@seozed
seozed / MongoDbConnection.py
Last active May 9, 2022 10:04
MongoDbConnection
from pymongo import MongoClient
class MongoDBConnection(object):
"""MongoDB Connection"""
def __init__(self, host='localhost', port=27017):
self.host = host
self.port = port
self.connection = None
def __enter__(self):
self.connection = MongoClient(self.host, self.port)
@seozed
seozed / 词型还原
Created October 12, 2022 08:11
lemmatize.py
import nltk
nltk.download('omw-1.4')
nltk.download('punkt')
from nltk.stem import PorterStemmer
from nltk.stem import LancasterStemmer
from nltk.stem import WordNetLemmatizer
wordnet_lemmatizer = WordNetLemmatizer()
import os