Skip to content

Instantly share code, notes, and snippets.

View facert's full-sized avatar
🎯
Focusing

zhangcr facert

🎯
Focusing
View GitHub Profile
@facert
facert / cosine_similarity.py
Last active December 29, 2023 00:29
python 余弦相似度代码示例
# coding: utf-8
from math import sqrt
import jieba.analyse
def cut_word(content):
'''
(u'\u65b9\u5e84', 2.4582479479)
(u'\u82b3\u57ce\u56ed', 1.19547675029)
(u'\u53ef\u6708\u4ed8', 1.19547675029)
@facert
facert / knn.py
Created March 6, 2017 05:56
python k 近邻实现
# coding: utf-8
#########################################
# kNN: k Nearest Neighbors
# Input: newInput: vector to compare to existing dataset (1xN)
# dataSet: size m data set of known vectors (NxM)
# labels: data set labels (1xM vector)
# k: number of neighbors to use for comparison
# coding: utf-8
import BaseHTTPServer
class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_FUCK(s):
s.send_response(200)
s.send_header("Content-type", "text/html")
s.end_headers()
s.wfile.write("just a kidding\n")
1. Create new tiny url
```
curl -i -X POST -H "Content-Type:application/json" -d '{"url": "http://example.com"}' 'http://t.bdaily.club'
Response:
{
"msg": "ok",
"data": {
"tiny_url": "http://t.bdaily.club/ssddz",
{"_id":"douban_group","startUrl":["https://www.douban.com/group/qiong/discussion"],"selectors":[{"id":"page","type":"SelectorLink","parentSelectors":["_root","page"],"selector":".paginator > a","multiple":true,"delay":0},{"id":"post","type":"SelectorElement","parentSelectors":["_root","page"],"selector":"tr:nth-of-type(n+2)","multiple":true,"delay":0},{"id":"link","type":"SelectorLink","parentSelectors":["post"],"selector":".title a","multiple":false,"delay":0},{"id":"author","type":"SelectorText","parentSelectors":["post"],"selector":"[nowrap] a","multiple":false,"regex":"","delay":0},{"id":"updated","type":"SelectorText","parentSelectors":["post"],"selector":"td.time","multiple":false,"regex":"","delay":0}]}