@@ -2484,7 +2484,7 @@ export const Cont = resume => ({
24842484███████████████████████████████████████████████████████████████████████████████*/
24852485
24862486
2487- Cont . forever = o => Cont . chain ( o ) ( _ => Cont . forever ( o ) ) ;
2487+ Cont . fromPromise = px => Cont ( ( res , rej ) => px . then ( res ) . catch ( rej ) ) ;
24882488
24892489
24902490Cont . reject = e => Cont ( ( _res , rej ) => {
@@ -2493,11 +2493,10 @@ Cont.reject = e => Cont((_res, rej) => {
24932493} ) ;
24942494
24952495
2496- Cont . validate = p => o => Cont . chain ( o ) ( x =>
2497- p ( x ) ? Cont . of ( x ) : Cont . reject ( x ) ) ;
2496+ Cont . forever = o => Cont . chain ( o ) ( _ => Cont . forever ( o ) ) ;
24982497
24992498
2500- Cont . fromPromise = px => Cont ( ( res , rej ) => px . then ( res ) . catch ( rej ) ) ;
2499+ Cont . never = Cont ( ( res , rej ) => null ) ;
25012500
25022501
25032502Cont . tryCatch = f => o => Cont ( ( res , rej ) => o . resume ( id , e => res ( f ( e ) ) ) ) ;
@@ -2506,6 +2505,10 @@ Cont.tryCatch = f => o => Cont((res, rej) => o.resume(id, e => res(f(e))));
25062505Cont . tryThrow = o => Cont ( ( res , rej ) => o . resume ( id , e => { throw e } ) ) ;
25072506
25082507
2508+ Cont . validate = p => o => Cont . chain ( o ) ( x =>
2509+ p ( x ) ? Cont . of ( x ) : Cont . reject ( x ) ) ;
2510+
2511+
25092512// final function guaranteed to be called regardless of success or failure
25102513
25112514Cont . finalize = finalizer => o => Cont ( ( res , rej ) =>
@@ -2699,15 +2702,23 @@ Cont.Parallel.andRace = o => p => Cont((res, rej) => {
26992702} ) ;
27002703
27012704
2702- Cont . Parallel . all = xs => xs . reduce ( ( acc , o ) =>
2705+ Cont . Parallel . All = { } ;
2706+
2707+
2708+ Cont . Parallel . All . arr = xs => xs . reduce ( ( acc , o ) =>
27032709 Cont . map ( pair => pair . flat ( ) ) ( Cont . Parallel . and ( acc ) ( o ) ) , Cont . of ( [ ] ) ) ;
27042710
27052711
2706- Cont . Parallel . never = Cont ( ( res , rej ) => null ) ;
2712+ Cont . Parallel . All . obj = o => Object . entries ( o ) . reduce ( ( acc , [ k , v ] ) => {
2713+ return Cont . map ( pair => {
2714+ pair [ 0 ] [ k ] = pair [ 1 ] ;
2715+ return acc ;
2716+ } ) ( Cont . Parallel . and ( acc ) ( v ) ) ;
2717+ } , Cont . of ( { } ) ) ;
27072718
27082719
2709- Cont . Parallel . race = xs => xs . reduce ( ( acc , o ) =>
2710- Cont . Parallel . andRace ( acc ) ( o ) , Cont . Parallel . never ) ;
2720+ Cont . Parallel . All . race = xs => xs . reduce ( ( acc , o ) =>
2721+ Cont . Parallel . andRace ( acc ) ( o ) , Cont . never ) ;
27112722
27122723
27132724/*█████████████████████████████████████████████████████████████████████████████
@@ -6782,9 +6793,9 @@ R.splitNonAlnumTrans = R.splitTrans("v") (
67826793 R . classes . crnl . sep ) ;
67836794
67846795
6785- // split almost all
6796+ // split all but letter casing transitions
67866797
6787- R . splitAlmostAllTrans = R . splitTrans ( "v" ) (
6798+ R . splitAllTrans = R . splitTrans ( "v" ) (
67886799 R . classes . num . sep ,
67896800 R . classes . punct . sep ,
67906801 R . classes . sym . sep ,
@@ -6795,7 +6806,7 @@ R.splitAlmostAllTrans = R.splitTrans("v") (
67956806
67966807// split all
67976808
6798- R . splitAllTrans = R . splitTrans ( "v" ) (
6809+ R . splitAllTrans_ = R . splitTrans ( "v" ) (
67996810 R . classes . num . sep ,
68006811 R . classes . punct . sep ,
68016812 R . classes . sym . sep ,
@@ -7222,14 +7233,17 @@ R.General.generalize = (...classes) => s => {
72227233} ;
72237234
72247235
7225- //█████ Context ██████████ █████████████████████████████████████████████████████
7236+ //█████ Contextualization █████████████████████████████████████████████████████
72267237
72277238
72287239/* Remerge tokens that form meaningful compositions. Some of these contexts are
72297240localized, i.e. require a list of locales that should be considered. Meant to
72307241be used after splitting strings into tokens. */
72317242
72327243
7244+ // TODO: revise + predefined composition
7245+
7246+
72337247R . Context = { } ;
72347248
72357249
@@ -7306,9 +7320,9 @@ R.Context.hyphen = tokens => {
73067320} ;
73077321
73087322
7309- // takes a set of abbreviations
7323+ // assume that every occurrence of a period might be part of an abbreviation
73107324
7311- R . Context . period = abbrs => tokens => {
7325+ R . Context . period = tokens => {
73127326 const xs = [ ] ;
73137327
73147328 for ( let i = 0 ; i < tokens . length ; i ++ ) {
@@ -7338,12 +7352,11 @@ R.Context.period = abbrs => tokens => {
73387352 && / * / . test ( next ) )
73397353 xs [ last ] += curr ;
73407354
7341- // eg.
7355+ // eg. (might indicate an abbreviation or end of sentence)
73427356
73437357 else if ( / * / . test ( prev2 )
73447358 && / \p{ L} / v. test ( prev )
7345- && / * / . test ( next )
7346- && abbrs . has ( prev + curr ) )
7359+ && / * / . test ( next ) )
73477360 xs [ last ] += curr ;
73487361
73497362 // 0.1
@@ -7946,6 +7959,8 @@ R.Context.amount = tokens => {
79467959} ;
79477960
79487961
7962+ // composed abbreviation
7963+
79497964R . Context . abbrs = tokens => {
79507965 const xs = [ ] ;
79517966
@@ -8008,7 +8023,28 @@ R.Context.protocol = tokens => {
80088023} ;
80098024
80108025
8011- // TODO: predefined composition
8026+ R . Context . pipeAll = pipes (
8027+ R . Context . hyphen ,
8028+ R . Context . apo ,
8029+ R . Context . period ,
8030+ R . Context . slash ,
8031+ R . Context . comma ,
8032+ R . Context . colon ,
8033+ R . Context . quota ,
8034+ R . Context . percent ,
8035+ R . Context . ampersand ,
8036+ R . Context . currency ,
8037+ R . Context . plus ,
8038+ R . Context . at ,
8039+ R . Context . asterisk ,
8040+ R . Context . underscore ,
8041+ R . Context . para ,
8042+ R . Context . degree ,
8043+ R . Context . ellipsis ,
8044+ R . Context . amount ,
8045+ R . Context . abbrs ,
8046+ R . Context . protocol
8047+ ) ;
80128048
80138049
80148050/*█████████████████████████████████████████████████████████████████████████████
@@ -11205,6 +11241,31 @@ S.Word.splitCompoundWord = ({locale, pos, corpus}) => queryWord => {
1120511241} ;
1120611242
1120711243
11244+ // for the time being, ignore imperative case
11245+
11246+ S . Word . parseSentType = s => {
11247+ const last = s [ s . length - 1 ] ;
11248+ let type = "" ;
11249+
11250+ if ( last === "." ) type = "declarative" ;
11251+ else if ( / ! { 1 , } $ / . test ( s ) ) type = "exclamatory" ;
11252+ else if ( / [ ? ! ] { 2 , } $ / . test ( s ) ) type = "interrogative" ;
11253+ else if ( last === "?" ) type = "interrogative" ;
11254+
11255+ else return Parser . Invalid ( {
11256+ value : s ,
11257+ kind : "sentence type" ,
11258+ reason : "partial sentence" ,
11259+ } ) ;
11260+
11261+ return Parser . Valid ( {
11262+ value : s ,
11263+ kind : "sentence type" ,
11264+ type,
11265+ } ) ;
11266+ } ;
11267+
11268+
1120811269//█████ Lemmatization █████████████████████████████████████████████████████████
1120911270
1121011271
@@ -11311,6 +11372,7 @@ S.Word.Lemma.adj = locale => adj => {
1131111372
1131211373
1131311374S . Word . Lemma . adv = locale => adv => {
11375+ const candidates = [ adv ] ;
1131411376
1131511377 // only comparative/superlative
1131611378
@@ -11869,61 +11931,6 @@ export class Tree {
1186911931
1187011932export const Alg = { } ;
1187111933
11872- /* TODO
11873-
11874- 1. **Vectors:**
11875- 2. **Matrices:**
11876- 3. **Vector Spaces:**
11877- 4. **Linear Independence & Span:**
11878- 5. **Basis:**
11879- 6. **Matrix Multiplication (and Vector-Matrix, Matrix-Vector):**
11880- 7. **Element-wise Operations (Hadamard Product):**
11881- 8. **Transpose:**
11882- 9. **Dot Product (Inner Product):**
11883- 10. **Normed Vector Spaces (Norms):**
11884- **L1 Norm (Manhattan):** Used in LASSO regularization for sparsity, feature selection.
11885- **L2 Norm (Euclidean):** Used in Ridge regularization, standard distance metric, loss functions (MSE).
11886- **Frobenius Norm:** Matrix norm used in regularization, matrix factorization objectives.
11887- 11. **Inner Product Spaces:**
11888- **Projections:** Projecting data onto lower-dimensional subspaces (PCA, Linear Regression).
11889- **Orthogonality:** Finding uncorrelated bases (PCA), simplifying calculations. Used in QR decomposition, Gram-Schmidt.
11890- **Kernel Methods (SVMs):** Kernels often implicitly compute inner products in high-dimensional spaces.
11891- 12. **Orthogonality / Orthonormal Bases:**
11892- 13. **Systems of Linear Equations (Ax = b):**
11893- 14. **Linear Least Squares:**
11894- 15. **Matrix Inverse:**
11895- 16. **Pseudo-inverse (Moore-Penrose):**
11896- 17. **Eigenvalue Decomposition (EVD) (for square matrices):**
11897- **Principal Component Analysis (PCA):** Eigenvalues/eigenvectors of the covariance matrix reveal directions of maximum variance (principal components).
11898- **Eigenvalues:** Scalars representing scaling factors.
11899- **Eigenvectors:** Vectors remaining in the same direction after transformation (scaled by eigenvalue).
11900- **Eigenspace:** The space spanned by eigenvectors corresponding to the same eigenvalue.
11901- 18. **Singular Value Decomposition (SVD) (for any matrix):**
11902- **PCA Implementation:** Can be computed via SVD of the data matrix.
11903- **Dimensionality Reduction / Matrix Approximation:** Low-rank approximation by keeping top singular values/vectors.
11904- **Calculating Pseudo-inverse.**
11905- **Latent Semantic Analysis (LSA)** in NLP.
11906- **Recommender systems (matrix factorization).
11907- 19. **QR Decomposition / Factorization:**
11908- **Gram–Schmidt Process:** A method to compute QR, conceptually important for understanding orthogonalization (though modified versions are often used for stability).
11909- **Householder Transformation:** A numerically stable method (reflections) used to compute QR decomposition.
11910- 20. **Cholesky Decomposition (for positive definite symmetric matrices):**
11911- 21. **Positive Definite / Semidefinite Matrices:**
11912- 22. **Tensors:**
11913- 23. **Tensor Algebra:**
11914- 24. **Outer Product:**
11915- 25. **Woodbury Matrix Identity:**
11916-
11917- **Concepts Less Directly Emphasized in Typical ML Applications:**
11918-
11919- ignore:
11920-
11921- * Matrix Equivalence/Congruence/Similarity/Consimilarity
11922- * Row Echelon Form / Elementary Row Operations
11923- * Determinant
11924- * Topological Vector Space, Pseudo-Euclidean Space, Orientation, Symplectic Structure
11925- */
11926-
1192711934
1192811935/*█████████████████████████████████████████████████████████████████████████████
1192911936█████████████████████████████████ COMBINATORS █████████████████████████████████
@@ -12051,7 +12058,7 @@ Alg.avgFracs = (o, p) => {
1205112058} ;
1205212059
1205312060
12054- //█████ Model Growth ██████ ████████████████████████████████████████████████████
12061+ //█████ Exponential Growth ████████████████████████████████████████████████████
1205512062
1205612063
1205712064/* Caluclate exponential growth. Max input is used to normalize the input range.
0 commit comments