0
$\begingroup$

I would need to analyse the structure of texts like this:

******VIRUS ALERT****** ******VIRUS ALERT****** ******VIRUS ALERT ******

There is NEW VIRUS rapidly affecting computers on the internet. This new virus is insidious, in that it transmitted as a USENET message. Usenet is the "news group" area on the internet that users can openly discuss and exchange information on a wide variety of topics.

What makes this virus DOUBLY DANGEROUS, is that it is disguised as a common chain letter. Chain letters have been passed across usenet almost since it's beginning. Lately, a common chain letter subject is MAKE MONEY FAST.

The Make Money Fast (MMF) chain is read by thousands of people daily. It is also known as: "Easy Cash", "Make Cash Fast", "Turn 5$ into $50,000" and many others. They are all basically the same scheme, in which the reader send $1 to each of the 5 people at the bottom of the list, then moves his name onto the list.

The MMF Virus, as it has been doubed, rides along on these chain letters as a "hidden binary attachment". Since most news reader programs (computer programs used to read USENET messages) will automatically decode and store binary attachments, there is NO SAFE WAY to protect yourself from infection.

The virus attackes your system the next time you run your news reader. Though the virus is transmitted during a normal usenet session, your NEXT usenet session will probably be your last for a while. As a hidden attachment, it is automatically activated with your news reader, and very quickly destroys your partition table. Generally, this is not even noticed until the next time you try to run ANY program.

The next thing the virus does is to place your micro processor into an nth-complexity infinate binary loop, quickly destroying it. This will appear at first as a normal "lock-up" but will quickley wipe out the delicate circuitry in your system.

At this point, your ONLY hope is to NOT DOWNLOAD ANY MESSAGES that have a subject similar to above. Please, FORWARD this message to ANYONE you know that reads usenet news.

In particular, I would be interested in grammar structure of each sentence (subject, verbs, object, and so on); specific pattern at the beginning of the text and at the end; and the sentiment.

Could you please give me any tips on which Python libraries I could use to do so?

Thanks

$\endgroup$
1
$\begingroup$

So, I understand from this question that you want to understand the grammatical structure of these messages, as well as the sentiment.

In terms of grammatical structure, this depends on how far you want to parse the grammatical structure, whether that is as simple as Part of Speech (POS) tagging (Noun, Verb, etc.) or if you need to parse the sentences as effectively parse trees, which show how each word depends on others.

For POS tagging, you can use nltk's POS tagging methods (link: https://www.nltk.org/book/ch05.html)

To get an idea of how each words relates to each other, one way to do it would be dependency parsing (principles are shown here: https://medium.com/@5hirish/dependency-parsing-in-nlp-d7ade014186)

In terms of sentiment analysis, there are many ways you can approach this. One approach I can think of from the top of my head would be using a encoder-decoder model architecture.
In this type of architecture, we firstly encode the input text as a sequence of tokens (using something like an RNN / LSTM) into a 'hidden representation'. Then we decode this 'hidden representation' using for example a standard neural network where we have a final softmax output layer, which gives a probability distribution over sentiment classes. The sentiment is then chosen as the index with the highest probability. Here is a really good paper, which talks about sentiment analysis using an encoder-decoder architecture, which could be of some use: https://www.aclweb.org/anthology/Q18-1002/

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.