1
+ const expect = require ( 'chai' ) . expect
2
+
3
+ describe ( 'Testing prepare NOUN methods' , ( ) => {
4
+ before ( ( ) => {
5
+ const { getDbRef } = require ( '../getter.js' )
6
+ this . langRef = getDbRef ( ) . database ( ) . ref ( 'es' )
7
+ this . prepareMeta = require ( '../prepares.js' ) . prepareMeta ;
8
+ } )
9
+
10
+ it ( 'Should split words in definitive MISC' , async ( ) => {
11
+ const testObj = {
12
+ words : [ 'casa de un amigo' ] ,
13
+ types : [ 'NOUN' ] ,
14
+ type : 'NOUN' ,
15
+ props : { } ,
16
+ meta : { } ,
17
+ composed : true
18
+ }
19
+
20
+ const resultObj = await this . prepareMeta ( testObj , this . langRef )
21
+ expect ( resultObj . words . length ) . to . eql ( 4 )
22
+ expect ( resultObj . types . length ) . to . eql ( 4 )
23
+ expect ( resultObj . types ) . to . include ( 'NOUN' )
24
+ expect ( resultObj . types ) . to . include ( 'PREP' )
25
+ expect ( resultObj . types ) . to . include ( 'ART' )
26
+ } )
27
+
28
+ it ( 'Should mark NOUN type as SUBJ for later processing' , async ( ) => {
29
+ const testObj = {
30
+ words : [ 'casa de un amigo' ] ,
31
+ types : [ 'NOUN' ] ,
32
+ type : 'NOUN' ,
33
+ props : { } ,
34
+ meta : { } ,
35
+ composed : true
36
+ }
37
+
38
+ this . prepareMeta ( testObj , this . langRef )
39
+ . then ( ( resultObj ) => {
40
+ expect ( resultObj . type ) . to . equal ( 'SUBJ' )
41
+ } )
42
+ } )
43
+
44
+ it ( 'Should properly detect/define gender' , async ( ) => {
45
+ const testObj = {
46
+ words : [ 'abuelo' , 'y' , 'mamá' ] ,
47
+ types : [ 'NOUN' , 'CON' , 'NOUN' ] ,
48
+ type : 'NOUN' ,
49
+ props : { } ,
50
+ meta : { } ,
51
+ composed : true
52
+ }
53
+
54
+ const resultObj = await this . prepareMeta ( testObj , this . langRef )
55
+ expect ( resultObj . meta . PERSON ) . to . equal ( 'ellos' )
56
+ expect ( resultObj . meta . GENDER ) . to . equal ( 'ellos' )
57
+ expect ( resultObj . genders ) . to . eql ( [ 'él' , 'ella' ] )
58
+ } )
59
+ } )
60
+
61
+ describe ( 'Testing prepare SUBJ methods' , async ( ) => {
62
+ before ( ( ) => {
63
+ const { getDbRef } = require ( '../getter.js' )
64
+ this . langRef = getDbRef ( ) . database ( ) . ref ( 'es' )
65
+ this . prepareMeta = require ( '../prepares.js' ) . prepareMeta ;
66
+ } )
67
+
68
+ it ( 'Should manage gender' , async ( ) => {
69
+ const testObj = {
70
+ words : [ 'yo' , 'vos' , 'mamá' , 'y' , 'ella' ] ,
71
+ types : [ 'SUBJ' , 'SUBJ' , 'SUBJ' , 'CON' , 'SUBJ' ] ,
72
+ type : 'SUBJ' ,
73
+ props : {
74
+ 0 : {
75
+ gender : 'él'
76
+ } ,
77
+ 1 : {
78
+ gender : 'ella'
79
+ }
80
+ } ,
81
+ meta : { } ,
82
+ composed : true
83
+ }
84
+
85
+ var resultObj ;
86
+ //Should properly detect/define gender
87
+ resultObj = await this . prepareMeta ( testObj , this . langRef )
88
+ expect ( resultObj . meta . PERSON ) . to . equal ( 'nosotros' )
89
+ expect ( resultObj . meta . GENDER ) . to . equal ( 'ellos' )
90
+ expect ( resultObj . genders ) . to . eql ( [ 'él' , 'ella' , 'ella' , 'ella' ] ) //eql is deep equality
91
+
92
+ testObj . props [ '0' ] . gender = 'ella'
93
+ //Should use plural feminines if all genders are feminine'
94
+ resultObj = await this . prepareMeta ( testObj , this . langRef )
95
+ expect ( resultObj . meta . PERSON ) . to . equal ( 'nosotros' )
96
+ expect ( resultObj . meta . GENDER ) . to . equal ( 'ellas' )
97
+ expect ( resultObj . genders ) . to . eql ( [ 'ella' , 'ella' , 'ella' , 'ella' ] ) //eql is deep equality
98
+ } )
99
+ } )
100
+
101
+ describe ( 'Testing prepare ADV methods' , async ( ) => {
102
+ before ( ( ) => {
103
+ const { getDbRef } = require ( '../getter.js' )
104
+ this . langRef = getDbRef ( ) . database ( ) . ref ( 'es' )
105
+ this . prepareMeta = require ( '../prepares.js' ) . prepareMeta ;
106
+ } )
107
+
108
+ it ( 'Should detect adverbial TIME' , async ( ) => {
109
+ const testObj = {
110
+ words : [ 'antes' ] ,
111
+ types : [ 'ADV' ] ,
112
+ type : 'ADV' ,
113
+ props : { } ,
114
+ meta : { } ,
115
+ composed : true
116
+ }
117
+
118
+ const resultObj = await this . prepareMeta ( testObj , this . langRef )
119
+ expect ( resultObj . meta . TIME ) . to . equal ( 'pasado' )
120
+ } )
121
+
122
+ it ( 'Should transform MOD into ADV' , async ( ) => {
123
+ const testObj = {
124
+ words : [ 'después' ] ,
125
+ types : [ 'MOD' ] ,
126
+ type : 'ADV' ,
127
+ props : { } ,
128
+ meta : { } ,
129
+ composed : true
130
+ }
131
+
132
+ const resultObj = await this . prepareMeta ( testObj , this . langRef )
133
+ expect ( resultObj . meta . TIME ) . to . equal ( 'futuro' )
134
+ expect ( resultObj . types ) . not . to . include ( 'MOD' )
135
+ expect ( resultObj . types ) . to . include ( 'ADV' )
136
+ } )
137
+ } )
138
+
139
+ //MISSING SOLVE MISC BUT MUST DEFINITIVES MISC ARE NOT DONE YET
0 commit comments