Jadson commited on
Commit
29ec487
·
verified ·
1 Parent(s): 70277bf

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +19 -6
index.html CHANGED
@@ -26,14 +26,22 @@
26
  env.allowLocalModels = false;
27
 
28
  // Reconhecimento de Entidades Nomeadas (NER)
29
- const nerStatus = document.getElementById('status');
30
  const textInput = document.getElementById('text-input');
31
  const analyzeTextButton = document.getElementById('analyze-text');
32
  const textOutput = document.getElementById('text-output');
33
 
34
- nerStatus.textContent = 'Carregando modelo de NER...';
35
- const nerModel = await pipeline('ner', 'Xenova/distilbert-base-multilingual-cased-ner-hrl');
36
- nerStatus.textContent = 'Modelo de NER pronto!';
 
 
 
 
 
 
 
 
 
37
 
38
  analyzeTextButton.addEventListener('click', async () => {
39
  const inputText = textInput.value.trim();
@@ -43,8 +51,13 @@
43
  }
44
 
45
  textOutput.textContent = 'Analisando...';
46
- const nerOutput = await nerModel(inputText);
47
- renderEntities(nerOutput);
 
 
 
 
 
48
  });
49
 
50
  function renderEntities(entities) {
 
26
  env.allowLocalModels = false;
27
 
28
  // Reconhecimento de Entidades Nomeadas (NER)
 
29
  const textInput = document.getElementById('text-input');
30
  const analyzeTextButton = document.getElementById('analyze-text');
31
  const textOutput = document.getElementById('text-output');
32
 
33
+ // Carregar modelo NER com quantização q4
34
+ let nerModel;
35
+ try {
36
+ textOutput.textContent = 'Carregando modelo de NER...';
37
+ nerModel = await pipeline('ner', 'Xenova/distilbert-base-multilingual-cased-ner-hrl', {
38
+ dtype: 'q4'
39
+ });
40
+ textOutput.textContent = 'Modelo de NER pronto!';
41
+ } catch (error) {
42
+ console.error('Erro ao carregar o modelo:', error);
43
+ textOutput.textContent = 'Erro ao carregar o modelo. Tente novamente mais tarde.';
44
+ }
45
 
46
  analyzeTextButton.addEventListener('click', async () => {
47
  const inputText = textInput.value.trim();
 
51
  }
52
 
53
  textOutput.textContent = 'Analisando...';
54
+ try {
55
+ const nerOutput = await nerModel(inputText);
56
+ renderEntities(nerOutput);
57
+ } catch (error) {
58
+ console.error('Erro durante a análise:', error);
59
+ textOutput.textContent = 'Erro durante a análise. Verifique o texto inserido.';
60
+ }
61
  });
62
 
63
  function renderEntities(entities) {