Κοινοποίηση μέσω


sentences

Splits a string into arrays of sentences, where each sentence is an array of words.

The language and country arguments are optional. When they are omitted:

  • If they are both omitted, the Locale.ROOT - locale(language='', country='') is used. The Locale.ROOT is regarded as the base locale of all locales, and is used as the language/country neutral locale for the locale sensitive operations.
  • If the country is omitted, the locale(language, country='') is used.

When they are null:

  1. If they are both null, the Locale.US - locale(language='en', country='US') is used.
  2. If the language is null and the country is not null, the Locale.US - locale(language='en', country='US') is used.
  3. If the language is not null and the country is null, the locale(language) is used.
  4. If neither is null, the locale(language, country) is used.

For the corresponding Databricks SQL function, see sentences function.

Syntax

from pyspark.databricks.sql import functions as dbf

dbf.sentences(string=<string>, language=<language>, country=<country>)

Parameters

Parameter Type Description
string pyspark.sql.Column or str a string to be split
language pyspark.sql.Column or str, optional a language of the locale
country pyspark.sql.Column or str, optional a country of the locale

Returns

pyspark.sql.Column: arrays of split sentences.

Examples

from pyspark.databricks.sql import functions as dbf
df = spark.createDataFrame([("This is an example sentence.", )], ["s"])
df.select("*", dbf.sentences(df.s, dbf.lit("en"), dbf.lit("US"))).show(truncate=False)
df.select("*", dbf.sentences(df.s, dbf.lit("en"))).show(truncate=False)
df.select("*", dbf.sentences(df.s)).show(truncate=False)