Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
checkSlops example
public
function
interpret
(
string
$word
, Context
$context
)
: SearchPattern
{
$tokens
=
$this
->tokenizer->
tokenize
(
$word
)
;
$tokens
=
$this
->tokenFilter->
filter
(
$tokens
,
$context
)
;
if
(
empty
(
$tokens
)
)
{
return
new
SearchPattern
(
new
SearchTerm
(
''
)
)
;
}
$tokenSlops
=
$this
->
slop
(
$tokens
)
;
if
(
!
$this
->
checkSlops
(
array_values
(
$tokenSlops
)
)
)
{
return
new
SearchPattern
(
new
SearchTerm
(
$word
)
)
;
}
$tokenKeywords
=
$this
->
fetchKeywords
(
$context
,
$tokenSlops
)
;
$matches
=
array_fill
(
0, \
count
(
$tokens
)
,
[
]
)
;
$matches
=
$this
->
groupTokenKeywords
(
$matches
,
$tokenKeywords
)
;
$combines
=
$this
->
permute
(
$tokens
)
;
foreach
(
$combines
as
$token
)
{
$tokens
[
]
=
$token
;
}