Scénario de test & Cas d'usage
Rule-based scoring of text documents.
Discover all actions of textRuleScoreCreate two tables: one for the customer emails ('customer_feedback') and one for the custom LITI model ('product_sentiment_liti') that defines rules for extracting products and sentiment.
| 1 | DATA mycas.customer_feedback; |
| 2 | LENGTH feedback_id $ 10 email_body $ 500; |
| 3 | INFILE DATALINES delimiter='|'; |
| 4 | INPUT feedback_id $ email_body $; |
| 5 | DATALINES; |
| 6 | email001|I am very happy with the new FusionX Pro, it's incredibly fast! |
| 7 | email002|The DataStreamer tool is a bit complicated, and the performance is disappointing. |
| 8 | email003|My FusionX Pro arrived broken. This is an awful experience. |
| 9 | email004|Just a quick note to say the DataStreamer is a fantastic product. Great job! |
| 10 | ; |
| 11 | run; |
| 12 | |
| 13 | data mycas.product_sentiment_liti; |
| 14 | length model_id $ 20 model_txt $ 500; |
| 15 | infile datalines delimiter='|'; |
| 16 | INPUT model_id $ model_txt $; |
| 17 | DATALINES; |
| 18 | model1|CONCEPT:PRODUCT@FusionX Pro, DataStreamer |
| 19 | model1|CONCEPT:SENTIMENT_POS@happy, fantastic, great job |
| 20 | model1|CONCEPT:SENTIMENT_NEG@disappointing, broken, awful |
| 21 | model1|SEQUENCE:PRODUCT_SENTIMENT:(SENTIMENT_POS, SENTIMENT_NEG) (PRODUCT):_c |
| 22 | ; |
| 23 | RUN; |
| 1 | /* |
| 2 | Data is prepared and loaded in the data_prep step */ |
| 1 | PROC CAS; |
| 2 | textRuleScore.applyConcept / |
| 3 | TABLE={name='customer_feedback'}, |
| 4 | docId='feedback_id', |
| 5 | text='email_body', |
| 6 | model={name='product_sentiment_liti'}, |
| 7 | casOut={name='feedback_concepts', replace=true}, |
| 8 | factOut={name='feedback_facts', replace=true}; |
| 9 | RUN; |
| 10 | QUIT; |
Two output tables are created. The 'feedback_concepts' table contains all individual matches for PRODUCT, SENTIMENT_POS, and SENTIMENT_NEG concepts. The 'feedback_facts' table contains extracted facts, linking specific products to the sentiment expressed in the same email (e.g., linking 'FusionX Pro' to 'happy' for email001).