With word frequency detection. Automation of analysis of active community members.

in Steem-BRU (BY-RU-UA)3 years ago

image.png

Итак, новая версия скрипта с определением наиболее часто встречающихся слов.
So, a new version of the script with the definition of the most common words.


const fs = require("fs");
const steem = require('steem');
let xc, input, hive, fullbody;
var body2R;
var body3R;
var author;
var permlinkR;

let wifkey = 'private key';
let votey = "alexmove";

function words(body) 
{
                
    //let words = body1.split(" ");
        var wordsCount = body.reduce(function (acc, w) {
        if(acc[w]) {
            acc[w] += 1
        } else {
            acc[w] = 1;
        }
        
        return acc;
        }, {});
     
        for (var w in wordsCount) 
        {
            console.log('Cлово "%s" встречается %d раз', w, wordsCount[w]);

            if (wordsCount[w]>2) {
            if (w.length>4)  {
               
               // body3R = body3R +  `| @`+author + ` | ` + `<a href="https://steemit.com/@${author}/${permlinkR}">` + permlinkR + ` </a> | Word "`+ w +`"| be found  ` + wordsCount[w]+ ' times | \n';
                body3R = body3R +  `| @`+author + ` | ` + `<a href="https://steemit.com/@${author}/${permlinkR}">` + permlinkR + ` </a> | Word "`+ w +`"| be found  ` + wordsCount[w]+ ' times | \n';
              //  body5R = body5R + " " + w + " " + wordsCount[w];
              //  bodyArr = bodyArr + ` ` + w;
//console.log(body3R);
                fs.appendFileSync("bdLOG.txt",body3R);

            }
            }
        }

}

//for (xc = 0; xc < 3; xc++) {

                        var y, err;
                        
                        let array = fs.readFileSync('spisok.txt').toString().split("\n");
                        let test_a = array[0].split(' ');
                        let popped = test_a.shift();
                        console.log(test_a);

                        function test_c(qu) {
                         steem.api.getDiscussionsByComments({
                                    "start_author": qu,
                                    "limit": 100
                                }, function (err, result) {
                                 //  console.log(err, result);
                                    
                                    if (err === null) {
                                         var stat = 0;
                                              console.log(stat);

                    var i, len = result.length;
                    for (i = 0; i < len; i++) {
                        
                        var discussion = result[i];
                        var d = new Date(); // Today!
                        d.setDate(d.getDate() - 1); // Yesterday!
                        d = d.toJSON().split("T")[0];
                        
                        permlinkR = discussion.permlink;
                        
                        author = discussion.author;
                        input = discussion.created;
                        hive = discussion.category;
            //  console.log('fullbody');  
            //  console.log(fullbody);  
                
                    //   input = input.toLocaleString();
                    //      input = input.toDateString; 
                        //input2.setMilliseconds(2 * 60 * 60 * 1000); 
                        //input2.setMinutes(input2.getMinutes() + minutes);
                        //var input = input2 + input2.getTimezoneOffset() * 60;

                    //  console.log(hive);
                        console.log(input);
                    //  console.log(discussion.body );

                        //hive = '';
                        if ((input.indexOf(d) !== -1) && (hive === 'hive-171319')) {
                          stat=stat+1;
                          fullbody = fullbody + ' ' + discussion.body;

                         //     console.log('YEEEES');
                        //  console.log(stat);
                        //  console.log(qu);
                            


      
                    }}
                            
                console.log(fullbody);
                body = fullbody.split(" ");
                words(body);
                            
                    }
                    
                        //console.log(qu, stat);
                        qu2 = qu+' '+stat+"\r\n";
                        fs.appendFile("brustat.txt", qu2, (err) => { 
                          if (err) { 
                            console.log(err); 
                          } 
                        }); 
                    }
                    
                    );



        }


                        //for (y = 0; y < 6; y++) {

                        //  console.log(array[y]);
                            let stat, test;
                            test = test_a[1].trim();
                            //console.log(test);
                            test_c(test);
                        //} 

                        fs.writeFile("spisok.txt", test_a.join(' '), (err) => { 
                          if (err) { 
                            console.log(err); 
                          } 
                        }); 
                        
//}

First, all comments are collected into one long line like this:
Вначале собираются все комментарии в одну длинную строку, подобную этой:

комментарии @milakz за 21.09.2021
@milakz comments for 09/21/2021

undefined Thank you, we will contact you soon. 😊 Thank you!! We will find the best teacher for you!! Спасибо большое🙏� Спасибо большое🙏🏻 Thank you so much!! God bless you!! Thank you so much @papi.mati!! I am so happy and thankful to read all supportive and kind comments!!!🥰🥰 Спасибо большое🙏🏻 Очень стараюсь, это сейчас самая гла вная цель 🎯🤫 Спасибо большое🙏🏻👍 держусь Спасибо большое🙏🏻 Такая уверенность обнадёживает🤗 Спасибо большое, Настёна🙏🏻 Спасибо большое🙏🏻 Очень стараюсь 🤞 Спасибо большое🙏🏻 Я верю в силу молитвы. Молюсь каждый день🙏🏻 Спасибо за поддержку Спасибо большое 🙏🏻 Молюсь каждый день Спасибо большое 🙏🏻 Да еда конечно даже выглядит не аппетитно((( про вкус вообще молчу 🤫 Спасибо большое! Стараюсь🤗 Спасибо большое 🙏🏻 Спасибо. Надеюсь всё будет хорошо🙏🏻 Thank you!! I love the idea of mood boards. I think you can do Contest -lesson about mood boards. I only used visualisation boards but I love your idea! Thank you for interesting post😁 It was very interesting and I think useful for any person who cares about productivity and happy life Спасибо большое🙏🏻 Yes, we are able to promote even more🥰 Thank you!! Let's gro w big ❤ That's the spirit!! Thank you very much!! Thank you so much!! I am honoured as well. Let's make Steemit even bigger Thank you so much!! Спасибо, я мечтаю об этом дне🥳 Я не прививалась. Врачи говорят, что у меня лёгкая форма и поэто му я лечусь дома. Но уже 7 день и мне кажется это никогда не закончится. Спасибо, что пишите, мне очень приятно. Надеюсь я уже скоро вернусь в строй🤒 Спасибо большое)) я бы с радостью, надеюсь недолго осталось(( Спасибо большое 🙏🏻 С каждым днём у меня прибавляются новые симптомы. Я уже боюсь представить, что меня ждёт дальше. Спасибо большое 🙏🏻 Thank you for your contribution. Recently, you got many requests to learn Chinese. Keep up good work!! We think that your posts help a lot our developers team! Thank you for such good quality post!! Thank you🥳 We will promote the participants!! Thank you for great lessons Thank you for the update and controlling quality posts as it is important to rise quality of photos on Steem SkillShare. Photography is a useful skill on Social Media. The pictures attract attention quicker than the whole text. Promotion is very important. We promote Steem Transactions between users Can you please specify your subject? Can you please tell me if you mean linguistic? Hey, I didn't forget. I included just those who publish lessons but I saw you started so you will be included in my post Спасибо большое🍀 Спасибо большое!🥳 Спасибо большое!) I am add ing you. Да, очень вкусный)) Спасибо 🙏🏻 Thank you 🥰 Спасибо 🥳🤗 Одно название выходной, дела по дому никто не отменя л)) Спасибо🤗 Thank you so much 🥰 Thank you so much 🥰 Thank you so much ☺️ Спасибо большое! Да, когда болеешь внимание и забота родных очень лечит и поднимает настроение) А когда ещё столько поздравлений со стимита, вдвойне приятно! Потому что день рождения с температурой 39 это ужасно 😢 Спасибо большое🥳 Да мама очень постаралась, чтобы мне понравилось🥰 Спасибо большое🥰 С
пасибо большое 🥰 Спасибо большое! 🥳 I think we can organise origami contest. What do you think or online fair. Спасибо большое! Ох и где ж мои 25 лет)) самой не верится, что уже 34🧐 Thank you☺️ Good luck🤞 Thank you so much!!😍😍😍
Thank you for your great support!!
I love Steemit ❤ Thank you so much ☺️ Спасибо большое! Тортики очень вкусные, я даже по вилочке их попробовала)) Да главное вылечиться и тогда можно будет отметить в узком кругу🤗 Спасибо большое 🎊 Спасибо большое🥳 Спа сибо большое. Мне очень приятно 🤗 Thank you so much! I'm very pleased!🤗 I would really like to visit Argentina😍 Спасибо🍀🤗 Thank you so much ☺️ Hi @jobreyes24. Sorry, I missed it. Thank you for writing 🍀 Please consider this post
https://steemit.com/hive-197809/@daytona475/instructional-guide-to-add-images-to-our-steemit-publications
Cc @daytona475 Thank you for detailed instructions. Food is very important. I didn't do any sport. I just changed mt diet and I lost 5 kg Thank you! The house looks beautiful. How much do you charge per online lesson. Can you draw any object? It sounds like a very interesting topic. Photography always attracted me. When I will have more time, I will definitely try it. Thank you so much for supporting the community. 🥳🎊👏 Wow I think we can do a contest on furniture makeovers and you can be the judge Не жизнь, а сплошные приключения)) всегда есть что вспомнить👍 Никогда ещё не пробовала печёночный тортик. Очень много слышала, но как то не решалась его приготовить. Потому что я не люблю печень(( Но рецепт лёгкий, может как нибудь попробую приготовить Да, автор очень постарался🔥 Нет, это наши медики так уничтожают ковид)) Очень крутое граффити!😍 Москва очень красивая😍 В этой тематике у нас оказывается несколько граффити по городу. Но я пока только это встретила. О, да надо пользоваться тёплыми деньками, уже скоро начнутся холода и не по медитируешь)) Thank you so much 🍀 Растём🎊🥳 Надеюсь что взрослеет, ему в октябре будет уже 1 год)) А может и так кадр слов ила, потому что он очень активный)) О, да уже сезон правда закончился(( Будем кушать яблоки, наш знаменитый Алматинский апорт)) Thank you! It’s very good 👍 Your skill is amazing. I will try to practice and share with u in comments I think your post can benefit many users to switch to healthy life style. Your posts are really beautiful. We would love to have you in our team

Затем в них определяется наиболее встречающиеся слова, и записываются в файл: bdLOG.txt
Then the most common words are determined in them, and written to the file: bdLOG.txt

Из этого файла я вручную импортирую в таблицу и сортирую по убыванию количества встречающихся слов.
From this file, I manually import into the table and sort in descending order of the number of words encountered.

Есть желания развивать скрипт дальше, можно как доделывать то, что есть сейчас, так и добавлять новые функции. Можно в целом добавить рейтинг не только комментарий, но и постов. Важно, чтобы это было интересно многим. Пока я ищу такие варианты, которые были бы интересны.

There is a desire to develop the script further, you can either finish what is now, or add new functions. In general, you can add a rating not only to the comment, but also to the posts. It is important that it be interesting to many. While I'm looking for options that would be interesting.

Прошлая версия тут. В этом же посте есть скрипт для сортировки по количеству комментариев.
The previous version is here. In the same post there is a script for sorting by the number of comments.

https://steemit.com/hive-171319/@alexmove/test-working-scripts-automation-of-analysis-of-active-community-members

Sort:  
 3 years ago 

Я ничерта не понимаю, но кажется это здорово! Только вот вручную вытягивать слова и вставлять в таблицу наверное долго, вдруг все будут сильно активные ... это ж сколько время нужно(

 3 years ago 

Ничего не понял, но было ОООчень интересно ))

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.034
BTC 64231.88
ETH 3128.59
USDT 1.00
SBD 3.95