Day 1: Xenon — The positive news App With JavaScript.

Ujjwal Kumar
4 min readJul 12, 2020

Hi, I am 15 years old and this is my first real-world project. You can take a look or contribute to it on GitHub.

It’s about an app I created, called ‘Xenon’, which fetches data from the google news RSS and analyzes it to separate the negative articles from the positive ones.

So, this the landing page of the app. Before I go through the tech stack I used to make it, let me guide you through the features. As said, the news fetched from the website is positive or neutral (non-negative). The news is based on several Topics. And the rest is pretty simple, you can read the news and the latest one by reloading using the ‘Load Latest’ button. And also, the rolling release comes with a filter option to let the user choose the positivity of the app.

Technology Stack

I created xenon as a web app for more accessibility. It is a Single Page Web App, using Angular. And of course, the programming language used is Typescript. There is a server backend hosted on Heroku, which is based on node.js, which grabs the data from the RSS feed and caches every five minutes, built with javascript and the Express framework.

How It Works

The flow of data is pretty simple, was not that hard to implement. But starting from the client (Angular) HTTP request, to the analysis of data is actually a long and intimidating process for the event loop and interpreter.

The Request-Response Flow —

  1. The client gets an input from the user using the route parameters.
  2. Then it grabs it to send to the server.
  3. The server matches the client parameters to the parameters already implemented in the server.
  4. The server then acts as the client and fires a request to the google news RSS.
  5. The RSS returns the news in XML format (which is worrying)
  6. The server loads the response to its memory and parses it to JSON format for the browser to understand.
  7. Then the response is sent back to the client.
  8. The client’s sentiment engine with extra features analyzes the articles and separates the negative ones from the positive ones.
Photo by Mark König on Unsplash

YES ! Implimenting it was difficult, and planning the flow was really a challenging task, I deserve some kudos.

And putting a whole lot of smart work, the cycle only takes the average of 2.5 seconds.

Well, I know its still a bit much, but I let you enjoy an amazing loading animation :)

And yes, will definitely try to reduce it even more further, but for now, I implemented a localStorage caching to make it accessible.

The Filtering Engine

This is the most exciting and important part of the app. It’s a simple NLP implementation as many of you know, but I added some more words in the list and some extra support, just for the news implementation.

Sentiment Analysis

This is the core of my purpose of using NLP. Here’s how it works —

  1. I grabbed the AFFIN wordlist for analysis which contains certain words with their scoring.
  2. The process involves adding the score of all the words to get the net score, and if it's less than or more than a certain value, which I set dynamically according to the topic, it gets categorized into positive and negative.

For instance a sentence “ I am fine but my pet died yesterday”, the engine will use the words “fine” and “died”, extract the scores, “fine = 1”, “died = -3” for the positive and negative words and will add them. The resultant, which is 1 + (-3) = -2 is negative so its a negative sentence.

3. Still, the method is not accurate… for example, if the sentence is “I am not fine” it will grab “fine” and will announce the sentence a positive one and this is not acceptable, especially for a news app…

4. The solution was simple to implement, which is negation support. This will multiply the next word with (-1) to “not”, “weren’t” and a whole lot of phrasal stuff. Which simply reverses the sentiment.

So this is all for today, hope you liked my post... Maybe its a bit longer, but the work done on the app was of a bit more effort, so hope you read it completely.

Thanks

--

--