program 2/lib/frontend.js
/**
  * Takes the knowledgebase and the hashmap of {symbols:numbers}
  * @returns the kb array with each token replaced by a number specified in the symbolMp hash
  */
Takes the knowledgebase and the hashmap of {symbols:numbers}
@returns the kb array with each token replaced by a number specified in the symbolMp hash
Takes the knowledgebase and the hashmap of { symbols : numbers } @returns the kb array with each token replaced by a number specified in the symbolMp hash
function convertToSymbols( kb, symbolMap , flatten) {
    return kb.map( function( symbols ) {
      return symbols.trim().split(' ').reduce( function( accumulator, symbol ) {
        var _atom = atom(symbol); 
        accumulator.push( symbol.replace( _atom, symbolMap[_atom] ))
        return accumulator;
      },[]).join(' ');
    }); 
  }
function convertToSymbols ( kb , symbolMap , flatten ) { return kb . map ( function ( symbols ) { return symbols . trim ( ) . split ( ' ' ) . reduce ( function ( accumulator , symbol ) { var _atom = atom ( symbol ) ; accumulator . push ( symbol . replace ( _atom , symbolMap [ _atom ] ) ) return accumulator ; } , [ ] ) . join ( ' ' ) ; } ) ; }
Takes the knowledgebase and the hashmap of {symbols:numbers}
 @returns the kb array with each token replaced by a number specified in the symbolMp hash
Takes the knowledgebase and the hashmap of { symbols : numbers } @returns the kb array with each token replaced by a number specified in the symbolMp hash
// for each row 'symbols' pair or triple in the kb,  // trim off any outerwhitespace,  // split the pair/triple/etc on the inner whitespace // each symbol will be of the form -A or A // get the pure atom, but ignoring the -()         // push into the initializer the token replacement from the symbolMap // here's the accumulator // return the array flattened with a ' ' as separators // since we're still within the map(), this new string will replace the older one // we could flatten here too ('\n'), but let the caller figure that out