Comments (1)
To use the api in python3, you can replace the vanilla pullword.py content with the following code:
import requests
post_url = "http://api.pullword.com/post.php"
class ServerError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
def split_word(words):
words = words.split()
words_list = []
for i in words:
if len(i) == 0:
continue
words_list.append(i.split(":"))
return words_list
def pullword(source="", threshold=0, debug=1):
payload = {"source":source, "param1":threshold, "param2":debug}
pw = requests.post(post_url, data=payload)
print(pw.url)
if pw.status_code != 200:
raise ServerError("server return %s"%pw.status_code)
words = pw.content.decode()
print(words)
return split_word(words)
Then you can do like the following demo:
from pullword.pullword import pullword
res = pullword(u'其实我天生奔放贪玩', debug=1, threshold=0.7)
print(res)
So everything is OK!
from pullword.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pullword.