зеркало из https://github.com/microsoft/presidio.git
analyzer request
This commit is contained in:
Родитель
8f613293d1
Коммит
44e3b6a084
|
@ -107,6 +107,14 @@
|
|||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==2.10"
|
||||
},
|
||||
"importlib-metadata": {
|
||||
"hashes": [
|
||||
"sha256:ace61d5fc652dc280e7b6b4ff732a9c2d40db2c0f92bc6cb74e07b73d53a1771",
|
||||
"sha256:fa5daa4477a7414ae34e95942e4dd07f62adf589143c875c133c1e53c4eff38d"
|
||||
],
|
||||
"markers": "python_version < '3.8'",
|
||||
"version": "==3.4.0"
|
||||
},
|
||||
"itsdangerous": {
|
||||
"hashes": [
|
||||
"sha256:321b033d07f2a4136d3ec762eac9f16a10ccd60f53c0c91af90217ace7ba1f19",
|
||||
|
@ -320,7 +328,7 @@
|
|||
"sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
|
||||
"sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced"
|
||||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==1.15.0"
|
||||
},
|
||||
"spacy": {
|
||||
|
@ -390,6 +398,15 @@
|
|||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==4.56.0"
|
||||
},
|
||||
"typing-extensions": {
|
||||
"hashes": [
|
||||
"sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918",
|
||||
"sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c",
|
||||
"sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"
|
||||
],
|
||||
"markers": "python_version < '3.8'",
|
||||
"version": "==3.7.4.3"
|
||||
},
|
||||
"urllib3": {
|
||||
"hashes": [
|
||||
"sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08",
|
||||
|
@ -412,6 +429,14 @@
|
|||
],
|
||||
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
|
||||
"version": "==1.0.1"
|
||||
},
|
||||
"zipp": {
|
||||
"hashes": [
|
||||
"sha256:102c24ef8f171fd729d46599845e95c7ab894a4cf45f5de11a44cc7444fb1108",
|
||||
"sha256:ed5eee1974372595f9e416cc7bbeeb12335201d8081ca8a0743c954d4446e5cb"
|
||||
],
|
||||
"markers": "python_version >= '3.6'",
|
||||
"version": "==3.4.0"
|
||||
}
|
||||
},
|
||||
"develop": {
|
||||
|
@ -454,6 +479,14 @@
|
|||
],
|
||||
"version": "==1.0.2"
|
||||
},
|
||||
"importlib-metadata": {
|
||||
"hashes": [
|
||||
"sha256:ace61d5fc652dc280e7b6b4ff732a9c2d40db2c0f92bc6cb74e07b73d53a1771",
|
||||
"sha256:fa5daa4477a7414ae34e95942e4dd07f62adf589143c875c133c1e53c4eff38d"
|
||||
],
|
||||
"markers": "python_version < '3.8'",
|
||||
"version": "==3.4.0"
|
||||
},
|
||||
"iniconfig": {
|
||||
"hashes": [
|
||||
"sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3",
|
||||
|
@ -529,7 +562,7 @@
|
|||
"sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1",
|
||||
"sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"
|
||||
],
|
||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==2.4.7"
|
||||
},
|
||||
"pytest": {
|
||||
|
@ -552,8 +585,25 @@
|
|||
"sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b",
|
||||
"sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
|
||||
],
|
||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'",
|
||||
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
|
||||
"version": "==0.10.2"
|
||||
},
|
||||
"typing-extensions": {
|
||||
"hashes": [
|
||||
"sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918",
|
||||
"sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c",
|
||||
"sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f"
|
||||
],
|
||||
"markers": "python_version < '3.8'",
|
||||
"version": "==3.7.4.3"
|
||||
},
|
||||
"zipp": {
|
||||
"hashes": [
|
||||
"sha256:102c24ef8f171fd729d46599845e95c7ab894a4cf45f5de11a44cc7444fb1108",
|
||||
"sha256:ed5eee1974372595f9e416cc7bbeeb12335201d8081ca8a0743c954d4446e5cb"
|
||||
],
|
||||
"markers": "python_version >= '3.6'",
|
||||
"version": "==3.4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from presidio_analyzer.presidio_logger import PresidioLogger
|
||||
from presidio_analyzer.analyzer_engine import AnalyzerEngine
|
||||
from presidio_analyzer.analyzer_request import AnalyzerRequest
|
||||
from flask import Flask, request
|
||||
import json
|
||||
import os
|
||||
|
@ -40,22 +41,15 @@ class Server:
|
|||
Executes the analyzer function
|
||||
"""
|
||||
# Parse the request params
|
||||
req_data = request.get_json()
|
||||
|
||||
text = req_data.get("text")
|
||||
language = req_data.get("language")
|
||||
entities = req_data.get("entities")
|
||||
correlation_id = req_data.get("correlation_id")
|
||||
score_threshold = req_data.get("score_threshold")
|
||||
trace = req_data.get("trace")
|
||||
req_data = AnalyzerRequest(request.get_json())
|
||||
try:
|
||||
recognizer_result_list = self.engine.analyze(
|
||||
text,
|
||||
language,
|
||||
correlation_id=correlation_id,
|
||||
score_threshold=score_threshold,
|
||||
entities=entities,
|
||||
trace=trace)
|
||||
req_data.text,
|
||||
req_data.language,
|
||||
correlation_id=req_data.correlation_id,
|
||||
score_threshold=req_data.score_threshold,
|
||||
entities=req_data.entities,
|
||||
trace=req_data.trace)
|
||||
|
||||
return json.dumps(recognizer_result_list, default=lambda o: o.to_json(),
|
||||
sort_keys=True, indent=4)
|
||||
|
|
|
@ -8,6 +8,7 @@ from presidio_analyzer.pattern_recognizer import PatternRecognizer
|
|||
from presidio_analyzer.remote_recognizer import RemoteRecognizer
|
||||
from presidio_analyzer.recognizer_registry import RecognizerRegistry
|
||||
from presidio_analyzer.analyzer_engine import AnalyzerEngine
|
||||
from presidio_analyzer.analyzer_request import AnalyzerRequest
|
||||
|
||||
|
||||
__all__ = [
|
||||
|
@ -21,4 +22,5 @@ __all__ = [
|
|||
"RemoteRecognizer",
|
||||
"RecognizerRegistry",
|
||||
"AnalyzerEngine",
|
||||
"AnalyzerRequest"
|
||||
]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
class AnalyzerRequest:
|
||||
"""
|
||||
Analyzer request data
|
||||
"""
|
||||
def __init__(self, req_data):
|
||||
self.text = req_data.get("text")
|
||||
self.language = req_data.get("language")
|
||||
self.entities = req_data.get("entities")
|
||||
self.correlation_id = req_data.get("correlation_id")
|
||||
self.score_threshold = req_data.get("score_threshold")
|
||||
self.trace = req_data.get("trace")
|
Загрузка…
Ссылка в новой задаче