Harium / suneidesis

A project to represent knowledge
MIT License
2 stars 1 forks source link

[Core] Add serialization / deserialization to KnowledgeDatabase #65

Closed yuripourre closed 3 years ago

yuripourre commented 4 years ago

My suggestion is to use JSON so humans can also populate the database.

Now that the id is a String we do not should care about updating indexes to keep everything sorted.

Obviously use an external serializer and a helper class. Do not pollute pojos with annotations.

General approach (words dictionary may be different) A concept with id = 1 and name.id = nameId1.

"knowledge base": {
  "typeId0": {"name":"type name word"},
  "nameId1": {"name": "name word", "typeId":"typeId0"},
  "1": {"nameId":"nameId1", "typeId":"typeId1", "customAttr1Id":"attrId1", "customAttr2Id":"attrId2"}
}

Persist as depth first search and all words are leaves.

Ideally, the best order would be;

yuripourre commented 3 years ago

Remember to only persist the first level (forget about nested attributes). And all (children) attributes should be persisted as Id only.

Knowledge Base should index all concepts using Id.

Suggestion: words, types, concepts. They can be persisted in knowledge base separately.

yuripourre commented 3 years ago

We can try this one: http://jsoniter.com/

Json libraries comparison: https://github.com/fabienrenaud/java-json-benchmark

yuripourre commented 3 years ago

Do not forget to add a test to serialize and deserialize the same knowledge base.

yuripourre commented 3 years ago

Also, add tests to handling databases of words since it will be a common use case.