StringStore

Map strings to and from integer IDs.

StringStore.__init__

Create the StringStore.

NameTypeDescription
strings-A sequence of unicode strings to add to the store.
returnStringStoreThe newly constructed object.

StringStore.__len__

Get the number of strings in the store.

NameTypeDescription
returnintThe number of strings in the store.

StringStore.__getitem__

Retrieve a string from a given integer ID, or vice versa.

NameTypeDescription
string_or_idbytes / unicode / intThe value to encode.
returnunicode / intThe value to retrieved.

StringStore.__contains__

Check whether a string is in the store.

NameTypeDescription
stringunicodeThe string to check.
returnboolWhether the store contains the string.

StringStore.__iter__

Iterate over the strings in the store, in order.

NameTypeDescription
yieldunicodeA string in the store.

StringStore.dump

Save the strings to a JSON file.

NameTypeDescription
filebufferThe file to save the strings.
returnNone-

StringStore.load

Load the strings from a JSON file.

NameTypeDescription
filebufferThe file from which to load the strings.
returnNone-