Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Text search

node v8.17.0
version: master
endpointsharetweet
var qm = require('qminer'); // create the base object with the desired schema var base = new qm.Base({ mode: 'createClean', schema: [{ name: 'tweets', fields: [{ name: 'text', type: 'string' }] }] }); // create the feature space object var ftr = new qm.FeatureSpace(base, { type: "text", source: "tweets", field: "text" }); // push the data let tweetStore = base.store('tweets'); tweetStore.push({text: "This pen is green."}); tweetStore.push({text: "This pen is yellow."}); tweetStore.push({text: "This pen is blue."}); tweetStore.push({text: "This marker is yellow."}); // update the feature space with the data ftr.updateRecords(tweetStore.allRecords);
let query = tweetStore.newRecord({"text": "The pen and the marker are green."}) let vector = ftr.extractSparseVector(query);
let matrix = ftr.extractSparseMatrix(tweetStore.allRecords); let sim = matrix.multiplyT(vector);
sim.print()
Loading…

no comments

    sign in to comment