Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
43d502ca
Commit
43d502ca
authored
Sep 10, 2012
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated spellcheck responseparser to support PHPS responses
parent
33c31ccd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
20 deletions
+18
-20
library/Solarium/QueryType/Select/ResponseParser/Component/Spellcheck.php
.../QueryType/Select/ResponseParser/Component/Spellcheck.php
+18
-20
No files found.
library/Solarium/QueryType/Select/ResponseParser/Component/Spellcheck.php
View file @
43d502ca
...
...
@@ -40,11 +40,12 @@ namespace Solarium\QueryType\Select\ResponseParser\Component;
use
Solarium\QueryType\Select\Query\Query
;
use
Solarium\QueryType\Select\Query\Component\Spellcheck
as
SpellcheckComponent
;
use
Solarium\QueryType\Select\Result\Spellcheck
as
SpellcheckResult
;
use
Solarium\Core\Query\ResponseParser
as
ResponseParserAbstract
;
/**
* Parse select component Highlighting result from the data
*/
class
Spellcheck
class
Spellcheck
extends
ResponseParserAbstract
{
/**
...
...
@@ -65,28 +66,26 @@ class Spellcheck
)
{
$spellcheckResults
=
$data
[
'spellcheck'
][
'suggestions'
];
if
(
$query
->
getResponseWriter
()
==
$query
::
WT_JSON
)
{
$spellcheckResults
=
$this
->
convertToKeyValueArray
(
$spellcheckResults
);
}
$suggestions
=
array
();
$correctlySpelled
=
null
;
$collations
=
array
();
$index
=
0
;
while
(
isset
(
$spellcheckResults
[
$index
])
&&
isset
(
$spellcheckResults
[
$index
+
1
]))
{
$key
=
$spellcheckResults
[
$index
];
$value
=
$spellcheckResults
[
$index
+
1
];
foreach
(
$spellcheckResults
as
$key
=>
$value
)
{
switch
(
$key
)
{
case
'correctlySpelled'
:
$correctlySpelled
=
$value
;
break
;
case
'collation'
:
$collations
[]
=
$this
->
parseCollation
(
$value
);
$collations
[]
=
$this
->
parseCollation
(
$
query
,
$
value
);
break
;
default
:
$suggestions
[]
=
$this
->
parseSuggestion
(
$key
,
$value
);
}
$index
+=
2
;
}
return
new
SpellcheckResult\Result
(
$suggestions
,
$collations
,
$correctlySpelled
);
...
...
@@ -98,10 +97,11 @@ class Spellcheck
/**
* Parse collation data into a result object
*
* @param Query $queryObject
* @param array $values
* @return SpellcheckResult\Collation
*/
protected
function
parseCollation
(
$values
)
protected
function
parseCollation
(
$
queryObject
,
$
values
)
{
if
(
is_string
(
$values
))
{
...
...
@@ -113,11 +113,11 @@ class Spellcheck
$hits
=
null
;
$correctionResult
=
null
;
$index
=
0
;
while
(
isset
(
$values
[
$index
])
&&
isset
(
$values
[
$index
+
1
]))
{
$key
=
$values
[
$index
];
$value
=
$values
[
$index
+
1
];
if
(
$queryObject
->
getResponseWriter
()
==
$queryObject
::
WT_JSON
)
{
$values
=
$this
->
convertToKeyValueArray
(
$values
);
}
foreach
(
$values
as
$key
=>
$value
)
{
switch
(
$key
)
{
case
'collationQuery'
:
$query
=
$value
;
...
...
@@ -129,19 +129,17 @@ class Spellcheck
$correctionResult
=
$value
;
break
;
}
$index
+=
2
;
}
$corrections
=
array
();
if
(
$correctionResult
!==
null
)
{
$index
=
0
;
while
(
isset
(
$correctionResult
[
$index
])
&&
isset
(
$correctionResult
[
$index
+
1
]))
{
$input
=
$correctionResult
[
$index
];
$correction
=
$correctionResult
[
$index
+
1
];
if
(
$queryObject
->
getResponseWriter
()
==
$queryObject
::
WT_JSON
)
{
$correctionResult
=
$this
->
convertToKeyValueArray
(
$correctionResult
);
}
foreach
(
$correctionResult
as
$input
=>
$correction
)
{
$corrections
[
$input
]
=
$correction
;
$index
+=
2
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment