@@ -2,101 +2,10 @@ import { Verb } from '../types/entries';
22import nlp from 'compromise' ;
33import verbData from '../data/verbs.json' ;
44
5- const sentimentCategories = {
6- positive : [
7- {
8- name : 'Support & Assistance' ,
9- subcategories : [ 'Support & Help' , 'Guide & Encourage' ] ,
10- } ,
11- {
12- name : 'Growth & Development' ,
13- subcategories : [ 'Personal Growth' , 'Adaptation & Learning' ] ,
14- } ,
15- {
16- name : 'Innovation & Creation' ,
17- subcategories : [ 'Creative Process' , 'Implementation' ] ,
18- } ,
19- {
20- name : 'Collaboration & Connection' ,
21- subcategories : [ 'Teamwork' , 'Engagement' ] ,
22- } ,
23- {
24- name : 'Achievement & Leadership' ,
25- subcategories : [ 'Leadership' , 'Achievement' ] ,
26- } ,
27- ] ,
28- negative : [
29- {
30- name : 'Conflict & Opposition' ,
31- subcategories : [ 'Direct Conflict' , 'Resistance' ] ,
32- } ,
33- {
34- name : 'Obstruction & Hindrance' ,
35- subcategories : [ 'Active Obstruction' , 'Passive Hindrance' ] ,
36- } ,
37- {
38- name : 'Evasion & Avoidance' ,
39- subcategories : [ 'Active Evasion' , 'Passive Avoidance' ] ,
40- } ,
41- {
42- name : 'Criticism & Rejection' ,
43- subcategories : [ 'Criticism' , 'Rejection' ] ,
44- } ,
45- {
46- name : 'Neglect & Indifference' ,
47- subcategories : [ 'Active Neglect' , 'Passive Indifference' ] ,
48- } ,
49- {
50- name : 'Underperformance & Failure' ,
51- subcategories : [ 'Underperformance' , 'Failure' ] ,
52- } ,
53- ] ,
54- } ;
55-
56- const categorizeBySentiment = ( verbs : Verb [ ] ) => {
57- const categorized : Record < string , Record < string , Record < string , Verb [ ] > > > = {
58- positive : { } ,
59- negative : { } ,
60- } ;
61-
62- // Initialize categories and subcategories
63- sentimentCategories . positive . forEach ( ( category ) => {
64- categorized . positive [ category . name ] = { } ;
65- category . subcategories . forEach ( ( subcategory ) => {
66- categorized . positive [ category . name ] [ subcategory ] = [ ] ;
67- } ) ;
68- } ) ;
69- sentimentCategories . negative . forEach ( ( category ) => {
70- categorized . negative [ category . name ] = { } ;
71- category . subcategories . forEach ( ( subcategory ) => {
72- categorized . negative [ category . name ] [ subcategory ] = [ ] ;
73- } ) ;
74- } ) ;
75-
76- // Group verbs by their categories and subcategories
77- verbs . forEach ( ( verb ) => {
78- const sentiment = verb . categories . some ( ( cat ) =>
79- sentimentCategories . positive . some ( ( posCategory ) =>
80- posCategory . subcategories . includes ( cat )
81- )
82- )
83- ? 'positive'
84- : 'negative' ;
85-
86- verb . categories . forEach ( ( category ) => {
87- for ( const mainCategory of sentimentCategories [ sentiment ] ) {
88- if ( mainCategory . subcategories . includes ( category ) ) {
89- categorized [ sentiment ] [ mainCategory . name ] [ category ] . push ( verb ) ;
90- break ;
91- }
92- }
93- } ) ;
94- } ) ;
95-
96- return categorized ;
97- } ;
98-
99- // Get verb name by id, processed with compromise.
5+ /**
6+ * Gets verb name by id, processed with compromise.
7+ * Converts to present tense and lowercase.
8+ */
1009const getVerbName = ( verbId : string ) : string => {
10110 const found = ( verbData . verbs as Verb [ ] ) . find ( ( v ) => v . id === verbId ) ;
10211 if ( found ) {
@@ -106,4 +15,4 @@ const getVerbName = (verbId: string): string => {
10615 return verbId ; // Fallback: return the id if not found.
10716} ;
10817
109- export { getVerbName , categorizeBySentiment , sentimentCategories , type Verb } ;
18+ export { getVerbName } ;
0 commit comments