The TEXTMINE Procedure
Example 24.8 Selecting Parts of Speech and Entities to Ignore
This example uses the data table that is generated in Example 24.1. If you want to eliminate prepositions, determiners, and proper nouns from your analysis, you can add a SELECT statement that lists these part-of-speech labels. If you also want to eliminate entities that are labeled "nlpDate," you can add another SELECT statement that includes "nlpDate" in the label list.
/* create data table */
data mycas.CarNominations;
infile datalines delimiter='|' missover;
length text $70 ;
input text$ i;
datalines;
The Ford Taurus is the World Car of the Year. |1
Hyundai won the award last year. |2
Toyota sold the Toyota Tacoma in bright green. |3
The Ford Taurus is sold in all colors except for lime green. |4
The Honda Insight was World Car of the Year in 2008. |5
;
run;
proc textmine data=mycas.CarNominations;
doc_id i;
var text;
parse
termwgt = none
cellwgt = none
reducef = 1
entities = std
outparent = mycas.outparent
outterms = mycas.outterms
outchild = mycas.outchild
outconfig = mycas.outconfig
;
select "PPOS" "DET" "PN"/ignore;
select "nlpDate"/group="entities" ignore;
run;
data outterms; set mycas.outterms; run;
proc print data= outterms; run;
Output 24.8.1 shows the content of the mycas.outterms data table. You can see that prepositions, determiners, and proper nouns are excluded. Terms that are labeled "nlpDate" are also excluded.
Output 24.8.1: The mycas.outterms Data Table Ignoring Specified Parts of Speech and Entities
| Obs | Term | Role | Attribute | Freq | numdocs | _keep | Key | Parent | Parent_id | _ispar | Weight |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | is | V | Alpha | 2 | 2 | Y | 19 | 16 | 16 | . | 1 |
| 2 | was | V | Alpha | 1 | 1 | Y | 20 | 16 | 16 | . | 1 |
| 3 | bright | A | Alpha | 1 | 1 | Y | 1 | . | 1 | 1 | |
| 4 | taurus | N | Alpha | 2 | 2 | Y | 2 | . | 2 | 1 | |
| 5 | won | V | Alpha | 1 | 1 | Y | 21 | 12 | 12 | . | 1 |
| 6 | lime green | nlpNounGroup | Alpha | 1 | 1 | Y | 3 | . | 3 | 1 | |
| 7 | lime | A | Alpha | 1 | 1 | Y | 4 | . | 4 | 1 | |
| 8 | except | V | Alpha | 1 | 1 | Y | 5 | . | 5 | 1 | |
| 9 | bright green | nlpNounGroup | Alpha | 1 | 1 | Y | 6 | . | 6 | 1 | |
| 10 | color | N | Alpha | 1 | 1 | Y | 7 | . | 7 | + | 1 |
| 11 | hyundai | nlpOrganization | Entity | 1 | 1 | Y | 8 | . | 8 | 1 | |
| 12 | sold | V | Alpha | 2 | 2 | Y | 22 | 17 | 17 | . | 1 |
| 13 | toyota | nlpOrganization | Entity | 2 | 1 | Y | 9 | . | 9 | 1 | |
| 14 | ford | nlpOrganization | Entity | 2 | 2 | Y | 10 | . | 10 | 1 | |
| 15 | all | A | Alpha | 1 | 1 | Y | 11 | . | 11 | 1 | |
| 16 | win | V | Alpha | 1 | 1 | Y | 12 | . | 12 | + | 1 |
| 17 | colors | N | Alpha | 1 | 1 | Y | 23 | 7 | 7 | . | 1 |
| 18 | award | N | Alpha | 1 | 1 | Y | 13 | . | 13 | 1 | |
| 19 | last | A | Alpha | 1 | 1 | Y | 14 | . | 14 | 1 | |
| 20 | green | N | Alpha | 2 | 2 | Y | 15 | . | 15 | 1 | |
| 21 | be | V | Alpha | 3 | 3 | Y | 16 | . | 16 | + | 1 |
| 22 | sell | V | Alpha | 2 | 2 | Y | 17 | . | 17 | + | 1 |
| 23 | year | N | Alpha | 3 | 3 | Y | 18 | . | 18 | 1 |