109 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			109 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 
								 | 
							
								/* 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'])
							 |