grimzaeye commited on
Commit
de470d6
ยท
verified ยท
1 Parent(s): 9fdce57

Update sentiments.html

Browse files
Files changed (1) hide show
  1. sentiments.html +4 -2
sentiments.html CHANGED
@@ -8,7 +8,8 @@
8
  <script type="module">
9
  // To-Do: transfomers.js ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ค‘ pipeline ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ import ๊ตฌ๋ฌธ์„ ์™„์„ฑํ•˜์‹ญ์‹œ์˜ค.
10
  // ํžŒํŠธ: import {}
11
-
 
12
  // Make it available globally
13
  window.pipeline = pipeline;
14
  </script>
@@ -115,7 +116,7 @@
115
  async function initializeModel() {
116
  // pipeline ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์„ฑ๋ถ„์„์— ์‚ฌ์šฉํ•  Xenova/distilbert-base-uncased-finetuned-sst-2-english ๋ชจ๋ธ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜์—ฌ sentimentAnalysis์— ์ €์žฅํ•˜์‹ญ์‹œ์˜ค
117
  // ํžŒํŠธ: sentimentAnalysis = await pipeline
118
-
119
  }
120
 
121
  async function analyzeSentiment() {
@@ -132,6 +133,7 @@
132
  // ์œ„์—์„œ ์ƒ์„ฑํ•œ ๊ฐ์„ฑ๋ถ„์„ ๋ชจ๋ธ ๊ฐ์ฒด์— sentimentText1๊ณผ sentimentText2๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ๊ฐ์ƒ๋ถ„์„์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ๊ทธ ๊ฒฐ๊ณผ๋ฅผ result์— ์ €์ •ํ•˜์‹ญ์‹œ์˜ค.
133
  // ํžŒํŠธ : cont result =
134
 
 
135
 
136
  document.getElementById("outputArea2").innerText = JSON.stringify(result, null, 2);
137
  }
 
8
  <script type="module">
9
  // To-Do: transfomers.js ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ค‘ pipeline ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•œ import ๊ตฌ๋ฌธ์„ ์™„์„ฑํ•˜์‹ญ์‹œ์˜ค.
10
  // ํžŒํŠธ: import {}
11
+ import {pipeline} from 'https://cdn.jsdelivr.net/npm/@xenova/transformers@'2.5.4';
12
+ window.pipeline = pipeline;
13
  // Make it available globally
14
  window.pipeline = pipeline;
15
  </script>
 
116
  async function initializeModel() {
117
  // pipeline ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์„ฑ๋ถ„์„์— ์‚ฌ์šฉํ•  Xenova/distilbert-base-uncased-finetuned-sst-2-english ๋ชจ๋ธ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜์—ฌ sentimentAnalysis์— ์ €์žฅํ•˜์‹ญ์‹œ์˜ค
118
  // ํžŒํŠธ: sentimentAnalysis = await pipeline
119
+ sentimentAnalysis = await pipeline('sentiment-analysis');
120
  }
121
 
122
  async function analyzeSentiment() {
 
133
  // ์œ„์—์„œ ์ƒ์„ฑํ•œ ๊ฐ์„ฑ๋ถ„์„ ๋ชจ๋ธ ๊ฐ์ฒด์— sentimentText1๊ณผ sentimentText2๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ๊ฐ์ƒ๋ถ„์„์„ ์ˆ˜ํ–‰ํ•˜๊ณ  ๊ทธ ๊ฒฐ๊ณผ๋ฅผ result์— ์ €์ •ํ•˜์‹ญ์‹œ์˜ค.
134
  // ํžŒํŠธ : cont result =
135
 
136
+ const result = await sentimentAnalysis([textFieldValue1, textFieldValue2]);
137
 
138
  document.getElementById("outputArea2").innerText = JSON.stringify(result, null, 2);
139
  }