-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME
56 lines (37 loc) · 1.83 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
eContext API
------------
The eContext API provides easy, quick, and accurate taxonomic classification of
any text content.
Installation
^^^^^^^^^^^^
Install the eContext API library from source using the following command:
$ python setup.py install
An executable will be installed into your /usr/local/bin directory that may be
used directly from the command line:
$ echo "Serena Williams Just Grand-Slammed Her Beyonce '7/11' Remake" | econtext-api -u USERNAME -p PASSWORD -t text
$ curl -s http://www.popularmechanics.com/science/health/a14760/real-ebola-vaccine/ | econtext-api -u USERNAME -p PASSWORD -t html
$ echo "http://www.popularmechanics.com/science/health/a14760/real-ebola-vaccine/" | econtext-api -u USERNAME -p PASSWORD -t url
You can also specify an input file containing the text or HTML you intend to
classify.
Using the Library
^^^^^^^^^^^^^^^^^
At the basic level, for each batch of classifiations you would like to run, you
pass in a `requests.session` object containing authorization and content-type
headers to the classification object, specify the data, and then run the batch.
from econtextapi.client import Client
from econtextapi.classify import Social
posts = [
"A master class in customer service from Lego. Boy writes to Lego after losing a mini-figure. Here's their reply...",
"This makes me realize how little hope there is for the education system in America.",
"Perrie just finished decorating the tree I didn't really help :( ha sorry x "
]
client = Client(USERNAME, PASSWORD)
classify = Social(client)
classify.set_classify_data(posts)
results = classify.get_results()
classify = Social(client)
classify.set_classify_data(10000_posts)
for result in classify.get_results():
print(result)
# result should contain all data pertinent to _that_ result
result