17
17
from medcat_service .types import HealthCheckResponse , ModelCardInfo , ProcessErrorsResult , ProcessResult , ServiceInfo
18
18
19
19
20
- class NlpProcessor :
21
- """
22
- This class defines an interface for NLP Processor
20
+ class MedCatProcessor ():
21
+ """"
22
+ MedCAT Processor class is wrapper over MedCAT that implements annotations extractions functionality
23
+ (both single and bulk processing) that can be easily exposed for an API.
23
24
"""
24
25
25
26
def __init__ (self ):
@@ -32,39 +33,6 @@ def __init__(self):
32
33
self .log .debug ("APP log level set to : " + str (app_log_level ))
33
34
self .log .debug ("MedCAT log level set to : " + str (medcat_log_level ))
34
35
35
- def get_app_info (self ):
36
- pass
37
-
38
- def process_content (self , content , * args , ** kwargs ):
39
- pass
40
-
41
- def process_content_bulk (self , content , * args , ** kwargs ):
42
- pass
43
-
44
- def is_ready (self ) -> HealthCheckResponse :
45
- return HealthCheckResponse (
46
- name = "MedCAT" ,
47
- status = "DOWN"
48
- )
49
-
50
- @staticmethod
51
- def _get_timestamp ():
52
- """
53
- Returns the current timestamp in ISO 8601 format. Formatted as "yyyy-MM-dd"T"HH:mm:ss.SSSXXX".
54
- :return: timestamp string
55
- """
56
- return datetime .now (tz = timezone .utc ).isoformat (timespec = "milliseconds" )
57
-
58
-
59
- class MedCatProcessor (NlpProcessor ):
60
- """"
61
- MedCAT Processor class is wrapper over MedCAT that implements annotations extractions functionality
62
- (both single and bulk processing) that can be easily exposed for an API.
63
- """
64
-
65
- def __init__ (self ):
66
- super ().__init__ ()
67
-
68
36
self .log .info ("Initializing MedCAT processor ..." )
69
37
self ._is_ready_flag = False
70
38
@@ -96,6 +64,14 @@ def __init__(self):
96
64
97
65
self ._is_ready_flag = self ._check_medcat_readiness ()
98
66
67
+ @staticmethod
68
+ def _get_timestamp ():
69
+ """
70
+ Returns the current timestamp in ISO 8601 format. Formatted as "yyyy-MM-dd"T"HH:mm:ss.SSSXXX".
71
+ :return: timestamp string
72
+ """
73
+ return datetime .now (tz = timezone .utc ).isoformat (timespec = "milliseconds" )
74
+
99
75
def _check_medcat_readiness (self ) -> bool :
100
76
readiness_text = "MedCAT is ready and can get_entities"
101
77
try :
@@ -171,7 +147,7 @@ def process_content(self, content, *args, **kwargs):
171
147
nlp_result = ProcessErrorsResult (
172
148
success = False ,
173
149
errors = [error_msg ],
174
- timestamp = NlpProcessor ._get_timestamp (),
150
+ timestamp = self ._get_timestamp (),
175
151
)
176
152
177
153
return nlp_result
@@ -206,7 +182,7 @@ def process_content(self, content, *args, **kwargs):
206
182
text = str (text ),
207
183
annotations = entities ,
208
184
success = True ,
209
- timestamp = NlpProcessor ._get_timestamp (),
185
+ timestamp = self ._get_timestamp (),
210
186
elapsed_time = elapsed_time ,
211
187
footer = content .get ("footer" ),
212
188
)
@@ -442,7 +418,7 @@ def _generate_result(self, in_documents, annotations, elapsed_time):
442
418
text = str (in_ct ["text" ]),
443
419
annotations = entities ,
444
420
success = True ,
445
- timestamp = NlpProcessor ._get_timestamp (),
421
+ timestamp = self ._get_timestamp (),
446
422
elapsed_time = elapsed_time ,
447
423
footer = in_ct .get ("footer" ),
448
424
)
@@ -452,7 +428,7 @@ def _generate_result(self, in_documents, annotations, elapsed_time):
452
428
text = str (in_ct ["text" ]),
453
429
annotations = [],
454
430
success = True ,
455
- timestamp = NlpProcessor ._get_timestamp (),
431
+ timestamp = self ._get_timestamp (),
456
432
elapsed_time = elapsed_time ,
457
433
footer = in_ct .get ("footer" ),
458
434
)
@@ -463,7 +439,7 @@ def _generate_result(self, in_documents, annotations, elapsed_time):
463
439
text = str (in_ct ["text" ]),
464
440
annotations = [],
465
441
success = True ,
466
- timestamp = NlpProcessor ._get_timestamp (),
442
+ timestamp = self ._get_timestamp (),
467
443
elapsed_time = elapsed_time ,
468
444
footer = in_ct .get ("footer" ),
469
445
)
0 commit comments