cetinca commited on
Commit
cba490f
·
verified ·
1 Parent(s): 6784f95

Created toml file

Browse files
app.py CHANGED
@@ -2,16 +2,18 @@
2
  To run locally use 'uvicorn app:app --host localhost --port 7860'
3
  """
4
 
 
5
  from fastapi import FastAPI, Request
6
  from fastapi.responses import JSONResponse
7
  from fastapi.staticfiles import StaticFiles
8
  from fastapi.templating import Jinja2Templates
9
- from pydantic import BaseModel
10
-
11
  from mathtext.sentiment import sentiment
12
  from mathtext.text2int import text2int
13
- from modules.nlu import prepare_message_data_for_logging
14
 
 
 
 
15
 
16
  app = FastAPI()
17
 
@@ -48,6 +50,7 @@ def text2int_ep(content: Text = None):
48
  content = {"message": ml_response}
49
  return JSONResponse(content=content)
50
 
 
51
  @app.post("/nlu")
52
  async def evaluate_user_message_with_nlu_api(request: Request):
53
  """ Calls NLU APIs on the most recent user message from Turn.io message data and logs the message data
 
2
  To run locally use 'uvicorn app:app --host localhost --port 7860'
3
  """
4
 
5
+ from dotenv import load_dotenv
6
  from fastapi import FastAPI, Request
7
  from fastapi.responses import JSONResponse
8
  from fastapi.staticfiles import StaticFiles
9
  from fastapi.templating import Jinja2Templates
 
 
10
  from mathtext.sentiment import sentiment
11
  from mathtext.text2int import text2int
12
+ from pydantic import BaseModel
13
 
14
+ from mathtext_fastapi.nlu import prepare_message_data_for_logging
15
+
16
+ load_dotenv()
17
 
18
  app = FastAPI()
19
 
 
50
  content = {"message": ml_response}
51
  return JSONResponse(content=content)
52
 
53
+
54
  @app.post("/nlu")
55
  async def evaluate_user_message_with_nlu_api(request: Request):
56
  """ Calls NLU APIs on the most recent user message from Turn.io message data and logs the message data
data/master_test_text2int.csv DELETED
@@ -1,90 +0,0 @@
1
- input,output
2
- fourteen,14
3
- forteen,14
4
- one thousand four hundred ninety two,1492
5
- one thousand ninety two,1092
6
- Fourteen Hundred Ninety-Two,1492
7
- Fourteen Hundred,1400
8
- Ninety nine,99
9
- fifteen thousand five hundred-sixty,15560
10
- three hundred fifty,350
11
- one nine eight five,1985
12
- nineteen eighty-five,1985
13
- oh one,1
14
- six oh 1,601
15
- sex,6
16
- six,6
17
- eight oh,80
18
- eighty,80
19
- ate,8
20
- double eight,88
21
- eight three seven five three O nine,8375309
22
- eight three seven five three oh nine,8375309
23
- eight three seven five three zero nine,8375309
24
- eight three seven five three oh ni-ee-ine,8375309
25
- two eight,28
26
- seven oh eleven,7011
27
- seven elevens,77
28
- seven eleven,711
29
- ninety nine oh five,9905
30
- seven 0 seven 0 seven 0 seven,7070707
31
- 123 hundred,123000
32
- 5 o 5,505
33
- 15 o 5,1505
34
- 15-o 5,1505
35
- 15 o-5,1505
36
- 911-thousand,911000
37
- twenty-two twenty-two,2222
38
- twenty-two twenty-twos,484
39
- four eighty four,484
40
- four eighties,320
41
- four eighties and nine nineties,1130
42
- ninety nine hundred and seventy seven,9977
43
- seven thousands,7000
44
- 2 hundreds,200
45
- 99 thousands and one,99001
46
- "forty-five thousand, seven hundred and nine",45709
47
- eighty eight hundred eighty,8880
48
- a hundred hundred,10000
49
- a hundred thousand,100000
50
- a hundred million,100000000
51
- nineteen ninety nine,1999
52
- forteen twenty seven,1427
53
- seventeen-thousand and seventy two,17072
54
- two hundred and nine,209
55
- two thousand ten,2010
56
- two thousand and ten,2010
57
- twelve million,12000000
58
- 8 billion,8000000000
59
- twenty ten,2010
60
- thirty-two hundred,3200
61
- nine,9
62
- forty two,42
63
- 1 2 three,123
64
- fourtean,14
65
- one tousand four hundred ninty two,1492
66
- Furteen Hundrd Ninety-Too,1492
67
- forrteen,14
68
- sevnteen-thosand and seventy two,17072
69
- ninety nine hundred ad seventy seven,9977
70
- seven thusands,7000
71
- 2 hunreds,200
72
- 99 tousands and one,99001
73
- eighty ate hundred eighty,8880
74
- fourteen Hundred,1400
75
- 8 Bilion,8000000000
76
- one million three thousand one,1003001
77
- four million nine thousand seven,4009007
78
- two million five hundred thousand,2500000
79
- two tousand ten,2010
80
- two thousand teen,2010
81
- tvelve milion,12000000
82
- tventy ten,2010
83
- tirty-twoo hunred,3200
84
- sevn thoosands,7000
85
- five,5
86
- ten,10
87
- one two three and ten,12310
88
- ONE MILLion three hunded and fiv,1000305
89
- "50,500 and six",50506
90
- one_million_and_five,1000005
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/text2int_results.csv DELETED
@@ -1,90 +0,0 @@
1
- input,output,text2int,score
2
- fourteen,14,14,True
3
- forteen,14,14,True
4
- one thousand four hundred ninety two,1492,1492,True
5
- one thousand ninety two,1092,1092,True
6
- Fourteen Hundred Ninety-Two,1492,1492,True
7
- Fourteen Hundred,1400,1400,True
8
- Ninety nine,99,99,True
9
- fifteen thousand five hundred-sixty,15560,15560,True
10
- three hundred fifty,350,350,True
11
- one nine eight five,1985,1985,True
12
- nineteen eighty-five,1985,1605,False
13
- oh one,1,1,True
14
- six oh 1,601,601,True
15
- sex,6,6,True
16
- six,6,6,True
17
- eight oh,80,8,False
18
- eighty,80,80,True
19
- ate,8,1,False
20
- double eight,88,32202,False
21
- eight three seven five three O nine,8375309,8375329,False
22
- eight three seven five three oh nine,8375309,8375309,True
23
- eight three seven five three zero nine,8375309,8375309,True
24
- eight three seven five three oh ni-ee-ine,8375309,837530619,False
25
- two eight,28,16,False
26
- seven oh eleven,7011,77,False
27
- seven elevens,77,77,True
28
- seven eleven,711,77,False
29
- ninety nine oh five,9905,149,False
30
- seven 0 seven 0 seven 0 seven,7070707,7070707,True
31
- 123 hundred,123000,223,False
32
- 5 o 5,505,525,False
33
- 15 o 5,1505,22,False
34
- 15-o 5,1505,22,False
35
- 15 o-5,1505,22,False
36
- 911-thousand,911000,911000,True
37
- twenty-two twenty-two,2222,44,False
38
- twenty-two twenty-twos,484,44,False
39
- four eighty four,484,404,False
40
- four eighties,320,72,False
41
- four eighties and nine nineties,1130,243,False
42
- ninety nine hundred and seventy seven,9977,276,False
43
- seven thousands,7000,7000,True
44
- 2 hundreds,200,200,True
45
- 99 thousands and one,99001,99001,True
46
- "forty-five thousand, seven hundred and nine",45709,1161,False
47
- eighty eight hundred eighty,8880,268,False
48
- a hundred hundred,10000,32202,False
49
- a hundred thousand,100000,32202,False
50
- a hundred million,100000000,32202,False
51
- nineteen ninety nine,1999,1809,False
52
- forteen twenty seven,1427,307,False
53
- seventeen-thousand and seventy two,17072,17072,True
54
- two hundred and nine,209,209,True
55
- two thousand ten,2010,2010,True
56
- two thousand and ten,2010,2010,True
57
- twelve million,12000000,12000000,True
58
- 8 billion,8000000000,8000000000,True
59
- twenty ten,2010,2010,True
60
- thirty-two hundred,3200,3200,True
61
- nine,9,9,True
62
- forty two,42,42,True
63
- 1 2 three,123,123,True
64
- fourtean,14,14,True
65
- one tousand four hundred ninty two,1492,1492,True
66
- Furteen Hundrd Ninety-Too,1492,1492,True
67
- forrteen,14,14,True
68
- sevnteen-thosand and seventy two,17072,17072,True
69
- ninety nine hundred ad seventy seven,9977,32202,False
70
- seven thusands,7000,7000,True
71
- 2 hunreds,200,200,True
72
- 99 tousands and one,99001,99001,True
73
- eighty ate hundred eighty,8880,261,False
74
- fourteen Hundred,1400,1400,True
75
- 8 Bilion,8000000000,8000000,False
76
- one million three thousand one,1003001,1003001,True
77
- four million nine thousand seven,4009007,4009007,True
78
- two million five hundred thousand,2500000,2001500,False
79
- two tousand ten,2010,2010,True
80
- two thousand teen,2010,2007,False
81
- tvelve milion,12000000,12000000,True
82
- tventy ten,2010,2010,True
83
- tirty-twoo hunred,3200,3200,True
84
- sevn thoosands,7000,7000,True
85
- five,5,5,True
86
- ten,10,10,True
87
- one two three and ten,12310,51,False
88
- ONE MILLion three hunded and fiv,1000305,1000305,True
89
- "50,500 and six",50506,50506,True
90
- one_million_and_five,1000005,1000005,True
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{modules → mathtext_fastapi}/__init__.py RENAMED
File without changes
{modules → mathtext_fastapi}/nlu.py RENAMED
@@ -1,13 +1,8 @@
1
  import os
2
  from datetime import datetime
3
 
4
- from dotenv import load_dotenv
5
  from supabase import create_client
6
 
7
- BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
8
-
9
- load_dotenv()
10
-
11
  SUPA = create_client(os.environ.get('SUPABASE_URL'), os.environ.get('SUPABASE_KEY'))
12
 
13
 
 
1
  import os
2
  from datetime import datetime
3
 
 
4
  from supabase import create_client
5
 
 
 
 
 
6
  SUPA = create_client(os.environ.get('SUPABASE_URL'), os.environ.get('SUPABASE_KEY'))
7
 
8
 
pyproject.toml CHANGED
@@ -1,6 +1,6 @@
1
  [tool.poetry]
2
- name = "MathText"
3
- version = "0.0.3"
4
  authors = [
5
  "Sebastian Larsen <[email protected]>",
6
  "Çetin ÇAKIR <[email protected]>",
@@ -8,7 +8,7 @@ authors = [
8
  ]
9
  description = "Natural Language Understanding (text processing) for math symbols, digits, and words with a Gradio user interface and REST API."
10
  readme = "README.md"
11
- # requires-python = ">=3.7"
12
  license = "AGPL-3.0-or-later"
13
  classifiers = [
14
  "Programming Language :: Python :: 3",
@@ -18,7 +18,9 @@ classifiers = [
18
  "Operating System :: OS Independent",
19
  ]
20
 
 
21
  [tool.poetry.dependencies]
 
22
  fastapi = "0.74.*"
23
  requests = "2.27.*"
24
  sentencepiece = "0.1.*"
 
1
  [tool.poetry]
2
+ name = "MathText_FastAPI"
3
+ version = "0.0.1"
4
  authors = [
5
  "Sebastian Larsen <[email protected]>",
6
  "Çetin ÇAKIR <[email protected]>",
 
8
  ]
9
  description = "Natural Language Understanding (text processing) for math symbols, digits, and words with a Gradio user interface and REST API."
10
  readme = "README.md"
11
+ # requires-python = ">=3.8"
12
  license = "AGPL-3.0-or-later"
13
  classifiers = [
14
  "Programming Language :: Python :: 3",
 
18
  "Operating System :: OS Independent",
19
  ]
20
 
21
+
22
  [tool.poetry.dependencies]
23
+ mathtext = {git = "https://gitlab.com/tangibleai/community/mathtext", rev = "main"}
24
  fastapi = "0.74.*"
25
  requests = "2.27.*"
26
  sentencepiece = "0.1.*"