BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Azeem112
Quartz | Level 8

I have some string data and I want to extract the nouns from those strings. 

 

data text;
infile datalines delimiter=",";
length Id $5 string $100;
input Id String $;
datalines;
10, Ahmad is a student in fifth grade
11, His mother is a nurse in a hospital
12, His aunt is a kindergarten teacher
;
run;
Now I want to extract the nouns from this data.
 
I want a table with the below data as
 
ID  Noun
10  student grade
11 mother nurse
12  aunt kindergarten teacher
 
Is there any NLP library or function in SAS that can do this?
1 ACCEPTED SOLUTION

Accepted Solutions
Azeem112
Quartz | Level 8

I wrote a python code that returns noun words using nltk lbirary and passed that string to it as parameter. I executed that code using pipe command and saved the output in a sas dataset.

View solution in original post

10 REPLIES 10
andreas_lds
Jade | Level 19

I don't know any function that can do this, would be interesting to maintain such a function, which, of course, needs to support multiple languages.

 

Maybe such a function exists in a special sas-component.

Maybe you can find a list of nouns in the www.

 

If you have such a list, the program could have the following steps:

  1. read the list
  2. create an informat (see code below)
  3. check each word
data nouns_fmt;
   set list(rename=(noun = start)) end=jobDone;
   retain FmtName 'IsNoun' Type 'i' Hlo 'U' Label 1;
   
   Start = upcase(start);
   output;
   
   if jobDone then do;
      HLO = 'O';
      Label = 0;
      output;
   end;
run;

proc format cntlin= nouns_fmt;
run;
ballardw
Super User

Ahmed is a Proper Noun. Is there are RULE that proper nouns are not to be included?

What is the RULE that Hospital is not considered as a noun in the second observation?

 

What would the result be for a sentence like:

I grade papers.

Natural language processing is a pain. English may be the worst language to attempt this with because so many "nouns" are also adjectives, adverbs or verbs.

There are also problems related with separating proper nouns from nouns with the fads for "yewneek" spellings of children's names where more names are place names, drinks, occupations and other non-traditional words. Remembering of course than many current proper names are nouns or job descriptions in older languages or versions of English.

Azeem112
Quartz | Level 8

There is not any rule regarding nouns and proper nouns. I just need to get noun information for analytics. it could be both nouns and proper nouns. I extracted the nouns from an online website. 

Azeem112
Quartz | Level 8

I just need to look fr words that user enter in a string and I need to extract the nouns from it. 

Kurt_Bremser
Super User

Quote from you:

I extracted the nouns from an online website

Now, what is it? Manually entered, or retrieved from a website?

Please describe in detail(!!!) your whole process.

Azeem112
Quartz | Level 8

I get that manually from a website.

Azeem112
Quartz | Level 8
I searched "Get nouns from a string online" and the first website does this for me
Patrick
Opal | Level 21

It looks like SAS Visual Text Analytics provides functionality in this area.

Patrick_0-1666077461290.png

 

Azeem112
Quartz | Level 8

I wrote a python code that returns noun words using nltk lbirary and passed that string to it as parameter. I executed that code using pipe command and saved the output in a sas dataset.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 10 replies
  • 896 views
  • 0 likes
  • 5 in conversation