Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/backend/replication/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 2 kB image not shown  

SSL dict_simple.c

  Interaktion und
PortierbarkeitC
 

/*-------------------------------------------------------------------------
 *
 * dict_simple.c
 *  Simple dictionary: just lowercase and check for stopword
 *
 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
 *
 *
 * IDENTIFICATION
 *   src/backend/tsearch/dict_simple.c
 *
 *-------------------------------------------------------------------------
 */

#include "postgres.h"

#include "catalog/pg_collation_d.h"
#include "commands/defrem.h"
#include "tsearch/ts_public.h"
#include "utils/fmgrprotos.h"
#include "utils/formatting.h"


typedef struct
{
 StopList stoplist;
 bool  accept;
} DictSimple;


Datum
dsimple_init(PG_FUNCTION_ARGS)
{
 List    *dictoptions = (List *) PG_GETARG_POINTER(0);
 DictSimple *d = (DictSimple *) palloc0(sizeof(DictSimple));
 bool  stoploaded = false,
    acceptloaded = false;
 ListCell   *l;

 d->accept = true;   /* default */

 foreach(l, dictoptions)
 {
  DefElem    *defel = (DefElem *) lfirst(l);

  if (strcmp(defel->defname, "stopwords") == 0)
  {
   if (stoploaded)
    ereport(ERROR,
      (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
       errmsg("multiple StopWords parameters")));
   readstoplist(defGetString(defel), &d->stoplist, str_tolower);
   stoploaded = true;
  }
  else if (strcmp(defel->defname, "accept") == 0)
  {
   if (acceptloaded)
    ereport(ERROR,
      (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
       errmsg("multiple Accept parameters")));
   d->accept = defGetBoolean(defel);
   acceptloaded = true;
  }
  else
  {
   ereport(ERROR,
     (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
      errmsg("unrecognized simple dictionary parameter: \"%s\"",
       defel->defname)));
  }
 }

 PG_RETURN_POINTER(d);
}

Datum
dsimple_lexize(PG_FUNCTION_ARGS)
{
 DictSimple *d = (DictSimple *) PG_GETARG_POINTER(0);
 char    *in = (char *) PG_GETARG_POINTER(1);
 int32  len = PG_GETARG_INT32(2);
 char    *txt;
 TSLexeme   *res;

 txt = str_tolower(in, len, DEFAULT_COLLATION_OID);

 if (*txt == '\0' || searchstoplist(&(d->stoplist), txt))
 {
  /* reject as stopword */
  pfree(txt);
  res = palloc0(sizeof(TSLexeme) * 2);
  PG_RETURN_POINTER(res);
 }
 else if (d->accept)
 {
  /* accept */
  res = palloc0(sizeof(TSLexeme) * 2);
  res[0].lexeme = txt;
  PG_RETURN_POINTER(res);
 }
 else
 {
  /* report as unrecognized */
  pfree(txt);
  PG_RETURN_POINTER(NULL);
 }
}

Messung V0.5 in Prozent
C=93 H=94 G=93

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.17Angebot  (Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-08-08) ¤

*Eine klare Vorstellung vom Zielzustand






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.