Memory file format

When the application closes, the content of the memory is saved into a text file with name "memory.txt" inside the folder "aseryla/data".

So when the application starts anew all the learned knowledge is loaded and available again.


The format of this file was designed to load all the knowledge in an optimal way;

and for future purposes of accessing directly the information from disk without the needed of loading the entire file into the RAM memory.

IMPORTANT: for performance reasons, no file format is checked. The system will not start if the file contains any error. So it is highly recommended not modify this file.


Header

First line: AMF [#lexicons] [#frames]

Where:

   - AMF (Aseryla Memory File) is the mark to identify the file, and avoid errors if an invalid memory file is provided.

     Remind that in previous versions the memory file was in Internal Language Code format.

   - [#lexicons] is the number of lexicon entries to load.

   - [#franes] is the number of frames the memory has.

   e.g: cat 100 cat,cats,Cat,Cats


Lexicon / Dictionary

For every inserted concept, there will be a line (and a total of #lexicons) with the format: [lemma] [bbb] [dictionary]

Where:

   - [lemma] the concept

   - [bbb] is a three position 1/0 array, where the first value correspond with Noun, the second with Verb, and the third with Adjective.

   - [dictionary] comma separated list with all the related words (dictionary)

   e.g: cat 100 cat,cats,Cat,Cats

   NOTE: The lexicon reference is assumed by the number of line.


Sets

Each concept has associated a list of referenced relations, so there will be a line (and a total of #lexicons) with the format:

Slash separated list with the elements of each relation list type, that are:

   Parents, Features, Attributes, Skills, Affected Actions, Negative Parents, Negative Features, Negative Attributes, Negative Skills). Remind, the affected property can not be negative.

Each element of the list contains a space separated list with the lexicon references associated to that list.

   e.g.: 11 22 33/44////55///66 77 (it has 3 parents, 1 feature, 1 negative parent and 2 negative skills)


Frame

Every inserted concept with type Noun, it has associated a frame:

There will be 5 lines (1 for each relation list: Parent, Feature, Attribute, Skill, Affected Actions) for each frame; each line it is a whitespace separated list with the elements of the relation.

Where the elements are [lexicon reference] [tendency] [source]

If the element is an attribute it also has [atrlink] [numbers] (slash separated list of numbers or ranges)

In case of the skill list also has [the list of interactions] (slash separated list with [lexicon reference]*[tnd]&[src] of each interaction)

Empty line means the frame has no relations in that property list

   e.g:

   20 3 64 (1 parent with tendency=3, source=64)

   21 2 64 42 -1 1 (2 features, 1 with negative tendency)

   22 10 64 19 1/4-6 (1 attribute with associated numbers)

   17 3 64 15*1&2/14*-11&11/12*1&1 18 1 1 / (2 skills, the first one with 3 interactions, the second without them)

   16 1 64 18 1 64 (2 affected)

   NOTE: The frame reference is assumed by the position in the file, in other words, the first 5 lines will be the frame 1, the next 5 corresponds with the frame 2, and so on.


Example:

Assuming the memory has following knowledge:

WORD N Cat cat

WORD N cats cat

WORD N pet pet

WORD N paw paw

WORD J nice nice

WORD J black black

WORD J metallic metallic

WORD V jumped jump

WORD V ate eat

WORD N eat eat

WORD N stone stone

WORD N fence fence

cat ISA pet / 1 1

cat IS nice / 1 1

cat IS black / 1 1

cat IS metallic / -1 1

cat HAVE paw 4 1 1

cat CAN jump stone*1&1 2 2

cat CAN jump fence*2&2 2 2

cat CANBE jump / 1 1

stone CAN eat / -1 1

The output file will be:

AMF 23 11

person 100 He,I,Person,She,They,We,You,he,i,person,she,they,we,you

location 100 Location,location

organization 100 Organization,organization

be 010 am,are,be,been,is,was,were

can 010 can,could

do 010 did,do,does,done

have 010 had,has,have

get 010 get,got

it 000 It,it

any 000 Any,any

some 000 Some,some

cat 100 Cat,cat,cats

pet 100 pet

paw 100 paw

nice 001 nice

black 001 black

metallic 001 metallic

jump 010 jump,jumped

eat 110 ate,eat

stone 100 stone

fence 100 fence

cat%paw 100 cat%paw * this is the line number 23 = #lexicon

//////// * set of person

//////// * set of location

////////

////////

////////

////////

////////

////////

////////

////////

////////

////////

12 ////////

22 ////////

/12 ///////

/12 ///////

//////12 //

///12 /12 ////

////////20

////////

////////

//12 ////// * set of cat%paw (line 46 = #lexicon * 2)

* frame of person (fisrt line after #lexicon * 2 + header)





* frame of location





* frame of organization





13 1 1 * frame of cat (1 parent)

15 1 1 16 1 1 17 -1 1 * 3 features

22 1 1 14 4 * 1 attribute

18 4 2 20*1&1/21*2&2 * 1 skill with 2 interaction

18 1 1 * 1 affected action



















19 -1 1 /







14 1 1




(last line after #frames* 5 + #lexicon * 2 + header)





Memory into Internal Language format


For safety or export data actions, the entire knowledge stored in the memory can also be saved in Internal Language format.


   - Every entry in the dictionary would be transformed into WORD codes .


   - Every assertion inserted in any list of the frames would be transformed into RELATION codes .


Example:

Assuming the memory only contains the example data described here, would left the following scenario:


Into the file will insert the following internal language codes:


WORD J nice nice

WORD N run run

WORD V runs run

run IS nice / -1 3

Notes:

   - The WORD codes are also fulfilled with information extracted from the lexicon.

   - The information stored in the sets, are no relevant for this tasks, because the sets are populated trough the frame relations. Check the second learning flow.



Source code


Memory::load() // load the file content into the memory structures

Memory::loadIlcs()

Memory::init() // minimal required by the system


   class Memory::DicData

   class Memory::LexData

   class Memory::FrameData

   class Memory::SetData

      Memory::FrameData.upLoad()

      Memory::SetData.upLoad()


Memory::save() // save the memory content into the files

Memory::saveIlcs()

  Memory::DicData.downLoad()

  Memory::LexData.downLoad()

  Memory::FrameData.downLoad()

      Memory::FrameData.downLoadILC()

  Memory::SetData.downLoad()