Thursday, September 25, 2025

CLASS X - TEXT NORMALIZATION (ARTIFICIAL INTELLIGENCE)

Text Normalization

 CLASS X - ARTIFICIAL INTELLIGENCE

 

 CBSE CLASS X – Artificial Intelligence

 

Q. Normalise the text on the segmented sentences given below:

Document 1: Diya and Riya are best friends.

Document 2: Diya likes to play guitar but Riya prefers to play violin

 

Q. Sushmitha, a student of class X, was exploring the Natural Language Processing domain. She got stuck while performing the text normalization. Help her to normalize the text on the segmented sentences given below:

Document 1: Akash and Ajay are best friends.

Document 2: Akash likes to play football but Ajay prefers to play online games.

 

Corpus

In Text Normalization, A corpus is a large and structured set of machine-readable texts that have been produced in a natural communicative setting.  A corpus can be defined as a collection of entire text of all documents in a dataset.

 

Text Normalization

It is a process to reduce the variations in text’s word forms to a common form when the variation means the same thing.

The different in text normalization is

1. Sentence Segmentation

2. Tokenisation

3. Removing Stop words, Special characters and Numbers

4. Converting text to a common case

5. Stemming  and Lemmatization

 

 

Q. Normalize the given text and comment on the vocabulary before and after the normalization:

Raj and Vijay are best friends. They play together with other friends. Raj likes to play football but Vijay prefers to play online games. Raj wants to be a footballer. Vijay wants to become an online gamer.

ANS -

1.    Sentence Segmentation:

Under sentence segmentation, the whole text is divided into individual sentences.

1. Raj and Vijay are best friends.

2. They play together with other friends.

3. Raj likes to play football but Vijay prefers to play online games.

4. Raj wants to be a footballer.

5. Vijay wants to become an online gamer.

 

2. Tokenisation

Under tokenisation, every word, number and special character is considered separately and each of them is now a separate token.

3. Removing Stop words, Special characters and Numbers

Stopwords are the words which occur very frequently in the corpus but do not add much meaning  to it.

eg. - a, an, and, are, as, for, it, is, into, in, if, on, or, such, the, this, there, to etc.

Hence, to make it easier for the computer to focus on meaningful terms, these words are removed.

 

3. Removing Stop words, Special characters and Numbers

1. Raj and Vijay are best friends.

    Raj, Vijay, best, friends

2. They play together with other friends.

    Play, together, other, friends

3. Raj likes to play football but Vijay prefers to play online games.

    Raj, likes, play, football, Vijay, prefers, play, online, games

4. Raj wants to be a footballer.

    Raj, wants, footballer

5. Vijay wants to become an online gamer.

    Vijay, wants, become, online, gamer

 

4. Converting text to a common case

After the stop words removal, we convert the whole text into a similar case, preferably lower case.

1. raj, vijay, best, friends.

2. play, together, other, friends.

3. raj, likes, play, football, vijay, prefers, play, online, games.

4. raj, wants, footballer.

5. vijay, wants, become, online, gamer.

 

5. Stemming and Lemmatization

stemming is the process in which the affixes of words are removed, and the words are converted to their base form.

 

5. Stemming and Lemmatization

stemming is the process in which the affixes of words are removed, and the words are converted to their base form.

1. raj, vijay, best, friend

2. play, together, other, friend

3. raj, like, play, football, vijay, prefer, play, online, game

4. raj, want, footballer

5. vijay, want, become, online, gamer

 

 

 

 

 

 

 


 

CBSE SAMPLE PAPER COMPUTER SCIENCE - 2026 WITH ANSWER KEY

CBSE SAMPLE PAPER 

COMPUTER SCIENCE - 2026 WITH ANSWER KEY

 

CLICK HERE FOR SAMPLE PAPER 

 

CLICK HERE FOR ANSWER KEY 

Wednesday, January 25, 2023

Python-DATAFRAME Basic Functions and Operations

Python DATAFRAME Basic Functions and Operations



CREATING DATAFRAME

 import pandas as pd

a= {'PNAME':['TV','AC','TV','WM','AC','TV'], 'COMP':['LG','WIRLPOOL','SONY','WIRLPOOL','LG','LG'], 'PRICE':[10000,25000,15000,12000,28000,15000],'QTY':[2,5,15,8,12,5]} df = pd.DataFrame(a,index=['P1','P2','P3','P4','P5','P6']) 
********************************************* FETCH SINGLE COLUMN

 print(df['PNAME'])ORprint(df.PNAME)
OUTPUT

 


 

 

 

 

 

********************************************* FETCH MULTIPLE COLUMNS

 print(df[['PNAME','PRICE']])

OUTPUT

 


 

 

 

 

 

 

 

********************************************* FETCH SINGLE ROW

 

 print(df.loc['P2'])
ORprint(df.iloc[1])

OUTPUT



  *********************************************
 FETCH MULTIPLE ROWS

 print(df.loc[['P2','P5']])

OUTPUT

 


 

 

 

*********************************************
 FETCH SOME ROWS, SOME COLUMNS

 print(df.loc[['P2','P5'],['PNAME','PRICE']])

OUTPUT


 

 

 

 

*********************************************
 FETCH SINGLE VALUE 
print(df['COMP']['P3'])

OUTPUT

 


  

*********************************************
 FETCH ALL VALUES HAVING QTY>5

 print(df[ (df['QTY']>5) ])

OUTPUT


 

 

 

 

*********************************************
 FETCH TOP 3 ROWS

print(df.head(3))

OUTPUT

 


 

 

 

 

 

*********************************************
 FETCH LAST 3 ROWS

 print(df.tail(3))

 OUTPUT

 


 

 

 

 

*********************************************
 ADDING NEW COLUMN 
df['DISCOUNT'] = [1,4,2,6,8,3]OR
df.loc[:,'DISCOUNT'] = [1,4,2,6,8,3] OR 
df.at[:,'DISCOUNT'] = [1,4,2,6,8,3]
 
 
 OUTPUT

 
 
 
 
 
********************************************* ADDING NEW ROW
df.loc['P10',:] = ['OS', 'ANDROID', 5000, 6]  OR df.at['P10',:] = ['OS', 'ANDROID', 5000, 6]
 OUTPUT
 

 
 
 
 
 
 
 
********************************************* DELETING A COLUMN  
 del df['COMP']  
OR df.drop(['COMP'],axis=1,inplace=True)  
OR df.drop(df.columns[1],axis=1,inplace=True)
 OUTPUT

 
 
 
 
 
 
 
 
 
 
 
 
 ********************************************* DELETING MULTIPLE COLUMNS
 df.drop(['PNAME','PRICE'],axis=1,inplace=True)
 OUTPUT

 
 
 
 
 
 
 
 
 
 
 
 
********************************************* DELETING A ROW
 
 df.drop(['P1'],axis=0,inplace=True)ORdf.drop(df.index[0],axis=0,inplace=True)
 OUTPUT

 
 
 
 
 
 
 
 
 
 
 
 
********************************************* DELETING MULTIPLE ROWS 
 df.drop(['P1','P2'],axis=0,inplace=True)
 
OUTPUT

 
 
 
 
 
 
 
 
 
********************************************* UPDATE COLUMN VALUES  
 df['PRICE'] = [1,2,3,4,5,6]
 

 
 
 
 
 
 
 
 
 
 
********************************************* UPDATE COLUMN WITH A SINGLE VALUE  
df['PRICE'] = 5

 
 
 
 
 
 
 
 
 
 
********************************************* UPDATE A ROW WITH A SINGLE VALUE 
 df.loc['P1',:] = 5
 

 
 
 
 
 
 
 
 
 
 
********************************************* UPDATE A ROW WITH DIFFERENT VALUES   
df.loc['P1',:] = [1,2,3,4]

 
 
 
 
 
 
 
 
 
 
********************************************* UPDATE A SPECIFIC RECORD 
 df['PRICE']['P1'] = 5
OR

df.loc['P1','PRICE'] = 5

OR

df.at['P1','PRICE'] = 5

 
 
 
 
 
 
 
 
 
 
********************************************* MISC FUNCTIONS
*********************************************
INCREASE VALUE OF QTY COLUMN BY 10  
df['QTY'] += 10

 
 
 
 
 
 
 
 
 
 
 
*********************************************SORT DATAFRAME BY QTY
 df.sort_values(axis=0,ascending=False,inplace=True,by=['QTY'])
 

 
 
 
 
 
 
 
 
 
 
*********************************************SUM OF QTY COLUMN
 print('SUM OF COLUMN IS = ', df['QTY'].sum())
 

 
 
 
 
 
 
*********************************************MINIMUM AND MAXIMUM VALUE FROM QTY COLUMN
print('MINIMUM QTY IS = ', df['QTY'].min())
print('MAXIMUM QTY IS = ', df['QTY'].max())

 
 
 
 
 
 
 
*********************************************MINIMUM AND MAXIMUM VALUE FROM EACH COLUMN 
print('MINIMUM IS = \n', df.min())
print('MAXIMUM IS = \n', df.max())
 

 
 
 
 
 
 
 
 
 
 
 
 
 
AS 
 

as