0

I want so set data in an object with 2 label positive and negative and I want to set word into the object. I tried this code:

function cok(_class, doc) {
    var vocab = {
        po: {
            wd: "good job"
        },
        ne: {
            wd: "nice job"
        }
    }
    doc = doc.split(' ')
    for (var _word of doc) {
        console.log(vocab[_class])
    }
}
cok('po', 'baik good');
cok('ne', 'jelek nakal');

I have set the positive and negative label but I'm unsure of how to store the value and loop the word.

Chris
  • 57,622
  • 19
  • 111
  • 137
  • 2
    Not sure what you want to accomplish. Could you be more explicit or give us the expected result ? – Erazihel May 02 '17 at 09:43
  • 1
    I'm really trying to understand what you want to do but your explanation is quite vague. Can you elaborate your intentions a bit better? :) – Chris May 02 '17 at 09:44
  • I want to add 2 positive and negative objects, in the 2 objects there is a word. And I want to check whether the sentence that I enter in the function cok is in 2 positive or negative objects. –  May 02 '17 at 09:51
  • 1
    @RayZal I still don't get it. Could you provide the expected result ? – Erazihel May 02 '17 at 09:55
  • the rusult i set the positif = good, nice and negatif = bad, ugly. next text "this is so good" the result positif cuz that word good. this is for naive bayes classification. –  May 02 '17 at 10:01

1 Answers1

0

loop your array like

array.forEach(function(entry) {
    entry.po = "positive";
    entry.ne = "negative";
});

This will loop and add values into each object

Nair Athul
  • 823
  • 9
  • 21