forked from dnaaun/openFraming
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathurl_test.py
121 lines (105 loc) · 3.5 KB
/
url_test.py
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import requests
import pandas as pd
import json
from numpy import fromfile
"""Classifier Part"""
# /api/classifiers post
"""
category_names = ['Politics', '2nd Amendment rights', 'Gun control',
'Public opinion', 'Mental health', 'School or public space safety',
'Society', 'Race', 'Economic consequences']
data = {
"name": "samesex classifier", "notify_at_email": "vibs97@bu.edu"
}
res = requests.post('http://www.openframing.org:5000/api/classifiers/', json=data)
print(res.text)
"""
# /api/classifiers/1 get
"""
res = requests.get('http://0.0.0.0:5000/api/classifiers/4')
print(res.text)
"""
# /api/classifiers/1/training/file post
"""
fil = open('testing_files/train_classifier.csv', 'r')
data = {"file": fil}
res = requests.post('http://0.0.0.0:5000/api/classifiers/1/training/file', files=data)
print(res.text)
"""
# /api/classifiers/1/test_sets post
"""
data = {
"test_set_name": "sample classifier_prediction_set1", "notify_at_email": "vibs97@bu.edu"
}
res = requests.post('http://0.0.0.0:5000/api/classifiers/4/test_sets/', json=data)
print(res.text)
"""
# /api/classifiers/1/set_status_to_be_completed post
"""
category_names = ['Economicconsequences', 'Gun2ndAmendmentrights', 'Guncontrolregulation', 'Mentalhealth', 'Politics', 'Publicopinion', 'Raceethnicity', 'Schoolorpublicspacesafety', 'Societyculture']
metrics = ['0.9261538461538462', '0.879877077719961', '0.8812814391247712', '0.8831354650027471']
data = {
"category_names": category_names, "metrics": metrics
}
res = requests.post('http://www.openframing.org:5000/api/classifiers/3/set_status_to_be_completed', json=data)
print(res.text)
"""
# /api/classifiers/1/test_sets get
"""
res = requests.get('http://0.0.0.0:5000/api/classifiers/7/test_sets')
print(res.text)
"""
# /api/classifiers/1/test_sets/1/file/ get
"""
fil = open('testing_files/test_classifier.csv', 'r')
data = {"file": fil}
res = requests.post('http://0.0.0.0:5000/api/classifiers/4/test_sets/3/file',files=data)
print(res.text)
"""
# /api/classifiers/1/test_sets/1/predictions get
"""
res = requests.get('http://0.0.0.0:5000/api/classifiers/7/test_sets/1/predictions')
"""
"""Topic Modelling Part"""
# /api/topic_models post
"""
data = {
"topic_model_name": "all things must pass", "num_topics": 10,
"notify_at_email": "vibs97@bu.edu", "language": "english",
"remove_stopwords": True, "remove_punctuation": True,
"do_stemming": True, "do_lemmatizing": True, "min_word_length": 2
}
res = requests.post('http://0.0.0.0:5000/api/topic_models/', json=data)
print(res.text)
"""
# api/topic_models/1 get
"""
res = requests.get('http://0.0.0.0:5000/api/topic_models/1')
print(res.text)
"""
# api/topic_models/1/training/file/
"""
fil = open('testing_files/step1.csv', 'r')
data = {"file": fil}
# print(pd.read_csv(fil))
res = requests.post('http://0.0.0.0:5000/api/topic_models/17/training/file', files=data)
print(res.text)
"""
# api/topic_models/1/topics/preview get
"""
res = requests.get('http://0.0.0.0:5000/api/topic_models/4/topics/preview')
print(res.text)
"""
# api/topic_models/1/topics/keywords get
# api/topic_models/1/topics_by_doc get
"""
# This is an excel file so won't be used here but in browser, you can download this.
res = requests.get('http://0.0.0.0:5000/api/topic_models/1/keywords?file_type=xlsx')
print(pd.read_excel(res.raw))
"""
# /topic_models/1/topics/names
"""
data = {"topic_names": ['my', 'name', 'is', 'vubh', '5', '6', '7', '8', '9', '10']}
res = requests.post('http://0.0.0.0:5000/api/topic_models/1/topics/names', json=data)
print(res.text)
"""