From 85d8aa0c28a5879c4716ea2b34378dd65b3bab86 Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:16:00 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-nlp2.js | 108 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 test/test-nlp2.js diff --git a/test/test-nlp2.js b/test/test-nlp2.js new file mode 100644 index 0000000..c8956ed --- /dev/null +++ b/test/test-nlp2.js @@ -0,0 +1,108 @@ +/* Dictionaries and keyword classification (efrt) */ +var symbols = "the them there thesis this"; +var packedDict = nlp.pack(symbols); +var lexer = nlp.lexer(packedDict); +print (lexer); +print ('thesis?',lexer.true('thesis')); +var dict = nlp.unpack(packedDict); +print ('thesis?',dict['thesis']) + +var science = [ +"astronomy", +"astrophysics", +"atom", +"beaker", +"biochemistry", +"biology", +"botany", +"Bunsen burner", +"burette", +"cell", +"chemical", +"chemistry", +"climate", +"climatologist", +"control", +"cuvette", +"data", +"datum", +"electricity", +"electrochemist", +"element", +"energy", +"entomology", +"evolution", +"experiment", +"fact", +"flask", +"fossil", +"funnel", +"genetics", +"geology", +"geophysics", +"glassware", +"graduated cylinder", +"gravity", +"herpetology", +"hypothesis", +"ichthyology", +"immunology", +"lab", +"laboratory", +"laws", +"lepidoptery", +"magnetism", +"mass", +"matter", +"measure", +"meteorologist", +"meteorology", +"microbiologist", +"microbiology", +"microscope", +"mineral", +"mineralogy", +"molecule", +"motion", +"observatory", +"observe", +"organism", +"ornithology", +"paleontology", +"particle", +"Petri dish", +"phase", +"physical science", +"physics", +"pipette", +"quantum mechanics", +"radiology", +"research", +"retort", +"scale", +"science", +"scientist", +"seismology", +"telescope", +"temperature", +"test tube", +"theory", +"thermometer", +"tissue", +"variable", +"virologist", +"volcanology", +"volume", +"volumetric flask", +"watch glass", +"weather", +"weigh", +"zoology", +] +var packedScience = nlp.pack(science); +print('packedScience',packedScience.length,science.join(',').length); +var lexer = nlp.lexer(packedScience); +print ('lexer',lexer); +print ('astrophysics?',lexer.true('astrophysics')); +var dict = nlp.unpack(packedScience); +print ('astrophysics?',dict['astrophysics'])