Last active
January 27, 2020 18:17
-
-
Save TobiahRex/20d294b9ce220017e3024cf3f152c0ea to your computer and use it in GitHub Desktop.
Dynamic Sentences - Design Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
@function generateRawDataFromSettings | |
receives differently shaped input data from various settings components, | |
containing users choices. | |
@param {FSA} settingsData | |
@return {object} | |
*/ | |
/** | |
* @function generateRawDataFromSettings | |
* receives differently shaped input data from various settings components, | |
* containing users choices. | |
* @param type var Description. | |
* @return type Description. | |
*/ | |
function generateRawDataFromSettings(settingsData) { | |
const sentenceTemplate = { // NOTE: ROUGH draft of essential ideas. will definitely need to be added to as we crystalize feature requirements | |
0: { | |
group: 0, | |
/* NOTE: | |
On a very basic level, language requires these 3 parts to have a standard sentence: Subject, Verb, Object. | |
In english, their order is: S-V-O. | |
In japanese, their order is: S-O-V. | |
English | |
I (S) go to (V) the store (O). | |
Japanese | |
I (S) the store (O) go to (V). | |
But the point is made: these are the key components to creating a sentence. | |
So going off of: https://gallery.io/projects/MCHbtQVoQ2HCZVYI9sluwdkP/files/MCEJu8Y2hyDScbbPzfaOHZq9E2BznVeMetY | |
I think the following mappings makes sense: | |
Subjects (S): | |
[Revenue, MarketCap, Sector, etc...] | |
Verbs (V): | |
[equalTo("is"), greaterThan(">"), lessThan("<"), etc.] | |
Objects (O): | |
[<the users alphaNumeric value (+ units)] | |
*/ | |
subject: '', | |
object: '', | |
verb: '', | |
}, | |
}; | |
const sentenceMapCopy = { ...sentenceTemplate }; | |
switch (settingsData.type) { | |
case 'BACKTEST_SETTINGS': | |
return composeBacktestMap(settingsData.payload, sentenceMapCopy); | |
case 'FILTER_SETTINGS': | |
return composeFiltersMap(settingsData.payload, sentenceMapCopy); | |
break; return {}; | |
} | |
/** | |
* @function composeFiltersMap | |
* takes filter setings from designer tab, and maps values to sentence groups. | |
* @param {object} settings | |
* @param {object} sentenceMap | |
* @return {object} sentenceMap | |
*/ | |
function composeFiltersMap(payload, sentenceMap) { | |
// TODO: map paylod to sentenceMap | |
} | |
/** | |
* @function composeBacktestMap | |
* takes setings from backtest tab, and maps values to sentence groups. | |
* @param {object} settings | |
* @param {object} sentenceMap | |
* @return {object} sentenceMap | |
*/ | |
function composeBacktestMap(payload, sentenceMap) { | |
// TODO: map paylod to sentenceMap | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment