class_docstr: This class extracts a number of basic text descriptives from FeedbackDataset
  records using the TextDescriptives library and adds them as record metadata.
class_docstr_tok: ["This","class","extracts","a","number","of","basic","text","descriptives","from","FeedbackDataset","records","using","the","TextDescriptives","library","and","adds","them","as","record","metadata","."]
docstr: Extract text descriptives metrics from a list of FeedbackDataset or RemoteFeedbackDataset records,
  add them as metadata to the records and return the updated records.
  
  Args:
      records (List[Union[FeedbackRecord, RemoteFeedbackRecord]]): A list of FeedbackDataset or RemoteFeedbackDataset records.
      fields (List[str]): A list of fields to extract metrics for. If None, extract metrics for all fields.
      overwrite (Optional[bool]): Whether to overwrite existing metadata properties with the same name. Defaults to False.
  
  Returns:
      List[Union[FeedbackRecord, RemoteFeedbackRecord]]: A list of FeedbackDataset or RemoteFeedbackDataset records with text descriptives metrics added as metadata.
  
  Examples:
  >>> from argilla.client.feedback.integrations.textdescriptives import TextDescriptivesExtractor
  >>> records = [rg.FeedbackRecord(fields={"text": "This is a test."})]
  >>> tde = TextDescriptivesExtractor()
  >>> updated_records = tde.update_records(records)
docstr_tok: ["Extract","text","descriptives","metrics","from","a","list","of","FeedbackDataset","or","RemoteFeedbackDataset","records",",","add","them","as","metadata","to","the","records","and","return","the","updated","records",".","Args",":","records","(","List","[","Union","[","FeedbackRecord",",","RemoteFeedbackRecord","]","]",")",":","A","list","of","FeedbackDataset","or","RemoteFeedbackDataset","records",".","fields","(","List","[","str","]",")",":","A","list","of","fields","to","extract","metrics","for",".","If","None",",","extract","metrics","for","all","fields",".","overwrite","(","Optional","[","bool","]",")",":","Whether","to","overwrite","existing","metadata","properties","with","the","same","name",".","Defaults","to","False",".","Returns",":","List","[","Union","[","FeedbackRecord",",","RemoteFeedbackRecord","]","]",":","A","list","of","FeedbackDataset","or","RemoteFeedbackDataset","records","with","text","descriptives","metrics","added","as","metadata",".","Examples",":",">",">",">","from","argilla.client.feedback.integrations.textdescriptives","import","TextDescriptivesExtractor",">",">",">","records","=","[","rg.FeedbackRecord","(","fields=","{","``","text","''",":","``","This","is","a","test",".","''","}",")","]",">",">",">","tde","=","TextDescriptivesExtractor","(",")",">",">",">","updated_records","=","tde.update_records","(","records",")"]
code: def update_records(
      self,
      records: List[Union[FeedbackRecord, RemoteFeedbackRecord]],
      fields: Optional[List[str]] = None,
      overwrite: Optional[bool] = False,
  ) -> List[Union[FeedbackRecord, RemoteFeedbackRecord]]:
      """
      Extract text descriptives metrics from a list of FeedbackDataset or RemoteFeedbackDataset records,
      add them as metadata to the records and return the updated records.
  
      Args:
          records (List[Union[FeedbackRecord, RemoteFeedbackRecord]]): A list of FeedbackDataset or RemoteFeedbackDataset records.
          fields (List[str]): A list of fields to extract metrics for. If None, extract metrics for all fields.
          overwrite (Optional[bool]): Whether to overwrite existing metadata properties with the same name. Defaults to False.
  
      Returns:
          List[Union[FeedbackRecord, RemoteFeedbackRecord]]: A list of FeedbackDataset or RemoteFeedbackDataset records with text descriptives metrics added as metadata.
  
      Examples:
      >>> from argilla.client.feedback.integrations.textdescriptives import TextDescriptivesExtractor
      >>> records = [rg.FeedbackRecord(fields={"text": "This is a test."})]
      >>> tde = TextDescriptivesExtractor()
      >>> updated_records = tde.update_records(records)
      """
      available_fields = set()
      # ensure records are unique and don't update updated indices
      modified_records = []
      for rec in records:
          modified_records.append(rec)
          for key in rec.fields:
              available_fields.add(key)
      if fields is None:
          fields = list(available_fields)
      # Extract text descriptives metrics from records
      extracted_metrics = self._extract_metrics_for_all_fields(
          modified_records, overwrite=overwrite, fields=fields
      )
      # If the dataframe doesn't contain any columns, return the original records and log a warning
      if extracted_metrics.shape[1] == 0:
          warnings.warn(
              "No text descriptives metrics were extracted. This could be because the metrics contained NaNs."
          )
          return modified_records
      else:
          # Cast integer and boolean columns to Python native types
          extracted_metrics = self._cast_to_python_types(
              extracted_metrics
          )
          # Clean column names
          extracted_metrics.columns = [
              self._clean_column_name(col)
              for col in extracted_metrics.columns
          ]
          # Add the metrics to the metadata of the records
          modified_records = self._add_text_descriptives_to_metadata(
              modified_records, extracted_metrics
          )
          return modified_records
  
imports: import logging
  import re
  import warnings
  from typing import Any, List, Optional, Union
  import numpy
  import pandas
  from rich.progress import Progress
  from argilla.client.feedback.dataset.local.dataset import FeedbackDataset
  from argilla.client.feedback.dataset.remote.dataset import RemoteFeedbackDataset
  from argilla.client.feedback.schemas.metadata import FloatMetadataProperty, IntegerMetadataProperty, TermsMetadataProperty
  from argilla.client.feedback.schemas.records import FeedbackRecord
  from argilla.client.feedback.schemas.remote.records import RemoteFeedbackRecord
  from argilla.utils.dependency import require_dependencies
label_desc: Use image node_id 9 for calling the TextDescriptivesExtractor obj's underlying member method code with example usage: obj.update_records(records, fields, overwrite) and returns: modified_records, modified_records