MCPcopy
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / add

Method add

vision/textDetection.js:78–89  ·  view source on GitHub ↗

* Tokenize the given document. * @param {string} filename - key for the storage in redis * @param {string} document - Collection of words to be tokenized * @returns {Promise }

(filename, document)

Source from the content-addressed store, hash-verified

76 * @returns {Promise<void>}
77 */
78 async add(filename, document) {
79 const PUNCTUATION = ['.', ',', ':', ''];
80 const tokenizer = new natural.WordTokenizer();
81 const tokens = tokenizer.tokenize(document);
82 // filter out punctuation, then add all tokens to a redis set.
83 await Promise.all(
84 tokens
85 .filter(token => PUNCTUATION.indexOf(token) === -1)
86 .map(token => this.tokenClient.sAdd(token, filename))
87 );
88 await this.docsClient.set(filename, document);
89 }
90
91 /**
92 * Lookup files that contain a given set of words in redis

Callers 13

makeGrpcRequestFunction · 0.80
updateMethod · 0.80
levelSetFunction · 0.80
scoreboardupdateFunction · 0.80
brickFallFunction · 0.80
addBrickFunction · 0.80
updateProgressFunction · 0.80
scannerFunction · 0.80
revealBoomFunction · 0.80
explodeBrickFunction · 0.80
countItFunction · 0.80
startGameFunction · 0.80

Calls 1

setMethod · 0.80

Tested by

no test coverage detected