Evalúa una versión del procesador
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Evalúa una versión del procesador con un conjunto de datos proporcionado.
Explora más
Para obtener documentación en la que se incluye esta muestra de código, consulta lo siguiente:
Muestra de código
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis code sample demonstrates how to evaluate a specific processor version within the Document AI service using a provided dataset.\u003c/p\u003e\n"],["\u003cp\u003eThe evaluation process requires specifying the project ID, location, processor ID, processor version ID, and a Google Cloud Storage (GCS) URI containing the input data.\u003c/p\u003e\n"],["\u003cp\u003eThe code utilizes the Document AI Python client library to send an \u003ccode\u003eEvaluateProcessorVersionRequest\u003c/code\u003e to the service.\u003c/p\u003e\n"],["\u003cp\u003eThe evaluation process is an asynchronous operation that will continue until complete, and after which the evaluation ID will be returned.\u003c/p\u003e\n"],["\u003cp\u003eThe document describes where the python API reference and setting up authentication for a local development environment can be found, as well as where to find more code samples.\u003c/p\u003e\n"]]],[],null,["Evaluate a processor version with a supplied dataset.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Evaluate performance](/document-ai/docs/evaluate)\n\nCode sample \n\nPython\n\n\nFor more information, see the\n[Document AI Python API\nreference documentation](/python/docs/reference/documentai/latest).\n\n\nTo authenticate to Document AI, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n from google.api_core.client_options import ClientOptions\n from google.cloud import documentai # type: ignore\n\n # TODO(developer): Uncomment these variables before running the sample.\n # project_id = 'YOUR_PROJECT_ID'\n # location = 'YOUR_PROCESSOR_LOCATION' # Format is 'us' or 'eu'\n # processor_id = 'YOUR_PROCESSOR_ID'\n # processor_version_id = 'YOUR_PROCESSOR_VERSION_ID'\n # gcs_input_uri = # Format: gs://bucket/directory/\n\n\n def evaluate_processor_version_sample(\n project_id: str,\n location: str,\n processor_id: str,\n processor_version_id: str,\n gcs_input_uri: str,\n ) -\u003e None:\n # You must set the api_endpoint if you use a location other than 'us', e.g.:\n opts = ClientOptions(api_endpoint=f\"{location}-documentai.googleapis.com\")\n\n client = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html(client_options=opts)\n\n # The full resource name of the processor version\n # e.g. `projects/{project_id}/locations/{location}/processors/{processor_id}/processorVersions/{processor_version_id}`\n name = client.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html#google_cloud_documentai_v1_services_document_processor_service_DocumentProcessorServiceClient_processor_version_path(\n project_id, location, processor_id, processor_version_id\n )\n\n evaluation_documents = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.BatchDocumentsInputConfig.html(\n gcs_prefix=documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.GcsPrefix.html(gcs_uri_prefix=gcs_input_uri)\n )\n\n # NOTE: Alternatively, specify a list of GCS Documents\n #\n # gcs_input_uri = \"gs://bucket/directory/file.pdf\"\n # input_mime_type = \"application/pdf\"\n #\n # gcs_document = documentai.GcsDocument(\n # gcs_uri=gcs_input_uri, mime_type=input_mime_type\n # )\n # gcs_documents = [gcs_document]\n # evaluation_documents = documentai.BatchDocumentsInputConfig(\n # gcs_documents=documentai.GcsDocuments(documents=gcs_documents)\n # )\n #\n\n request = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.EvaluateProcessorVersionRequest.html(\n processor_version=name,\n evaluation_documents=evaluation_documents,\n )\n\n # Make EvaluateProcessorVersion request\n # Continually polls the operation until it is complete.\n # This could take some time for larger files\n operation = client.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.services.document_processor_service.DocumentProcessorServiceClient.html#google_cloud_documentai_v1_services_document_processor_service_DocumentProcessorServiceClient_evaluate_processor_version(request=request)\n # Print operation details\n # Format: projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID\n print(f\"Waiting for operation {operation.operation.name} to complete...\")\n # Wait for operation to complete\n response = documentai.https://cloud.google.com/python/docs/reference/documentai/latest/google.cloud.documentai_v1.types.EvaluateProcessorVersionResponse.html(operation.result())\n\n # After the operation is complete,\n # Print evaluation ID from operation response\n print(f\"Evaluation Complete: {response.evaluation}\")\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=documentai)."]]