Skip to content

Commit

Permalink
add more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Apr 7, 2020
1 parent f18b5d9 commit b654b92
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dist/src/background.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/src/background.js.map

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions dist/src/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ function callBackgroundWithIntent(intent) {
// open connection to runtime (background.ts)
const port = chrome.runtime.connect({ name: "intentStatus" });
port.postMessage({ intent: intent, url: window.location.href });
displayStatus("connecting...", 3000, REFLECT_INFO);
port.onMessage.addListener((msg) => {
switch (msg.status) {
case "ok":
Expand All @@ -99,10 +98,6 @@ function callBackgroundWithIntent(intent) {
// clear input
$("#textbox").val("");
break;
case "timeout":
// display message
displayStatus("couldn't reach server, try again later.", 3000, REFLECT_ERR);
break;
}
// close connection
port.disconnect();
Expand Down
2 changes: 1 addition & 1 deletion dist/src/nn.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/src/nn.js.map

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ chrome.runtime.onConnect.addListener((port) => {
const url: string = msg.url;

const valid: boolean = await model.predict(intent);
console.log(valid)

if (valid) {
// add whitelist period for site
Expand Down
8 changes: 0 additions & 8 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ function callBackgroundWithIntent(intent: string): void {
// open connection to runtime (background.ts)
const port = chrome.runtime.connect({name: "intentStatus"});
port.postMessage({intent: intent, url: window.location.href});

displayStatus("connecting...", 3000, REFLECT_INFO);

port.onMessage.addListener((msg) => {
switch (msg.status) {
case "ok":
Expand All @@ -122,11 +119,6 @@ function callBackgroundWithIntent(intent: string): void {
// clear input
$("#textbox").val("");
break;

case "timeout":
// display message
displayStatus("couldn't reach server, try again later.", 3000, REFLECT_ERR);
break;
}

// close connection
Expand Down
5 changes: 5 additions & 0 deletions src/nn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ export class IntentClassifier {

// predict
return (this.model.predict(inputTensor) as tf.Tensor).data().then(predictions => {

// garbage collect finished tensor to prevent mem leak
tf.dispose(inputTensor)

// threshold net output
const confidence: number = predictions[0];
if (confidence > threshold) {
return true;
Expand Down

0 comments on commit b654b92

Please sign in to comment.