Gaetano Parente commited on
Commit
bc6ef8a
·
1 Parent(s): d8a4180

remove temp file

Browse files
data/temp2641556c-c998-47a1-b2c1-b5154c3176b6.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Isn't there one of the ten commandments that says something like "you shall not bear false witness?" And doesn't quoting someone in a way that completely inverts what they were trying to say constitute bearing false witness? Doesn't this cause you any internal conflict at all?
data/temp61f73890-73f4-4d0b-b11b-5b272c5bdadc.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Isn't there one of the ten commandments that says something like "you shall not bear false witness?" And doesn't quoting someone in a way that completely inverts what they were trying to say constitute bearing false witness? Doesn't this cause you any internal conflict at all?
data/temp6a367738-9681-42ef-b94a-af4b6d89121e.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Isn't there one of the ten commandments that says something like "you shall not bear false witness?" And doesn't quoting someone in a way that completely inverts what they were trying to say constitute bearing false witness? Doesn't this cause you any internal conflict at all?
data/tempa78dbc28-8ddc-4a85-b90d-56e684133149.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ che posto ragazzi! una cucina ricercata in piccolo cortile d'altri tempi. bellissimo, buonissimo, bravissimi. prenotare con largo anticipo.
data/tempa7e3e3a8-f2a2-4f25-bc9b-89e65e3b4c98.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Isn't there one of the ten commandments that says something like "you shall not bear false witness?" And doesn't quoting someone in a way that completely inverts what they were trying to say constitute bearing false witness? Doesn't this cause you any internal conflict at all?
data/tempc1c5bff7-30cd-4b53-9154-c9346cd2338c.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Isn't there one of the ten commandments that says something like "you shall not bear false witness?" And doesn't quoting someone in a way that completely inverts what they were trying to say constitute bearing false witness? Doesn't this cause you any internal conflict at all?
data/tempeab0fb33-01c3-4e02-9859-0720aeeae9dd.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ Isn't there one of the ten commandments that says something like "you shall not bear false witness?" And doesn't quoting someone in a way that completely inverts what they were trying to say constitute bearing false witness? Doesn't this cause you any internal conflict at all?
modules/__pycache__/multilabel_classification.cpython-311.pyc CHANGED
Binary files a/modules/__pycache__/multilabel_classification.cpython-311.pyc and b/modules/__pycache__/multilabel_classification.cpython-311.pyc differ
 
modules/multilabel_classification.py CHANGED
@@ -4,9 +4,6 @@ from keras_preprocessing.sequence import pad_sequences
4
  import modules.utilities.utils as utils
5
  import keras.models as models
6
  import numpy as np
7
- import pathlib
8
- import uuid
9
-
10
 
11
  BASE_PATH = './data/'
12
  MODEL = BASE_PATH + 'model/'
@@ -19,31 +16,23 @@ class_names = np.array(['alt.atheism', 'comp.graphics', 'comp.os.ms-windows.misc
19
  'soc.religion.christian', 'talk.politics.guns', 'talk.politics.mideast',
20
  'talk.politics.misc', 'talk.religion.misc'])
21
 
22
- def predict(model_path, tokenizer_path, sentence, filepath):
23
  model = models.load_model(model_path, compile=False)
24
  tokenizer = utils.load_tokenizer(tokenizer_path)
25
- file = open(filepath, 'w')
26
- file.write(sentence)
27
- file.close()
28
- test_files = [filepath]
29
  x_data = []
30
- for t_f in test_files:
31
- t_f_data = pathlib.Path(t_f).read_text()
32
- x_data.append(t_f_data)
33
  x_tokenized = tokenizer.texts_to_sequences(x_data)
34
  x_pad = pad_sequences(x_tokenized, maxlen=200)
35
  x_t = x_pad[0]
36
  prediction = model.predict(np.array([x_t]))
37
- predicted_label = class_names[np.argmax(prediction[0])]
38
- return prediction, predicted_label
39
 
40
  def multi_classification(text):
41
  model = MODEL + 'multi-classification.h5'
42
  tokenizer = TOKEN + 'multi-classification-tokenizer.json'
43
- myuuid = uuid.uuid4()
44
- filepath = BASE_PATH + 'temp' + str(myuuid) + '.txt'
45
  #try:
46
- labels, max_label = predict(model, tokenizer, text, filepath)
47
  response = {}
48
  for i, label in enumerate(labels[0]):
49
  response[class_names[i]] = "%.4f" % float(label)
 
4
  import modules.utilities.utils as utils
5
  import keras.models as models
6
  import numpy as np
 
 
 
7
 
8
  BASE_PATH = './data/'
9
  MODEL = BASE_PATH + 'model/'
 
16
  'soc.religion.christian', 'talk.politics.guns', 'talk.politics.mideast',
17
  'talk.politics.misc', 'talk.religion.misc'])
18
 
19
+ def predict(model_path, tokenizer_path, sentence):
20
  model = models.load_model(model_path, compile=False)
21
  tokenizer = utils.load_tokenizer(tokenizer_path)
 
 
 
 
22
  x_data = []
23
+ x_data.append(sentence)
 
 
24
  x_tokenized = tokenizer.texts_to_sequences(x_data)
25
  x_pad = pad_sequences(x_tokenized, maxlen=200)
26
  x_t = x_pad[0]
27
  prediction = model.predict(np.array([x_t]))
28
+ #predicted_label = class_names[np.argmax(prediction[0])]
29
+ return prediction#, predicted_label
30
 
31
  def multi_classification(text):
32
  model = MODEL + 'multi-classification.h5'
33
  tokenizer = TOKEN + 'multi-classification-tokenizer.json'
 
 
34
  #try:
35
+ labels = predict(model, tokenizer, text)
36
  response = {}
37
  for i, label in enumerate(labels[0]):
38
  response[class_names[i]] = "%.4f" % float(label)