LatentSemanticMapping.h Reference

Declared in
LatentSemanticMapping.h

Overview

Semantic Mapping This framework classifies texts based on latent semantic information.

Included Headers

  • <CoreFoundation/CoreFoundation.h>

  • <CoreServices/CoreServices.h>

  • <Carbon/Carbon.h>

  • <stdio.h>

  • <stdint.h>

Functions

See the Overview for header-level documentation.

LSMMapAddCategory

LSMCategory LSMMapAddCategory(
   LSMMapRef mapref);
Discussion

Adds another category and returns its category identifier.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapAddText

OSStatus LSMMapAddText(
   LSMMapRef mapref,
   LSMTextRef textref,
   LSMCategory category);
Discussion

Adds a training text to the given category. The textref is no longer needed after this call.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapAddTextWithWeight

OSStatus LSMMapAddTextWithWeight(
   LSMMapRef mapref,
   LSMTextRef textref,
   LSMCategory category,
   float weight);
Discussion

Adds a training text to the given category with a weight different from 1. The weight may be negative, but global counts will be pinned to 0. The textref is no longer needed after this call.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapApplyClusters

OSStatus LSMMapApplyClusters(
   LSMMapRef mapref,
   CFArrayRef clusters);
Discussion

Group categories or words (tokens) into the specified sets of clusters.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapCompile

OSStatus LSMMapCompile(
   LSMMapRef mapref);
Discussion

Compiles the map into executable form and puts it into mapping mode, preparing it for the classification of texts. This function is computationally expensive.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapCreate

LSMMapRef LSMMapCreate(
   CFAllocatorRef alloc,
   CFOptionFlags flags);
Discussion

Creates a new LSM map. Call CFRelease to dispose.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapCreateClusters

CFArrayRef LSMMapCreateClusters(
   CFAllocatorRef alloc,
   LSMMapRef mapref,
   CFArrayRef subset,
   CFIndex numClusters,
   CFOptionFlags flags);
Discussion

Compute a set of clusters grouping similar categories or words. If subset is non-NULL, only perform clustering on the categories or words listed.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapCreateFromURL

LSMMapRef LSMMapCreateFromURL(
   CFAllocatorRef alloc,
   CFURLRef file,
   CFOptionFlags flags);
Discussion

Loads a map from a given file.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapGetCategoryCount

CFIndex LSMMapGetCategoryCount(
   LSMMapRef mapref);
Discussion

Returns the number of categories in the map.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapGetProperties

CFDictionaryRef LSMMapGetProperties(
   LSMMapRef mapref);
Discussion

Get a dictionary of properties for the map. LSM retains ownership of this dictionary, do not release it.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapGetTypeID

CFTypeID LSMMapGetTypeID(
   void);
Discussion

Returns the Core Foundation type identifier for LSM maps.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapSetProperties

void LSMMapSetProperties(
   LSMMapRef mapref,
   CFDictionaryRef properties);
Discussion

Set a dictionary of properties for the map. LSM makes its own copy of the properties, there's no need to retain them past this call.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapSetStopWords

OSStatus LSMMapSetStopWords(
   LSMMapRef mapref,
   LSMTextRef textref);
Discussion

The specified words will be omitted from all classification efforts. Needs to be called before any other texts are created. The textref is no longer needed after this call.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapStartTraining

OSStatus LSMMapStartTraining(
   LSMMapRef mapref);
Discussion

Puts the map into training mode, preparing it for the addition of more categories and/or texts. This function will be somewhat expensive, as it requires substantial data structure reorganization.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapWriteToStream

OSStatus LSMMapWriteToStream(
   LSMMapRef mapref,
   LSMTextRef textref,
   CFWriteStreamRef stream,
   CFOptionFlags options);
Discussion

Writes information about a map and/or text to a stream in text form

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapWriteToURL

OSStatus LSMMapWriteToURL(
   LSMMapRef mapref,
   CFURLRef file,
   CFOptionFlags flags);
Discussion

Compiles the map if necessary and then stores it into the given file.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultCopyToken

CFDataRef LSMResultCopyToken(
   LSMResultRef mapref,
   CFIndex n);
Discussion

Returns the token for the n-th best (zero based) result.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultCopyTokenCluster

CFArrayRef LSMResultCopyTokenCluster(
   LSMResultRef mapref,
   CFIndex n);
Discussion

Returns the cluster of tokens for the n-th best (zero based) result.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultCopyWord

CFStringRef LSMResultCopyWord(
   LSMResultRef result,
   CFIndex n);
Discussion

Returns the word for the n-th best (zero based) result.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultCopyWordCluster

CFArrayRef LSMResultCopyWordCluster(
   LSMResultRef result,
   CFIndex n);
Discussion

Returns the cluster of words for the n-th best (zero based) result.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultCreate

LSMResultRef LSMResultCreate(
   CFAllocatorRef alloc,
   LSMMapRef mapref,
   LSMTextRef textref,
   CFIndex numResults,
   CFOptionFlags flags);
Discussion

Returns, in decreasing order of likelihood, the categories or words that best match when a text is mapped into a map.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultGetCategory

LSMCategory LSMResultGetCategory(
   LSMResultRef result,
   CFIndex n);
Discussion

Returns the category of the n-th best (zero based) result.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultGetCount

CFIndex LSMResultGetCount(
   LSMResultRef result);
Discussion

Returns the number of results.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultGetScore

float LSMResultGetScore(
   LSMResultRef result,
   CFIndex n);
Discussion

Returns the likelihood of the n-th best (zero based) result. A nan score often indicates that the category does not contain any token.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResultGetTypeID

CFTypeID LSMResultGetTypeID(
   void);
Discussion

Returns the Core Foundation type identifier for LSM results.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMTextAddToken

OSStatus LSMTextAddToken(
   LSMTextRef textref,
   CFDataRef token);
Discussion

Adds an arbitrary binary token to the text. The order of tokens is significant if the map uses pairs or triplets, and the count of tokens is always significant.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMTextAddWord

OSStatus LSMTextAddWord(
   LSMTextRef textref,
   CFStringRef word);
Discussion

Adds a word to the text. The order of words is significant if the map uses pairs or triplets, and the count of words is always significant.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMTextAddWords

OSStatus LSMTextAddWords(
   LSMTextRef textref,
   CFStringRef words,
   CFLocaleRef locale,
   CFOptionFlags flags);
Discussion

Breaks a string into words using the locale provided and adds the words to the text.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMTextCreate

LSMTextRef LSMTextCreate(
   CFAllocatorRef alloc,
   LSMMapRef mapref);
Discussion

Creates a new text.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMTextGetTypeID

CFTypeID LSMTextGetTypeID(
   void);
Discussion

Returns the Core Foundation type identifier for LSM texts.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

Data Types

See the Overview for header-level documentation.

LSMCategory

typedef uint32_t LSMCategory;
Discussion

An integral type representing a category.

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMMapRef

typedef struct __LSMMap * LSMMapRef;
Discussion

An opaque Core Foundation type representing an LSM map (mutable).

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

LSMResult

typedef struct __LSMResult * LSMResultRef;
Discussion

An opaque Core Foundation type representing the result of a lookup (immutable).

Availability
  • Available in OS X v10.5 and later.
See Also
Declared In
LatentSemanticMapping.h

LSMResultRef

typedef struct __LSMResult * LSMResultRef;
Discussion

An opaque Core Foundation type representing the result of a lookup (immutable).

Availability
  • Available in OS X v10.5 and later.
See Also
Declared In
LatentSemanticMapping.h

LSMTextRef

typedef struct __LSMText * LSMTextRef;
Discussion

An opaque Core Foundation type representing an input text (mutable).

Availability
  • Available in OS X v10.5 and later.
Declared In
LatentSemanticMapping.h

Constants

See the Overview for header-level documentation.

Defines

   
#define kLSMAlgorithmDense CFSTR("LSMAlgorithmDense")
#define kLSMAlgorithmKey CFSTR("LSMAlgorithm")
#define kLSMAlgorithmSparse CFSTR("LSMAlgorithmSparse")
#define kLSMDimensionKey CFSTR("LSMDimension")
#define kLSMIterationsKey CFSTR("LSMIterations")
#define kLSMPrecisionDouble CFSTR("LSMPrecisionDouble")
#define kLSMPrecisionFloat CFSTR("LSMPrecisionFloat")
#define kLSMPrecisionKey CFSTR("LSMPrecision")
#define kLSMSweepAgeKey CFSTR("LSMSweepAge")
#define kLSMSweepCutoffKey CFSTR("LSMSweepCutoff")
Constants
kLSMAlgorithmDense

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMAlgorithmKey

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMAlgorithmSparse

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMDimensionKey

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMIterationsKey

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMPrecisionDouble

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMPrecisionFloat

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMPrecisionKey

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMSweepAgeKey

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMSweepCutoffKey

A CFDictionary of arbitrary properties may be associated. with an LSM map. The following keys currently are interpreted by LSM, and all other keys starting with LSM... are reserved.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

See Also

Error codes

enum {
   kLSMMapOutOfState = -6640,
   kLSMMapNoSuchCategory = -6641,
   kLSMMapWriteError = -6642,
   kLSMMapBadPath = -6643,
   kLSMMapBadCluster = -6644,
   kLSMMapOverflow = -6645
};
Constants
kLSMMapOutOfState

This call cannot be issued in this map state

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapNoSuchCategory

Invalid category specified

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapWriteError

An error occurred writing the map

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapBadPath

The URL you specified does not exist

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapBadCluster

The clusters you specified are invalid

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapOverflow

Cannot add more data to map

Available in OS X v10.7 and later.

Declared in LatentSemanticMapping.h.

Discussion

Errors returned from LSM routines

Map Flags

enum {
   kLSMMapPairs = 1,
   kLSMMapTriplets = 2,
   kLSMMapHashText = 256
};
Constants
kLSMMapPairs

Use pairs in addition to single words.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapTriplets

Use triplets and pairs in addition to single words.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapHashText

Transform the text so it's not trivially human readable. Disables creation of language models.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

Discussion

Options that can be specified for LSMMapCreate. These options can improve mapping accuracy, at a potentially significant increase in memory use.

Parsing Flags

enum {
   kLSMTextPreserveCase = 1,
   kLSMTextPreserveAcronyms = 2,
   kLSMTextApplySpamHeuristics = 4
};
Constants
kLSMTextPreserveAcronyms

Don't map all uppercase words to lowercase.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMTextPreserveCase

Don't change any words to lowercase.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMTextApplySpamHeuristics

Try to find words in hostile text.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

Discussion

Options you can specify for LSMTextAddWords.

Result Flags

enum {
   kLSMResultBestWords = 1,
};
Constants
kLSMResultBestWords

Find the words, rather than categories, that best match.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

Discussion

Options for LSMResultCreate.

Storage Flags

enum {
   kLSMMapDiscardCounts = 1,
   kLSMMapLoadMutable = 2,
};
Constants
kLSMMapDiscardCounts

Don't keep counts. If specified on loading, the map needs to be reloaded without this option before calling LSMStartTraining. If specified on storing, the stored map can't be retrained at all. This option can save a lot of memory and/or disk space.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapLoadMutable

Load map as mutable in training state.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

kLSMMapHashText

(Defined above) If specified on storing, will hash the map if it hasn't been hashed yet.

Available in OS X v10.5 and later.

Declared in LatentSemanticMapping.h.

Discussion

Options for LSMMap{CreateFrom,WriteTo}URL.