klasocki commited on
Commit
f42d24c
1 Parent(s): a3e3b16

Refactor the openapi spec to remove duplication

Browse files
Files changed (2) hide show
  1. commafixer/src/fixer.py +1 -0
  2. openapi.yaml +42 -45
commafixer/src/fixer.py CHANGED
@@ -84,6 +84,7 @@ def _fix_commas_based_on_labels_and_offsets(
84
 
85
  def _should_insert_comma(label, result, current_offset) -> bool:
86
  # Only insert commas for the final token of a word, that is, if next word starts with a space.
 
87
  return label == 'B-COMMA' and result[current_offset].isspace()
88
 
89
 
 
84
 
85
  def _should_insert_comma(label, result, current_offset) -> bool:
86
  # Only insert commas for the final token of a word, that is, if next word starts with a space.
87
+ # TODO perharps for low confidence tokens, we should use the original decision of the user in the input?
88
  return label == 'B-COMMA' and result[current_offset].isspace()
89
 
90
 
openapi.yaml CHANGED
@@ -8,68 +8,65 @@ servers:
8
  paths:
9
  /fix-commas:
10
  post:
11
- summary: Fixes comma placement in a sentence using the fine-tuned model
12
  requestBody:
13
  required: true
14
  content:
15
  application/json:
16
  schema:
17
- type: object
18
- properties:
19
- s:
20
- type: string
21
- example: 'This, is a sentence with wrong commas at least some.'
22
- description: The text with commas to fix. Commas can be removed, added, reordered at will, or left
23
- unchanged. Other punctuation, whitespaces and so on will stay intact.
24
  responses:
25
  200:
26
- description: Commas fixed.
27
- content:
28
- application/json:
29
- schema:
30
- type: object
31
- properties:
32
- s:
33
- type: string
34
- example: 'This is a sentence with wrong commas, at least some.'
35
- description: A text with commas fixed, or unchanged if not necessary. Everything other that
36
- commas will stay as it was originally.
37
-
38
  400:
39
- description: A required field missing from the POST request body JSON.
40
-
41
- # TODO remove duplication here
42
 
43
  /baseline/fix-commas:
44
  post:
45
- summary: Fixes comma placement in a sentence using the baseline model
46
  requestBody:
47
  required: true
48
  content:
49
  application/json:
50
  schema:
51
- type: object
52
- properties:
53
- s:
54
- type: string
55
- example: 'This, is a sentence with wrong commas at least some.'
56
- description: The text with commas to fix. Commas can be removed, added, reordered at will, or left
57
- unchanged. Other punctuation, whitespaces and so on will stay intact.
58
  responses:
59
  200:
60
- description: Commas fixed.
61
- content:
62
- application/json:
63
- schema:
64
- type: object
65
- properties:
66
- s:
67
- type: string
68
- example: 'This is a sentence with wrong commas, at least some.'
69
- description: A text with commas fixed, or unchanged if not necessary. Everything other that
70
- commas will stay as it was originally.
71
-
72
  400:
73
- description: A required field missing from the POST request body JSON.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
-
 
 
8
  paths:
9
  /fix-commas:
10
  post:
11
+ summary: Fixes comma placement in a sentence using the fine-tuned model (https://huggingface.co/klasocki/roberta-large-lora-ner-comma-fixer)
12
  requestBody:
13
  required: true
14
  content:
15
  application/json:
16
  schema:
17
+ $ref: '#/components/schemas/CommaFixerRequestBody'
 
 
 
 
 
 
18
  responses:
19
  200:
20
+ $ref: '#/components/responses/200Fixed'
 
 
 
 
 
 
 
 
 
 
 
21
  400:
22
+ $ref: '#/components/responses/400ParameterMissing'
23
+ 422:
24
+ $ref: '#/components/responses/422BodyMissing'
25
 
26
  /baseline/fix-commas:
27
  post:
28
+ summary: Fixes comma placement in a sentence using the baseline model (https://huggingface.co/oliverguhr/fullstop-punctuation-multilang-large)
29
  requestBody:
30
  required: true
31
  content:
32
  application/json:
33
  schema:
34
+ $ref: '#/components/schemas/CommaFixerRequestBody'
 
 
 
 
 
 
35
  responses:
36
  200:
37
+ $ref: '#/components/responses/200Fixed'
 
 
 
 
 
 
 
 
 
 
 
38
  400:
39
+ $ref: '#/components/responses/400ParameterMissing'
40
+ 422:
41
+ $ref: '#/components/responses/422BodyMissing'
42
+
43
+ components:
44
+ schemas:
45
+ CommaFixerRequestBody:
46
+ type: object
47
+ properties:
48
+ s:
49
+ type: string
50
+ example: 'This, is a sentence with wrong commas at least some.'
51
+ description: The text with commas to fix. Commas can be removed, added, reordered at will, or left
52
+ unchanged. Other punctuation, whitespaces and so on will stay intact.
53
+
54
+ responses:
55
+ 200Fixed:
56
+ description: Commas fixed.
57
+ content:
58
+ application/json:
59
+ schema:
60
+ type: object
61
+ properties:
62
+ s:
63
+ type: string
64
+ example: 'This is a sentence with wrong commas, at least some.'
65
+ description: A text with commas fixed, or unchanged if not necessary. Everything other that
66
+ commas will stay as it was originally.
67
+
68
+ 400ParameterMissing:
69
+ description: A required field missing from the POST request body JSON.
70
 
71
+ 422BodyMissing:
72
+ description: Request body missing