CLUSTERING

Use this procedure to cluster a collection of documents. A cluster is a group of documents similar to each other in content.

A clustering result set is composed of document assignments and cluster descriptions:

Cluster output is hierarchical. Only leaf clusters are scored for relevance to documents. Producing more clusters requires more computing time. Indicate the upper limit for generated clusters with the CLUSTER_NUM attribute of the KMEAN_CLUSTERING cluster type (see “Cluster Types” in this chapter).

There are two versions of this procedure: one with a table result set, and one with an in-memory result set.

Clustering is also known as unsupervised classification.

See Also: For more information about clustering and relevant preferences, see Cluster Types in Oracle Text Indexing Elements, as well as the Oracle Text Application Developer’s Guide

Syntax: Table Result Set

ctx_cls.clustering (
 index_name  IN VARCHAR2,
 docid       IN VARCHAR2,
 doctab_name IN VARCHAR2,
 clstab_name IN VARCHAR2,
 pref_name   IN VARCHAR2  DEFAULT NULL
);

index_name

Specify the name of the context index on collection table.

docid

Specify the name of document ID column of the collection table.

doctab_name

Specify the name of document assignment table. This procedure creates the table with the following structure:

doc_assign(
   docid number,
   clusterid number,
   score number
);
Column Description

| — | — |

DOCID Document ID to identify document.
CLUSTERID ID of a leaf cluster associated with this document. If CLUSTERID is -1, then the cluster contains “miscellaneous” documents; for example, documents that cannot be assigned to any other cluster category.
SCORE The associated score between the document and the cluster.

If you require more columns, then create the table before you call this procedure.

clstab_name

Specify the name of the cluster description table. This procedure creates the table with the following structure:

cluster_desc(
  clusterid NUMBER,
  descript VARCHAR2(4000),
  label VARCHAR2(200),
  sze NUMBER,
  quality_score NUMBER,
  parent NUMBER
);
Column Description

| — | — |

CLUSTERID Cluster ID to identify cluster. If CLUSTERID is -1, then the cluster contains “miscellaneous” documents; for example, documents that cannot be assigned to any other cluster category.
DESCRIPT String to describe the cluster.
LABEL A suggested label for the cluster.
SZE This parameter currently has no value.
QUALITY_SCORE The quality score of the cluster. A higher number indicates greater coherence.
PARENT The parent cluster ID. Zero means no parent cluster.

If you require more columns, then create the table before you call this procedure.

pref_name

Specify the name of the preference.

Syntax: In-Memory Result Set

Put the result set into in-memory structures for better performance. Two in-memory tables are defined in CTX_CLS package for document assignment and cluster description respectively.

CTX_CLS.CLUSTERING(
  index_name     IN VARCHAR2,
  docid          IN VARCHAR2,
  dids           IN DOCID_TAB,
  doctab_name    IN OUT NOCOPY DOC_TAB,
  clstab_name    IN OUT NOCOPY CLUSTER_TAB,
  pref_name      IN VARCHAR2  DEFAULT NULL
          );

index_name

Specify the name of context index on the collection table.

docid

Specify the document ID column of the collection table.

dids

Specify the name of the in-memory docid_tab.

TYPE docid_tab IS TABLE OF number INDEX BY BINARY_INTEGER;

doctab_name

Specify name of the document assignment in-memory table. This table is defined as follows:

TYPE doc_rec IS RECORD (
   docid NUMBER,
   clusterid NUMBER,
   score NUMBER
)
TYPE doc_tab IS TABLE OF doc_rec INDEX BY BINARY_INTEGER;
Column Description

| — | — |

DOCID Document ID to identify document.
CLUSTERID ID of a leaf cluster associated with this document. If CLUSTERID is -1, then the cluster contains “miscellaneous” documents; for example, documents that cannot be assigned to any other cluster category.
SCORE The associated score between the document and the cluster.

cls_tab

Specify the name of cluster description in-memory table.

TYPE cluster_rec IS RECORD(
     clusterid NUMBER,
     descript VARCHAR2(4000),
     label VARCHAR2(200),
     sze NUMBER,
     quality_score NUMBER,
     parent NUMBER
);
TYPE cluster_tab IS TABLE OF cluster_rec INDEX BY BINARY_INTEGER;
Column Description

| — | — |

CLUSTERID Cluster ID to identify cluster. If CLUSTERID is -1, then the cluster contains “miscellaneous” documents; for example, documents that cannot be assigned to any other cluster category.
DESCRIPT String to describe the cluster.
LABEL A suggested label for the cluster.
SZE This parameter currently has no value.
QUALITY_SCORE The quality score of the cluster. A higher number indicates greater coherence.
PARENT The parent cluster ID. Zero means no parent cluster.

pref_name

Specify the name of the preference. For cluster types and attributes, see Cluster Types in Oracle Text Indexing Elements.

Example

See Also: The Oracle Text Application Developer’s Guide for an example of using clustering