TraumatizedTuna / ProGrammarJS

The best way to enjoy messages that do not convey actual information
MIT License
0 stars 1 forks source link

Save words and rules to some sort of database #3

Open TraumatizedTuna opened 3 years ago

MrYakobo commented 3 years ago

as of now, the data is defined directly in the source files generate.js and clauses.js. it's not necessarily a problem if the data is provided solely from official sources. pokemon showdown for example keeps all their data in their sources.

though this becomes a problem if this is to be crowd-funded with data, as implied by #1 and #2. So some type of format should be considered.

i propose some super-light-weight text based system. right now i found both a prototype-based format in clauses.js and var patterns = [[Subject, Predicate],[Subject, Predicate, Adverbial, null]] in generate.js. by assuming the latter, we can encode the following...

[Predicate],
[Predicate, Adverbial, null]
[Subject, Predicate, Adverbial, null],

...using the strings P, PAN and SPAN. this could be stored in a text file clauses.txt:

P # comment
PAN # here
SPAN # also

of course, this requires unique identifiers for all clauses; but the format makes authoring rules a very fast job. having comments in this format seems reasonable, so that an example sentence can be put next to a clause.

for words, we have more of a tabular layout. we could use csv here or simply json. i think json fits better, as we can add new properties and avoid affecting old records.

new Noun({ base: 'star' });
new Noun({ base: 'Donald Trump', proper: true });
new Noun({ base: 'index', plural: 'indices'});

as of now, JSON.stringify(words) simply works. adding new words could be done in a web-based interface or by editing the json file directly.

{
  "adjectives": [],
  "nouns": [
    {
      "base": "ape",
      "countable": true,
      "proper": false,
      "gender": 0
    },
    {
      "base": "Donald Trump",
      "countable": true,
      "proper": true,
      "gender": 0
    },
    {
      "base": "index",
      "countable": true,
      "proper": false,
      "gender": 0
    }
  ],
  "verbs": [
    {
      "base": "drown",
      "acceptsObj": true,
      "needsObj": false
    },
  ],
  "adverbs": [
    {
      "base": "typically"
    },
  ]
}

of course, when reading the files we should call the respective constructor on each record.