The Diary Game 09/20/2022

in CCS2 years ago

The Diary Game 09202022.png

Hey everyone!

I continue to work with the system for checking the uniqueness of posts and text analysis.

Text20.js


Script for sorting an array depending on the frequency of finding words.

 // index.js
const dsteem = require('dsteem');
const client = new dsteem.Client('https://api.steemit.com');
var natural = require('natural');
var tokenizer = new natural.WordTokenizer();
 
 function sortByCount(array)
{
    if( !Array.isArray(array) )
        throw new TypeError('Incorrect type of ' + typeof array);

    let valuesMap = new Map();
    array.forEach(elem => {

        valuesMap.set(elem, valuesMap.has(elem) ? valuesMap.get(elem) + 1 :  1);
    });

    let arr =  [...valuesMap.entries()].sort((a, b) => b[1] - a[1]);

    return arr.map(value => value[0]);
}


    const filter = "created";
    const query = {tag: "steemit",limit: 1}
 
    console.log('Post assembled.\nFilter:', filter, '\nQuery:', query);

    client.database
        .getDiscussions(filter, query)
        .then(result => {
            //console.log('Response received:', result);
            if (result) {
                var posts = [];
                result.forEach(post => {
                    const json = JSON.parse(post.json_metadata);
                    const image = json.image ? json.image[0] : '';
                    const title = post.title;
                    const author = post.author;
                    const created = new Date(post.created).toDateString();
                    let upvote = post.active_votes.length;

            
//console.log(post.body);
let text2 = tokenizer.tokenize(post.body);
console.log(text2);

// исходный массив
let fruits = ['banana', 'fruit', 'apple', 'apple', 'orange', 'banana', 'orange', 'banana', 'banana', 'apple'];


let ex = sortByCount (text2);
console.log(ex);

                });

            } else {
                console.log('No result');

            }
        })
        .catch(err => {
            console.log(err);
        });

But we still need to remove "noises" - words that do not carry a significant semantic load, like:

'you',
'to',
'the',
'of',
'a',
'and'

https://openbase.com/categories/js/best-nodejs-nlp-libraries

Wow, there are many packages for language processing.

npm install sentiment

var Sentiment = require('sentiment');
var sentiment = new Sentiment();
var result = sentiment.analyze('Cats are stupid.');
console.dir(result); // Score: -2, Comparative: -0.666

I publish post about this: https://steemit.com/hive-153176/@alexmove/nlp-natural-language-processing-for-posts-on-steemit-experimental-nodejs

photo_2022-09-20_21-22-42 (2).jpg

Life

Yesterday I went to the house on the same principle, and woke up in the apartment, as in the past days. During the day I cleaned the garden. In the evening I went and bought food. It is cloudy and cold in our city. And it's raining. I want to communicate, so I'm looking for new friends now.

photo_2022-09-20_21-22-42 (3).jpg

Love

Yesterday I went into the elevator and heard someone coming into the entrance. And I decided to wait for the person and said loudly "I'm waiting for you!". It turned out to be a girl. And she got off the floor below, on the fifth floor, and I went to the sixth.

And then I regretted that I did not talk to her. And I even came up with a script for how I would communicate with her. I came up with a simple scheme that I would say "hello!", Then, perhaps, "how are you!". And I will say that I live on the floor above and can we go for a walk?

But today I again went into the elevator with this girl (!!) and the maximum that was enough for me was to tell her "good evening!".

Here's how interesting it is. Will I meet her again? And can I say anything more to her?

Thank you for your attention
Have a nice day!

photo_2022-09-20_21-22-45.jpg

Sort:  
 2 years ago 

Interesting day


This post was selected for Curación Manual (Manual Curation)

@tipu curate

Thank you!

 2 years ago 

Seems a lot of programming works there.

Yes, you right) Thank you for you comment, @shula14

Бро, будь уверенней! Вдруг она ждёт от тебя решительных действий?

Thank you for you comment!

Coin Marketplace

STEEM 0.18
TRX 0.15
JST 0.028
BTC 62943.85
ETH 2464.43
USDT 1.00
SBD 2.55