class_docstr: Fits an Annotator to match exact strings or regex patterns provided in a
  file against a Document and assigns them an named entity. The definitions
  can contain any number of named entities.
  
  There are multiple ways and formats to set the extraction resource. It is
  possible to set it either as a "JSON", "JSONL" or "CSV" file. A path to the
  file needs to be provided to ``setPatternsResource``. The file format needs
  to be set as the "format" field in the ``option`` parameter map and
  depending on the file type, additional parameters might need to be set.
  
  If the file is in a JSON format, then the rule definitions need to be given
  in a list with the fields "id", "label" and "patterns"::
  
       [
          {
            "id": "person-regex",
            "label": "PERSON",
            "patterns": ["\w+\s\w+", "\w+-\w+"]
          },
          {
            "id": "locations-words",
            "label": "LOCATION",
            "patterns": ["Winterfell"]
          }
      ]
  
  The same fields also apply to a file in the JSONL format::
  
      {"id": "names-with-j", "label": "PERSON", "patterns": ["Jon", "John", "John Snow"]}
      {"id": "names-with-s", "label": "PERSON", "patterns": ["Stark", "Snow"]}
      {"id": "names-with-e", "label": "PERSON", "patterns": ["Eddard", "Eddard Stark"]}
  
  In order to use a CSV file, an additional parameter "delimiter" needs to be
  set. In this case, the delimiter might be set by using
  ``.setPatternsResource("patterns.csv", ReadAs.TEXT, {"format": "csv", "delimiter": "|")})``::
  
      PERSON|Jon
      PERSON|John
      PERSON|John Snow
      LOCATION|Winterfell
  
  ====================== ======================
  Input Annotation types Output Annotation type
  ====================== ======================
  ``DOCUMENT, TOKEN``    ``CHUNK``
  ====================== ======================
  
  Parameters
  ----------
  patternsResource
      Resource in JSON or CSV format to map entities to patterns
  useStorage
      Whether to use RocksDB storage to serialize patterns
  
  Examples
  --------
  >>> import sparknlp
  >>> from sparknlp.base import *
  >>> from sparknlp.annotator import *
  >>> from sparknlp.common import *
  >>> from pyspark.ml import Pipeline
  
  In this example, the entities file as the form of::
  
      PERSON|Jon
      PERSON|John
      PERSON|John Snow
      LOCATION|Winterfell
  
  where each line represents an entity and the associated string delimited by "|".
  
  >>> documentAssembler = DocumentAssembler() \
  ...     .setInputCol("text") \
  ...     .setOutputCol("document")
  >>> tokenizer = Tokenizer() \
  ...     .setInputCols(["document"]) \
  ...     .setOutputCol("token")
  >>> entityRuler = EntityRulerApproach() \
  ...     .setInputCols(["document", "token"]) \
  ...     .setOutputCol("entities") \
  ...     .setPatternsResource(
  ...       "patterns.csv",
  ...       ReadAs.TEXT,
  ...       {"format": "csv", "delimiter": "\\|"}
  ...     )
  >>> pipeline = Pipeline().setStages([
  ...     documentAssembler,
  ...     tokenizer,
  ...     entityRuler
  ... ])
  >>> data = spark.createDataFrame([["Jon Snow wants to be lord of Winterfell."]]).toDF("text")
  >>> result = pipeline.fit(data).transform(data)
  >>> result.selectExpr("explode(entities)").show(truncate=False)
  +--------------------------------------------------------------------+
  |col                                                                 |
  +--------------------------------------------------------------------+
  |[chunk, 0, 2, Jon, [entity -> PERSON, sentence -> 0], []]           |
  |[chunk, 29, 38, Winterfell, [entity -> LOCATION, sentence -> 0], []]|
  +--------------------------------------------------------------------+
docstr: Alphabet Resource (a simple plain text with all language characters)
  
  Parameters
  ----------
  path : str
      Path to the resource
docstr_tok: ["Alphabet","Resource","(","a","simple","plain","text","with","all","language","characters",")","Parameters","--","--","--","--","--","path",":","str","Path","to","the","resource"]
code: def setAlphabetResource(self, path):
      """Alphabet Resource (a simple plain text with all language characters)
  
      Parameters
      ----------
      path : str
          Path to the resource
      """
      return self._set(
          alphabet=ExternalResource(
              path, read_as=ReadAs.TEXT, options={}
          )
      )
  
file_path: spark-nlp/python/sparknlp/annotator/er/entity_ruler.py
imports: from sparknlp.common import *
label_desc: Use image node_id 5 for calling the EntityRulerApproach obj's underlying member method code with example usage: obj.setAlphabetResource(path) and returns: self