Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
gsper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tools
gsper
Commits
d59a71cc
Commit
d59a71cc
authored
7 years ago
by
Millicent Billette
Browse files
Options
Downloads
Patches
Plain Diff
FEAT: advensed dictionaryBuilder finished exept escape chr
parent
cddd1d65
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
public/dictionaryBuilder.js
+3
-11
3 additions, 11 deletions
public/dictionaryBuilder.js
public/dictionaryBuilder.test.js
+3
-3
3 additions, 3 deletions
public/dictionaryBuilder.test.js
with
6 additions
and
14 deletions
public/dictionaryBuilder.js
+
3
−
11
View file @
d59a71cc
...
@@ -46,20 +46,12 @@ function regLikeVariants(theString,allStrings) {
...
@@ -46,20 +46,12 @@ function regLikeVariants(theString,allStrings) {
return
`(
${
res
.
join
(
'
|
'
)}
)`
;
return
`(
${
res
.
join
(
'
|
'
)}
)`
;
};
};
theString
=
theString
.
replace
(
/
([^\)])
{
([^
}
]
+
)
}/g
,
qtyApply
);
theString
=
theString
.
replace
(
/
([^\)])
{
([^
}
]
+
)
}/g
,
qtyApply
);
theString
=
theString
.
replace
(
/^
(
.*
)\(([^
)
]
*
)\)\{([^
}
]
+
)\}(
.*
)
$/
,(
all
,
before
,
choices
,
qty
,
after
)
=>
before
+
qtyApply
(
''
,
`(
${
choices
}
)`
,
qty
)
+
after
);
// handle (|)
// handle (|)
let
multiString
=
theString
.
replace
(
/^
(
.*
)\(([^
)
]
*
)\)(
.*
)
$/
,(
all
,
before
,
choices
,
after
)
=>
choices
.
split
(
'
|
'
).
map
(
c
=>
{
let
multiString
=
theString
.
replace
(
/^
(
.*
)\(([^
)
]
*
)\)(
.*
)
$/
,(
all
,
before
,
choices
,
after
)
=>
choices
.
split
(
'
|
'
).
map
(
c
=>
before
+
c
+
after
).
join
(
'
=$##$=
'
)
).
split
(
'
=$##$=
'
);
if
(
after
.
indexOf
(
'
{
'
)
!==
0
)
return
before
+
c
+
after
;
else
{
console
.
log
(
c
);
const
end
=
after
.
slice
(
1
).
split
(
'
}
'
);
const
qty
=
end
.
shift
();
const
afterQty
=
end
.
join
(
'
}
'
);
return
before
+
qtyApply
(
''
,
c
,
qty
)
+
afterQty
;
}
}).
join
(
'
=$##$=
'
)
).
split
(
'
=$##$=
'
);
console
.
log
(
multiString
);
console
.
log
(
multiString
);
multiString
=
[].
concat
(...
multiString
.
map
(
str
=>
(
str
.
indexOf
(
'
(
'
)
!==
-
1
)?
regLikeVariants
(
str
,
allStrings
):
str
));
multiString
=
[].
concat
(...
multiString
.
map
(
str
=>
(
str
.
indexOf
(
'
(
'
)
!==
-
1
)?
regLikeVariants
(
str
,
allStrings
):
str
));
return
multiString
;
return
dedup
(
multiString
)
;
}
}
This diff is collapsed.
Click to expand it.
public/dictionaryBuilder.test.js
+
3
−
3
View file @
d59a71cc
...
@@ -36,10 +36,10 @@ describe('dictionaryBuilder', () => {
...
@@ -36,10 +36,10 @@ describe('dictionaryBuilder', () => {
expect
(
app
.
regLikeVariants
(
"
b{3,5}
"
)).
toEqual
([
"
bbb
"
,
"
bbbb
"
,
"
bbbbb
"
]);
expect
(
app
.
regLikeVariants
(
"
b{3,5}
"
)).
toEqual
([
"
bbb
"
,
"
bbbb
"
,
"
bbbbb
"
]);
});
});
it
(
'
regLikeVariants handle (string){qty}
'
,
()
=>
{
it
(
'
regLikeVariants handle (string){qty}
'
,
()
=>
{
expect
(
app
.
regLikeVariants
(
"
(toto|tata){0,2}
"
)).
toEqual
([
""
,
"
toto
"
,
"
tata
"
,
"
totototo
"
,
"
toto
tata
"
,
"
tatatoto
"
,
"
tatatata
"
]);
expect
(
app
.
regLikeVariants
(
"
(toto|tata){0,2}
"
)).
toEqual
([
""
,
"
toto
"
,
"
totototo
"
,
"
tata
"
,
"
tatatoto
"
,
"
tototata
"
,
"
tatatata
"
]);
});
});
x
it
(
'
regLikeVariants handle nested ([a-f]|<ref>){0,1}
'
,
()
=>
{
it
(
'
regLikeVariants handle nested ([a-f]|<ref>){0,1}
'
,
()
=>
{
expect
(
app
.
regLikeVariants
(
"
autre mot
"
)).
toEqual
([
"
autre mot
"
,
"
Autre Mot
"
,
"
AUTRE MOT
"
]);
expect
(
app
.
regLikeVariants
(
"
([B-D]|<ref>){0,1}
"
,[
"
ref::plop
"
])).
toEqual
([
""
,
"
B
"
,
"
plop
"
,
"
C
"
,
"
D
"
]);
});
});
xit
(
'
regLikeVariants handle plop:
\\
:
'
,
()
=>
{
xit
(
'
regLikeVariants handle plop:
\\
:
'
,
()
=>
{
expect
(
app
.
regLikeVariants
(
"
autre mot
"
)).
toEqual
([
"
autre mot
"
,
"
Autre Mot
"
,
"
AUTRE MOT
"
]);
expect
(
app
.
regLikeVariants
(
"
autre mot
"
)).
toEqual
([
"
autre mot
"
,
"
Autre Mot
"
,
"
AUTRE MOT
"
]);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment