Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
		
							parent
							
								
									6ea3ae7b82
								
							
						
					
					
						commit
						85d8aa0c28
					
				
							
								
								
									
										108
									
								
								test/test-nlp2.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								test/test-nlp2.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -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'])
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user