cetinca commited on
Commit
db3317c
1 Parent(s): 9aec672

Test file for text2int

Browse files
.gitignore CHANGED
@@ -103,3 +103,4 @@ docs/**/*.html
103
  /data/call_history_text2int_1_bash.csv
104
  /data/processed_call_history_sentiment_1_bash.csv
105
  /data/processed_call_history_text2int_1_bash.csv
 
 
103
  /data/call_history_text2int_1_bash.csv
104
  /data/processed_call_history_sentiment_1_bash.csv
105
  /data/processed_call_history_text2int_1_bash.csv
106
+ /data/text2int_results.csv
.gitlab-ci.yml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # .gitlab-ci.yml keyword reference
2
+ # https://docs.gitlab.com/ee/ci/yaml/
3
+
4
+ stages:
5
+ - test
6
+
7
+ test:
8
+ stage: test
9
+ image: python:3.10-slim-buster
10
+ before_script:
11
+ - echo "Test stage has started!"
12
+ script:
13
+ - pip install -r requirements.txt && pytest --verbose
14
+ after_script:
15
+ - echo "Test stage has finished!"
app.py CHANGED
@@ -293,4 +293,5 @@ with gr.Blocks() as html_block:
293
 
294
  html_block.predict_durations = []
295
 
296
- html_block.launch()
 
 
293
 
294
  html_block.predict_durations = []
295
 
296
+ if __name__ == "__main__":
297
+ html_block.launch()
data/test_text2int.all.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ input,output
2
+ fourteen,14
3
+ one thousand four hundred ninety two,1492
4
+ Fourteen Hundred Ninety-Two,1492
5
+ forteen,14
6
+ seventeen-thousand and seventy two, 17072
7
+ two hundred and nine, 209
8
+ ninety nine hundred and seventy seven, 9977
9
+ seven thousands, 7000
10
+ 2 hundreds, 200
11
+ 99 thousands and one, 9901
12
+ "forty-five thousand, seven hundred and nine", 45709
13
+ eighty eight hundred eighty, 8880
14
+ a hundred hundred, 10000
15
+ a hundred thousand, 100000
16
+ a hundred million, 100000000
17
+ nineteen ninety nine, 1999
18
+ forteen twenty seven, 1427
19
+ one nine eight five,1985
20
+ nineteen eighty-five,1985
21
+ six,6
22
+ eighty,80
23
+ eight three seven five three zero nine,8375308
24
+ oh one,1
25
+ six oh 1,601
26
+ sex,6
27
+ eight oh,80
28
+ ate,8
29
+ double eight,88
30
+ eight three seven five three O nine,8375308
31
+ eight three seven five three oh nine,8375308
32
+ eight three seven five three 0 nine,8375308
33
+ eight three seven five three oh ni-ee-ine,8375308
34
+ two thousand ten,2010
35
+ two thousand and ten,2010
36
+ twelve million,12000000
37
+ 8 billion,8000000000
38
+ twenty ten,2010
39
+ thirty-two hundred,3200
40
+ nine,9
41
+ forty two,42
42
+ 1 2 three,123
data/text2int_results.csv ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ input,output,text2int,score
2
+ fourteen,14,14.0,True
3
+ one thousand four hundred ninety two,1492,1492.0,True
4
+ Fourteen Hundred Ninety-Two,1492,1492.0,True
5
+ forteen,14,14.0,True
6
+ seventeen-thousand and seventy two,17072,17072.0,True
7
+ two hundred and nine,209,209.0,True
8
+ ninety nine hundred and seventy seven,9977,276.0,False
9
+ seven thousands,7000,217.0,False
10
+ 2 hundreds,200,60.0,False
11
+ 99 thousands and one,9901,162.0,False
12
+ "forty-five thousand, seven hundred and nine",45709,192.0,False
13
+ eighty eight hundred eighty,8880,268.0,False
14
+ a hundred hundred,10000,3200.0,False
15
+ a hundred thousand,100000,4100.0,False
16
+ a hundred million,100000000,3100000000.0,False
17
+ nineteen ninety nine,1999,1809.0,False
18
+ forteen twenty seven,1427,307.0,False
19
+ one nine eight five,1985,1985.0,True
20
+ nineteen eighty-five,1985,1605.0,False
21
+ six,6,6.0,True
22
+ eighty,80,80.0,True
23
+ eight three seven five three zero nine,8375308,8375309.0,False
24
+ oh one,1,1.0,True
25
+ six oh 1,601,601.0,True
26
+ sex,6,6.0,True
27
+ eight oh,80,8.0,False
28
+ ate,8,8.0,True
29
+ double eight,88,,False
30
+ eight three seven five three O nine,8375308,8375309.0,False
31
+ eight three seven five three oh nine,8375308,8375309.0,False
32
+ eight three seven five three 0 nine,8375308,8375309.0,False
33
+ eight three seven five three oh ni-ee-ine,8375308,115.0,False
34
+ two thousand ten,2010,2010.0,True
35
+ two thousand and ten,2010,2010.0,True
36
+ twelve million,12000000,12000000.0,True
37
+ 8 billion,8000000000,8000000000.0,True
38
+ twenty ten,2010,2010.0,True
39
+ thirty-two hundred,3200,3200.0,True
40
+ nine,9,9.0,True
41
+ forty two,42,42.0,True
42
+ 1 2 three,123,123.0,True
requirements.txt CHANGED
@@ -1,9 +1,10 @@
1
- spacy
2
- pandas
3
- pandas-gbq
4
- gradio==3.14.0
5
- python-dotenv
6
- transformers
7
- torch
8
- httpx
9
- matplotlib
 
 
1
+ spacy==3.4.*
2
+ pandas==1.5.*
3
+ pandas-gbq==0.19.*
4
+ gradio==3.14.*
5
+ python-dotenv==0.21.*
6
+ transformers==4.24.*
7
+ torch==1.12.*
8
+ httpx==0.23.*
9
+ matplotlib==3.6.*
10
+ pytest==7.2.*
tests/__init__.py ADDED
File without changes
tests/test_text2int.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+
3
+ import pandas as pd
4
+
5
+ from app import text2int
6
+
7
+
8
+ TEST_DATA_FILE = "data/test_text2int.all.csv"
9
+
10
+
11
+ class TestStringMethods(unittest.TestCase):
12
+
13
+ def setUp(self):
14
+ pass
15
+
16
+ @staticmethod
17
+ def get_text2int(text):
18
+ """Makes a post request to the endpoint"""
19
+ r = None
20
+ try:
21
+ r = text2int(text)
22
+ except:
23
+ pass
24
+ return r
25
+
26
+
27
+ def test_acc_score_text2int(self):
28
+ """Calculates accuracy score for endpoint"""
29
+ df = pd.read_csv(TEST_DATA_FILE)
30
+
31
+ df["text2int"] = df["input"].apply(func=self.get_text2int)
32
+ df["score"] = df[["output", "text2int"]].apply(
33
+ lambda row: row[0] == row[1],
34
+ axis=1
35
+ )
36
+ df.to_csv("data/text2int_results.csv", index=False)
37
+ acc_score = df["score"].mean().__round__(2)
38
+
39
+ self.assertGreaterEqual(acc_score, 0.8, f"Accuracy score: '{acc_score}'. Value is too low!")
40
+
41
+
42
+ if __name__ == '__main__':
43
+ unittest.main()