Thursday, July 28, 2022

Natural Language Processing Questions and Answers (Set 4 of 7 Questions)

Course: INTRODUCTION TO NATURAL LANGUAGE PROCESSING

Q1: Multiple Choice Correct

Which of the following are potential use cases of NLP?

a) A self driving car drawing your attentioin to an advertising billboard

b) Given the audio of a song, and its lyrics generate a translated song audio       

c) Understanding a cryptic language 

d) Determing what are the chances that you will win a law suit based on outcomes of previous similar law suits.

Answer: All four are correct.

Q2: Multiple Choice Correct 

Which of the below tasks can be performed effectively even without using sophisticated NLP techniques:

a) Identifying the main topic of a document assuming that its title is not provided.

b) Detecting the language in a document 

c) Extracting the phone numer, email address and year of graduatioin from a resume.

d) Substituting words like doesn't, can't, etc with does not, and can not, etc.

Answer: C and D 

Q3: Spam email is a persistent problem that service providers have been trying to solve for years now. One of the key tasks in building an effective spam detection system is identifying the features of an email that could be used to classify the email as spam or not.

Rank the following features based on the text content of an email based on your Understanding of the feature's importance.

a) Language (English, French, etc) used in the email text.

b) Presence of words with spelling mistakes / non standard form.

c) Emails addressed to you and contain your name.

Answer:
Correct order is: C > A > B 

Q4) Identify the kind of ambiguity in the given sentences:

a) Time flies like an arrow, fruit flies like a banana.

b) Iraqi head seeks arms.

c) A frog thought it saw a prince walk towards it. It thought it can't be true.

List of ambiuities for matching with above sentences.

I) Anaphoric Ambiguity 

II) Semantic Ambiguity 

III) Syntactic Ambiguity.

Answer: 
A -> III 
B -> II  
C -> I 

Syntactic ambiguity
Take a look at the sentence given below
“Old men and women were taken to safe locations”
This sentence has a syntactic ambiguity where the scope of the adjective “old” needs to be resolved.
In this sentence, we may not know if the adjective applies only to men or to both men and women.

Semantic ambiguity
Semantic ambiguity refers to ambiguity in the meaning.
For example, the sentence
“Alice loves her mother and so does Jacob.”
The ambiguity here is, we may not know if Jacob loves his own mother or Alice’s mother.

Anaphoric Ambiguity 

In the below paragraph
“The horse ran up the hill. It was very steep. It soon got tired.”
In this paragraph, the pronoun ‘it’ is used to refer to the hill first and then to the horse. To interpret this sentence, we need to have knowledge of the world and context. These ambiguities are called anaphoric ambiguities.


Q5) Consider the below review for co-sleeper sheets for a baby. What is the sentiment in this review?
"The shipping was quick the colors are pretty but the sheets themselves are not soft."

a) positive
b) negative 
c) Neutral

Amswer: Positive 
The user is appreciating the shipping and the colors.

Q6) Do sentiment analysis of following sentence:

"The parking was great, the restaurant anbience was good. But the food was utterly terrible."

a) positive
b) negative 
c) Neutral

Answer:
Although the number of positive words is greater than the number of negative words in these sentences, the overall sentiment was negative.

Weighted Scores to Find The Polarity
The short coming of this dictionary based, and weighted scores for doing Sentiment Analysis is that it misses out on the order of words and hence may classify the sentiment as wrong.

Q7) Assume that you have to build an NLP application that looks at a new document and estimates how similar it is to various text documents previously ingested. Consider that similarity of 2 documents is computed on the basis of presence of common words.

Based on your understanding of the NLP technique discussed so far, what are various basic pre-processing steps that you will include in this application while processing the historic data and making inferences on a new document?

Steps:

a. Remove any unwanted spaces, numbers, special characters, etc 
b. Convert all text into lower case.
c. Create n-grams based on the text.
d. Tokenize the text.
e. Normalize data using stemming and lemmatization techniques.
f. Determine the frequence of each word in each document and also in the whole corpus.
g. Remove stop words from the text.
h. Remove punctuation
i. Perform POS tagging on the text.

Options:

I. All the steps listed above need to be done.
II. a, b, d, f, g, h 
III. b, c, d, e, h, g 
IV. a, d, e, f, g

Answer: II 
Tags: Natural Language Processing

20220728 - Monitoring Effects of 1 tablet of Trini Calm and 1 tablet of Petril Beta 10

Index of Journals
20220728

1910: 
1 Tablet of Trinicalm Plus
SALT COMPOSITION: Trifluoperazine (5mg) + Trihexyphenidyl (2mg) 

1 Tablet of Petril Beta 10 Tablet
SALT COMPOSITION: Clonazepam (0.25mg) + Propranolol (10mg)

Note: 
1. Trihexyphenidyl is also referred to as "THP" medical prescriptions for psychiatric cases.
2. Clonazepam is also known as Clazzy in the underworld of drugs.

1914: Shiva Patel has just come for Math tuition.

1918:
My psychiatrist told me that: Propranolol is used to slow down racing heart beat an effect of facing a threatening situation.

2015: Finished teaching students.

2016: Having dinner.

2024: Going for shower.

2037: Am feeling sleepy and tired. Going for rest for an hour.

2040: Spoke to Anjali Devi's parents about NIOS (National Institute of Open Schooling) and readmitting her to study again.

2021: Going for rest.

8:52 pm: I cannot stop thinking how Rekha bua, Manju bua, and Kumkum bua are becoming a blocker in rental business.

8:54 pm: They do not understand that I purchased the flat after having a verbal fight with mom. Mom and I cannot live together.

9:32 pm: Self awareness was there but that panicky, irritated mood was not there.

2202: When I am in Mayur Vihar, I face harassment by uncle and aunt. And, when I am Tri Nagar, I face harassment by three buas.

Tags: Medicine,Psychology,

Student Update (2022-Jul-28)

Index of Journals

Counting

Srishti Patel Class: Nursery Till: 8 Anjali Devi Class: 5 Till: 9

Tables

Sonam Patel Class: 7 Till: 12 Shiva Patel Class: 6C Till: 18

Addition

Sonam Patel Class: 7 Till Level: 4 Shiva Patel Class: 6C Till Level: 9

Subtraction

Sonam Patel Class: 7 Till Level: 8
Tags: Student Update,

Types of Ambiguities in Natural Language

Lexical ambiguity

Take a look at the following sentences: John bagged two silver medals. Mary made a silver speech. Roger’s worries had silvered his hair. The word silver is used as a noun, an adjective, and a verb. The word silver in isolation is mostly associated with the metal and considered as a noun. However, in other sentences, the context gives the word silver different meanings and also different parts of speech like adjectives and verbs. This ambiguity is called lexical ambiguity.

Syntactic ambiguity

Take a look at the sentence given below “Old men and women were taken to safe locations” This sentence has a syntactic ambiguity where the scope of the adjective “old” needs to be resolved. In this sentence, we may not know if the adjective applies only to men or to both men and women.

Semantic ambiguity

Semantic ambiguity refers to ambiguity in the meaning. For example, the sentence “Alice loves her mother and so does Jacob.” The ambiguity here is, we may not know if Jacob loves his own mother or Alice’s mother.

Anaphoric ambiguity

In the below paragraph “The horse ran up the hill. It was very steep. It soon got tired.” In this paragraph, the pronoun ‘it’ is used to refer to the hill first and then to the horse. To interpret this sentence, we need to have knowledge of the world and context. These ambiguities are called anaphoric ambiguities.

Pragmatic Ambiguity

The hardest kind of ambiguity to resolve is the pragmatic ambiguity. This kind of ambiguity arises from the inability to process the intention or sentiment or world belief. For example, in the below conversation, My wife said: "Please go to the store and buy a carton of milk and if they have eggs, get six." I came back with 6 cartons of milk She said, "why did you buy six cartons of milk?" I replied, "They had eggs" As you can see here, the ambiguity is in understanding the intention of the speaker.
Tags: Natural Language Processing,

Wednesday, July 27, 2022

Risperidone (Salt) from 1mg.com

Risperidone Uses

Risperidone is used in the treatment of schizophrenia and mania.

How Risperidone works

Risperidone is an atypical antipsychotic. It works by affecting the levels of chemical messengers (dopamine and serotonin) to improve mood, thoughts and behavior.

Common side effects of Risperidone

Insomnia (difficulty in sleeping), Parkinsonism, Sedation, Dizziness, Weight gain, Akathisia (inability to stay still), Anxiety, Gastrointestinal symptom, Increased prolactin level in blood.

EXPERT ADVICE FOR RISPERIDONE

1. Risperidone helps treat schizophrenia and mania. 2. It may cause less weight gain, sedation, and heart problems as compared to other similar medicines. 3. It may take 4-6 weeks to notice any medication effects. Keep taking it as prescribed. 4. Use caution while driving or doing anything that requires concentration as Risperidone can cause dizziness and sleepiness. 5. It may cause increase in weight, blood sugar, cholesterol, and fat. Eat healthy, exercise, and monitor your levels regularly. 6. Inform your doctor if you experience any abnormal movements or restlessness. 7. Inform your doctor if you have a history of heart diseases as Risperidone can increase your risk of irregular heartbeat. 8. Do not stop taking Risperidone without talking to your doctor first as it may cause worsening of symptoms.
Tags: Medicine,Psychology

Student Update (2022-Jul-27)

Index of Journals

Counting

Komal Kumari Class: 4 Trial 1 (Beginning of class): Till: 16 Trial 2 (After an hour): Till: 20 Srishti Patel Class: Nursery Till: 1

Tables

Kusum Kumari Class: 5 Till: 2

Addition

Kusum Kumari Class: 5 Level: 7

Subtraction

Kusum Kumari Class: 5 Level: 1 URL: https://survival8.blogspot.com/2022/01/add-subtract-multiply-divide.html
Tags: Student Update,

Tuesday, July 26, 2022

Detailed Solution to Upto Three Digit Subtraction

Note: We are going to subtract the smaller number from the bigger one.
Enter two numbers between 0 to 999.


First Number:

Second Number:

0

0

 

-

------------

 

Tags: Mathematical Foundations for Data Science,

Monday, July 25, 2022

Student Update (2022-Jul-25)

Index of Journals

Counting

Komal Kumari Class: 4th Till: 16 Srishti Patel Class: Nursery Till: 10

Tables

Kusum Kumari Class: 5B Till: 3 Yash Kashyap Class: 5 Till: 8

Addition

Kusum Kumari Class: 5B Till Level: 4

Subtraction

Kusum Kumari Class: 5B Till Level: 1 Yash Kashyap Class: 5 Till Level: 2
Tags: Student Update,

Star Coat (Skin and Coat Tonic for Dogs)

For 3-4 Months Old Canine.
Tags: Medicine for dogs,

SkyCal (Pet Liquid for Stronger Bones)

For 3-4 Months old Canine.

Tags: Medicine for dogs,

Sunday, July 24, 2022

Converting image to text, saving to disk, reading text from disk and displaying image


A brief introduction of 'base64' functions 'b64encode' and 'b64decode':

(base) C:\Users\Ashish Jain>python
Python 3.7.1 (default, Dec 10 2018, 22:54:23) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from base64 import b64encode as b, b64decode as d
>>> s = 'hello'
>>> b(bytes(s, 'utf-8'))
b'aGVsbG8='
>>> bs = b(bytes(s, 'utf-8'))
>>> d(bs)
b'hello'
>>> d(b'aGVsbG8=')
b'hello'
>>> d(bs).decode("utf-8") 
'hello'

Now with image:

from base64 import b64decode, b64encode
image_handle = open('test_image.png', 'rb')
raw_image_data = image_handle.read()
encoded_data = b64encode(raw_image_data)

with open('i.txt', 'wb') as f:
  f.write(encoded_data)

with open('i.txt', 'rb') as f:
  b = f.read()

print(type(b)) 
[class 'bytes'] 
print(encoded_data == b) 
True 
with open('i.png', 'wb') as f:
  f.write(b64decode(b)) 

If you have a text file and it has data such as this: b'iVB...ggg=='
That means you had called str() function on 'bytes' type data and saved that string.

If you have a text file that has data such as this: iVB...ggg==
Then, you can read this file as ">>> with open('img.txt', 'rb') as f:" to get a 'bytes' type data. 
Tags: Technology,Python,

Deriving Derangement Theorem

5 - Deriving Derangement Theorem Go to Index of Math Lessons

Deriving Derangement Theorem

The growth of both the functions n! (factorial) and !n (derangement) is exponential, look at the table of values below:

n Permutation Derangement
2 2 1
3 6 2
4 24 9
5 120 44
6 720 265
7 5040 1854

We will work with the log (base Math.E) of these functions. Look at the table of values below:

n log(Permutation) log(Derangement)
2 0.693 0
3 1.791 0.693
4 3.178 2.197
5 4.787 3.784
6 6.5792 5.5797
7 8.5251 7.5251

We see the following relationship between these values:
log(!n) = log(n!) - 1
=> log(!n) = log(n!) - log(e)
=> log(!n) = log(n! / e)
=> !n = n! / e
And true relationship between !n and n! is: !n = round(n! / e)

Test this out by adding data to the plot showing n! and !n below:


Tags: Mathematical Foundations for Data Science,