NTPronunciationDictionary Class Reference

Inherits from NSObject
Conforms to NSCopying
Declared in NTPronunciationDictionary.h
NTPronunciationDictionary.m

Overview

Represents a phonetic dictionary. Contains words with corresponding phones. One word can have multiple phones. Words and phones are stored in upper case.

Other Methods

  name

The name identifying this dictionary.

@property (nonatomic, strong) NSString *name

Discussion

The name identifying this dictionary.

Declared In

NTPronunciationDictionary.h

  entries

The list of words with the corresponding phones.

@property (nonatomic, strong, readonly) NSDictionary *entries

Discussion

The list of words with the corresponding phones.

Example:

@{ @“word” : @[ @“phone a”, @“phone b”, @“phone c”], @“word b” : @[ @“phone ba”, @“phone bb”,] }

Declared In

NTPronunciationDictionary.h

  allWords

A list of words contained in the entries. (entries.allKeys)

@property (nonatomic, strong, readonly) NSArray *allWords

Discussion

A list of words contained in the entries. (entries.allKeys)

Declared In

NTPronunciationDictionary.h

– init

Creates a phonetic dictionary without entries.

- (instancetype)init

Return Value

Empty Dictionary

Discussion

Creates a phonetic dictionary without entries.

Declared In

NTPronunciationDictionary.h

– initWithName:

Creates a phonetic dictionary with a given name

- (instancetype)initWithName:(NSString *)name

Parameters

name

Name

Return Value

Dictionary

Discussion

Creates a phonetic dictionary with a given name

Declared In

NTPronunciationDictionary.h

– initWithName:fileAtPath:

Creates a phonetic dictionary with words loaded from a file.

- (instancetype)initWithName:(NSString *)name fileAtPath:(NSString *)path

Parameters

name

Name

path

The path to the file with the words to load.

Return Value

Dictionary

Discussion

Creates a phonetic dictionary with words loaded from a file.

File format:

[word]\t[phones] [wordb]\t[phonesb] wordb\t[phonesb2]

Declared In

NTPronunciationDictionary.h

– initWithName:dictionaryString:

Creates a phonetic dictionary with words parsed from a string.

- (instancetype)initWithName:(NSString *)name dictionaryString:(NSString *)dictionaryString

Parameters

name

Name

dictionaryString

String to parse words from

Return Value

Dictionary

Discussion

Creates a phonetic dictionary with words parsed from a string.

String format:

[word]\t[phones] [wordb]\t[phonesb] wordb\t[phones2]

Declared In

NTPronunciationDictionary.h

– initWithName:words:

Creates a dictionary with the given words.

- (instancetype)initWithName:(NSString *)name words:(NSDictionary *)words

Parameters

name

Name

words

Words/Phones.

NSDictionary Format:

@{ @“word” : @[ @“phone a”, @“phone b”, @“phone c”], @“word b” : @[ @“phone ba”, @“phone bb”,] }

Return Value

Dictionary

Discussion

Creates a dictionary with the given words.

Declared In

NTPronunciationDictionary.h

– addWord:phones:

Add the phones for the given word. Existing phones for the same words won’t be deleted.

- (void)addWord:(NSString *)word phones:(NSString *)phones

Parameters

word

Word (e.g. “Flight”)

phones

Phones (e.g. “F L AY T”)

Discussion

Add the phones for the given word. Existing phones for the same words won’t be deleted.

Declared In

NTPronunciationDictionary.h

– addWord:listOfPhones:

Add multiple phones for the given word. Existing phones for the same words won’t be deleted.

- (void)addWord:(NSString *)word listOfPhones:(NSArray *)listOfPhones

Parameters

word

Word (e.g. “Flight”)

listOfPhones

Array (e.g. [“F L AY T”, “F L EY T”])

Discussion

Add multiple phones for the given word. Existing phones for the same words won’t be deleted.

Declared In

NTPronunciationDictionary.h

– addWords:

Adds words and phones from dictionary.

- (void)addWords:(NSDictionary *)words

Parameters

words

dictionary

Discussion

Adds words and phones from dictionary.

NSDictionary Format:

@{ @“word” : @[ @“phone a”, @“phone b”, @“phone c”], @“word b” : @[ @“phone ba”, @“phone bb”,] }

Declared In

NTPronunciationDictionary.h

– removeWord:

Removes the given word with all corresponding phones.

- (void)removeWord:(NSString *)word

Parameters

word

The word to delete.

Discussion

Removes the given word with all corresponding phones.

Declared In

NTPronunciationDictionary.h

– removePhones:ofWord:

Remove the given phones from the given word. If there are no more phones for word, it will be removed.

- (void)removePhones:(NSString *)phones ofWord:(NSString *)word

Parameters

phones

phones

word

word

Discussion

Remove the given phones from the given word. If there are no more phones for word, it will be removed.

Declared In

NTPronunciationDictionary.h

– addWordsFromDictionary:

Adds all word from a dictionary.

- (void)addWordsFromDictionary:(NTPronunciationDictionary *)dictionary

Parameters

dictionary

Words/Phones.

NSDictionary Format:

@{ @“word” : @[ @“phone a”, @“phone b”, @“phone c”], @“word b” : @[ @“phone ba”, @“phone bb”,] }

Discussion

Adds all word from a dictionary.

Declared In

NTPronunciationDictionary.h

– parseWordsFromDictionaryString:

Add parsed words from dictionary string.

- (void)parseWordsFromDictionaryString:(NSString *)dictionaryString

Parameters

dictionaryString

String to parse words from

Discussion

Add parsed words from dictionary string.

String format:

[word]\t[phones] [wordb]\t[phonesb] wordb\t[phones2]

Declared In

NTPronunciationDictionary.h

– createDictionaryString

Creates a dictionary string with the entries.

- (NSString *)createDictionaryString

Return Value

dictionary string

Discussion

Creates a dictionary string with the entries.

String format:

[word]\t[phones] [wordb]\t[phonesb] wordb\t[phones2]

Declared In

NTPronunciationDictionary.h

– loadWordsFromFileAtPath:

Add words from a phonetic dictionary file.

- (void)loadWordsFromFileAtPath:(NSString *)path

Parameters

path

The path to the file with the words to load.

Discussion

Add words from a phonetic dictionary file.

File format:

[word]\t[phones] [wordb]\t[phonesb] wordb\t[phonesb2]

Declared In

NTPronunciationDictionary.h

– writeToFileAtPath:

Writes entries to a file.

- (void)writeToFileAtPath:(NSString *)path

Parameters

path

Path to write to.

Discussion

Writes entries to a file.

File format:

[word]\t[phones] [wordb]\t[phonesb] wordb\t[phonesb2]

Declared In

NTPronunciationDictionary.h

– phonesForWord:

Returns all phones for the given word.

- (NSArray *)phonesForWord:(NSString *)word

Parameters

word

word

Return Value

array with phones. (e.g. [@“F L AY T”, @“F L EY T”])

Discussion

Returns all phones for the given word.

Declared In

NTPronunciationDictionary.h

Other Methods

– copyWithZone:

- (id)copyWithZone:(NSZone *)zone

Extension Methods

  internalPhones

@property (nonatomic, strong) NSMutableDictionary *internalPhones