diff --git a/kos2vec/flow_test.py b/kos2vec/flow_test.py index e302fef..eea5525 100755 --- a/kos2vec/flow_test.py +++ b/kos2vec/flow_test.py @@ -5,7 +5,17 @@ import sys for line in sys.stdin: - data=json.loads(line) - data['value']=(data['value']).lower() + + try: + data = json.loads(line) + # trace + #print("******** FORMAT OK : id:{}".format(data["id"])) + except json.decoder.JSONDecodeError: + mess='[{"code" : "1","message":"Input format problem line :{compteur} : String could not be converted to JSON".format(compteur)"}]' + exit({mess}) + + result=(data['value']).lower() + # test if result is json + data["value"] = result sys.stdout.write(json.dumps(data)) sys.stdout.write('\n') diff --git a/kos2vec/indexer.py b/kos2vec/indexer.py index 35b173a..783ac09 100755 --- a/kos2vec/indexer.py +++ b/kos2vec/indexer.py @@ -36,32 +36,40 @@ # lecture ligne a ligne sur input standard # 1 ligne = un json {} def main(config): - + + worker="8" + indexer = CSOClassifier( modules="both", enhancement="first", explanation=False, - delete_outliers=False, # False pour que ca marche sinon error : - silent=True, - fast_classification=False, + delete_outliers=False, # False pour que ca marche sinon error : + silent=True, # Si False ==> >>> + fast_classification=True, # marche pas en EZS sinon configFile=config, # a passer en arg par le .ini + workers=worker, ) compteur = 0 for json_line in sys.stdin: # deserialisation json - compteur += 1 + # compteur += 1 try: data = json.loads(json_line) - # trace - # print("******** FORMAT OK : id:{}".format(data["id"])) + # trace + #print("******** FORMAT OK : id:{}".format(data["id"])) except json.decoder.JSONDecodeError: - print("Input format problem line :{} : String could not be converted to JSON".format(compteur)) - exit(1) - #data["value"] = indexer.run(data["value"]) - data["value"] = indexer.run(data["value"]) - sys.stdout.write(json.dumps(data)) - sys.stdout.write("\n") + mess='[{"code" : "1","message":"Input format problem line :{compteur} : String could not be converted to JSON".format(compteur)"}]' + exit({mess}) + + data["value"] = indexer.run(data["value"]) # <============== ligne qui si silent=False + if not bool( data["value"]): + sys.stderr.write('ERROR OUPUT EMPTY !! \n') + + #trace + #sys.stderr.write(str(data["value"]) + '\n') + sys.stdout.write(json.dumps(data) +'\n') + if __name__ == "__main__": if False: diff --git a/kos2vec/v1/JVR/index.ini b/kos2vec/v1/JVR/index.ini index 30872c9..ae74b99 100755 --- a/kos2vec/v1/JVR/index.ini +++ b/kos2vec/v1/JVR/index.ini @@ -33,7 +33,7 @@ [expand/exec] # command should be executable ! command = ./indexer.py -args = fix("config-memory-neuro-mesh.ini") +args = fix("config-memory-neuro-mesh-v1.ini") [dump] indent = env('indent', false) diff --git a/kos2vec/v1/P21/index.ini b/kos2vec/v1/P21/index.ini index ceb6da0..fd6f254 100755 --- a/kos2vec/v1/P21/index.ini +++ b/kos2vec/v1/P21/index.ini @@ -1,7 +1,7 @@ # OpenAPI Documentation - JSON format (dot notation) mimeType = application/json -post.operationId = post-v1-detect-lang -post.description =indexation +post.operationId = indexation-vocab +post.description = indexation post.responses.default.description = Renvoie un Json composé d`id`, `value` avec `value` qui contient le resultat d une indexation Loterre post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream post.summary = indexation sur ressource loterre mémoire @@ -30,10 +30,12 @@ size = 100 # in production mode, uncomment the following line # cache = boost + [expand/exec] # command should be executable ! command = ./indexer.py args = fix("config-memory-shs-litterature-v1.ini") +#command = ./flow_test.py [dump] indent = env('indent', false) diff --git a/kos2vec/v1/P66/index.ini b/kos2vec/v1/P66/index.ini index cb39cc7..99844db 100755 --- a/kos2vec/v1/P66/index.ini +++ b/kos2vec/v1/P66/index.ini @@ -1,8 +1,8 @@ # OpenAPI Documentation - JSON format (dot notation) mimeType = application/json -post.operationId = post-v1-detect-lang +post.operationId = indexation-vocab post.description = indexation -post.responses.default.description = Renvoie un Json composé d id, value avec value qui contient le resultat d une indexation Loterre +post.responses.default.description = Renvoie un Json composé d`id`, `value` avec `value` qui contient le resultat d une indexation Loterre post.responses.default.content.application/json.schema.$ref = #/components/schemas/JSONStream post.summary = indexation sur ressource loterre mémoire post.tags.0 = NLP @@ -30,10 +30,12 @@ size = 100 # in production mode, uncomment the following line # cache = boost + [expand/exec] # command should be executable ! command = ./indexer.py -args = fix("config-memory-neuro-memoirePsy.ini") +args = fix("config-memory-neuro-memoirePsy-v1.ini") +#command = ./flow_test.py [dump] indent = env('indent', false)