sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function processFuzzyProximityModifier($parameter = null)
{
$this->_proximityQuery = true;
if ($parameter !== null) {
$this->_wordsDistance = $parameter;
}
} | Process modifier ('~')
@param mixed $parameter | entailment |
public function getQuery($encoding)
{
/**
* Zend_Search_Lucene_Search_Query_Preprocessing_Phrase
*/
include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Phrase.php';
$query = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase(
$this->_phrase,
$encoding,... | Transform entry to a subquery
@param string $encoding
@return Zend_Search_Lucene_Search_Query
@throws Zend_Search_Lucene_Search_QueryParserException | entailment |
protected function createGuzzleRequest($method, $uri, array $extraParameters)
{
$extraParameters = $this->mergeGuzzleRequestExtraParams($extraParameters);
return new Request(
strtoupper($method),
$uri,
$extraParameters['headers'],
$extraParameters['bo... | @param string $method
@param string $uri
@param array $extraParameters
@return Request | entailment |
protected function sendRequest($method, $uri, array $extraParameters = array(), array $clientOptions = array())
{
$request = $this->createGuzzleRequest($method, $uri, $extraParameters);
$client = $this->getGuzzleClientIntance();
return $client->send($request, $clientOptions);
} | @param string $method
@param string $uri
@param array $extraParameters
@param array $clientOptions
@return Response
@throws \LogicException | entailment |
protected function setOptionsCurlUpload($curlResource, array $options)
{
foreach ($options as $key => $value) {
curl_setopt($curlResource, $key, $value);
}
return $curlResource;
} | @param resource $curlResource
@param array $options
@return bool | entailment |
protected function getOptionsCurlUpload($uri, array $postFields)
{
return array(
CURLOPT_HEADER => 0,
CURLOPT_VERBOSE => 0,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $uri,
CURLOPT_POST => true,
C... | @param string $uri
@param array $postFields
@return array | entailment |
protected function sendFile($uri, array $postFields)
{
$curlResource = $this->initCurlUpload();
$curlOptions = $this->getOptionsCurlUpload($uri, $postFields);
$curlResource = $this->setOptionsCurlUpload($curlResource, $curlOptions);
return $this->execCurlUpload($curlResource);
... | @param string $uri
@param array $postFields
@return string|bool | entailment |
private function _translateInput($char)
{
if (strpos(self::QUERY_WHITE_SPACE_CHARS, $char) !== false) { return self::IN_WHITE_SPACE;
} else if (strpos(self::QUERY_SYNT_CHARS, $char) !== false) { return self::IN_SYNT_CHAR;
} else if (strpos(self::QUERY_MUTABLE_CHARS, ... | Translate input char to an input symbol of state machine
@param string $char
@return integer | entailment |
public function tokenize($inputString, $encoding)
{
$this->reset();
$this->_lexemes = array();
$this->_queryString = array();
if (PHP_OS == 'AIX' && $encoding == '') {
$encoding = 'ISO8859-1';
}
$strLength = iconv_strlen($inputString, $encoding);
... | This method is used to tokenize query string into lexemes
@param string $inputString
@param string $encoding
@return array
@throws Zend_Search_Lucene_Search_QueryParserException | entailment |
public function addQuerySyntaxLexeme()
{
$lexeme = $this->_queryString[$this->_queryStringPosition];
// Process two char lexemes
if (strpos(self::QUERY_DOUBLECHARLEXEME_CHARS, $lexeme) !== false) {
// increase current position in a query string
$this->_queryStringPos... | Add query syntax lexeme
@throws Zend_Search_Lucene_Search_QueryParserException | entailment |
public function addLexemeModifier()
{
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_SYNTAX_ELEMENT,
$this->_queryString[$this->_queryStringPosition],
$this->_queryStringPosition
);
} | Add lexeme modifier | entailment |
public function addLexeme()
{
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_WORD,
$this->_currentLexeme,
$this->_queryStringPosition - 1
);
$this->_currentLexeme = '';
} | Add lexeme | entailment |
public function addQuotedLexeme()
{
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_PHRASE,
$this->_currentLexeme,
$this->_queryStringPosition
);
$this->_currentLexeme = '';
} | Add quoted lexeme | entailment |
public function addNumberLexeme()
{
$this->_lexemes[] = new Zend_Search_Lucene_Search_QueryToken(
Zend_Search_Lucene_Search_QueryToken::TC_NUMBER,
$this->_currentLexeme,
$this->_queryStringPosition - 1
);
$this->_currentLexeme = '';
} | Add number lexeme | entailment |
public function send($recipient, $body, $originator = '')
{
if (null === $this->accessToken) {
throw new Exception\InvalidCredentialsException('No API credentials provided');
}
$params = array(
'messageContent' => $body,
'recipientAddressList' => ... | {@inheritDoc} | entailment |
protected function executeQuery($url, array $data = array(), array $extra_result_data = array())
{
$headers = array(
sprintf('Authorization: Bearer %s', $this->accessToken),
'Content-Type: application/json',
'Accept: application/json'
);
// Issue ... | Issues the actual HTTP query.
@param $url
@param array $data
@param array $extra_result_data
@return array | entailment |
protected function parseResults($result, array $extra_result_data = array())
{
$data = json_decode($result, true);
$smsData = array();
// There was an error
if (empty($data['transferId']) || empty($data['statusCode'])) {
return array_merge($this->getDefaults(), $e... | Parses the data returned by the API.
@param string $result The raw result string.
@return array | entailment |
public static function getPrefix($str, $length)
{
$prefixBytes = 0;
$prefixChars = 0;
while ($prefixBytes < strlen($str) && $prefixChars < $length) {
$charBytes = 1;
if ((ord($str[$prefixBytes]) & 0xC0) == 0xC0) {
$charBytes++;
if (or... | Get term prefix
@param string $str
@param integer $length
@return string | entailment |
public static function getLength($str)
{
$bytes = 0;
$chars = 0;
while ($bytes < strlen($str)) {
$charBytes = 1;
if ((ord($str[$bytes]) & 0xC0) == 0xC0) {
$charBytes++;
if (ord($str[$bytes]) & 0x20 ) {
$charBytes++;
... | Get UTF-8 string length
@param string $str
@return string | entailment |
public function rewrite(Zend_Search_Lucene_Interface $index)
{
// Allow to use wildcards within phrases
// They are either removed by text analyzer or used as a part of keyword for keyword fields
//
// if (strpos($this->_phrase, '?') !== false || strpos($this->_phrase, '*') !=... | Re-write query into primitive queries in the context of specified index
@param Zend_Search_Lucene_Interface $index
@return Zend_Search_Lucene_Search_Query | entailment |
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
/**
* Skip fields detection. We don't need it, since we expect all fields presented in the HTML body and don't differentiate them
*/
/**
* Skip exact term matching recognition, keyword fields hig... | Query specific matches highlighting
@param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) | entailment |
protected function isPureArray(array $array ) {
$i=0;
foreach($array as $k=>$v) {
if ( $k !== $i ) {
return false;
}
$i++;
}
return true;
} | Checks wether the provided array has string keys and if it's not sparse.
@param array $arr
@return bool | entailment |
public function termDocs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
return $this->_index->termDocs($term, $docsFilter);
} | Returns IDs of all the documents containing term.
@param Zend_Search_Lucene_Index_Term $term
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return array | entailment |
public function termDocsFilter(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
return $this->_index->termDocsFilter($term, $docsFilter);
} | Returns documents filter for all documents containing term.
It performs the same operation as termDocs, but return result as
Zend_Search_Lucene_Index_DocsFilter object
@param Zend_Search_Lucene_Index_Term $term
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return Zend_Search_Lucene_Index_D... | entailment |
public function termFreqs(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
return $this->_index->termFreqs($term, $docsFilter);
} | Returns an array of all term freqs.
Return array structure: array( docId => freq, ...)
@param Zend_Search_Lucene_Index_Term $term
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return integer | entailment |
public function termPositions(Zend_Search_Lucene_Index_Term $term, $docsFilter = null)
{
return $this->_index->termPositions($term, $docsFilter);
} | Returns an array of all term positions in the documents.
Return array structure: array( docId => array( pos1, pos2, ...), ...)
@param Zend_Search_Lucene_Index_Term $term
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter
@return array | entailment |
public function flush(SmsSenderInterface $sender)
{
$results = array();
$errors = array();
foreach ($this->messages as $message) {
try {
$results[] = $sender->send($message['recipient'], $message['body'], $message['originator']);
} catch (Exception $e... | {@inheritdoc} | entailment |
public function getContent($url, $method = 'GET', array $headers = array(), $data = array())
{
if (!function_exists('curl_init')) {
throw new \RuntimeException('cURL has to be enabled.');
}
$c = curl_init();
// build the request...
curl_setopt($c, CURLOPT_RETURN... | {@inheritDoc} | entailment |
protected function getUri($module, $method, $responseFormat, array $requestParameters = array())
{
if (!$this->hasMethod($method)) {
throw new \InvalidArgumentException(sprintf('The method %s is not registered', $method));
}
if (!$this->hasResponseFormat($responseFormat)) {
... | @param string $module
@param string $method
@param string $responseFormat
@param array $requestParameters
@return string
@throws \InvalidArgumentException | entailment |
protected function getUnserializedData(Response $response, $responseFormat)
{
return UnserializerBuilder::create($responseFormat)->unserialize(
$response->getBody()->getContents()
);
} | @param Response $response
@param string $responseFormat
@return array | entailment |
public function run($request)
{
$this->start();
$registered = Config::inst()->get('DocumentationManifest', 'register_entities');
foreach ($registered as $details) {
// validate the details provided through the YAML configuration
$required = array('Path', 'Title');
... | Validate all source files
@param SS_HTTPRequest $request
@throws Exception | entailment |
public function addTerm(Zend_Search_Lucene_Index_Term $term, $position = null)
{
if ((count($this->_terms) != 0)&&(end($this->_terms)->field != $term->field)) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception(
'All phrase terms... | Adds a term to the end of the query phrase.
The relative position of the term is specified explicitly or the one immediately
after the last term added.
@param Zend_Search_Lucene_Index_Term $term
@param integer $position | entailment |
public function rewrite(Zend_Search_Lucene_Interface $index)
{
if (count($this->_terms) == 0) {
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Search_Lucene_Search_Query_Empty();
} else if ($this->_terms[0]->field !== null) {
return $thi... | Re-write query into primitive queries in the context of specified index
@param Zend_Search_Lucene_Interface $index
@return Zend_Search_Lucene_Search_Query | entailment |
public function optimize(Zend_Search_Lucene_Interface $index)
{
// Check, that index contains all phrase terms
foreach ($this->_terms as $term) {
if (!$index->hasTerm($term)) {
include_once 'Zend/Search/Lucene/Search/Query/Empty.php';
return new Zend_Searc... | Optimize query in the context of specified index
@param Zend_Search_Lucene_Interface $index
@return Zend_Search_Lucene_Search_Query | entailment |
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
include_once 'Zend/Search/Lucene/Search/Weight/Phrase.php';
$this->_weight = new Zend_Search_Lucene_Search_Weight_Phrase($this, $reader);
return $this->_weight;
} | Constructs an appropriate Weight implementation for this query.
@param Zend_Search_Lucene_Interface $reader
@return Zend_Search_Lucene_Search_Weight | entailment |
public function _exactPhraseFreq($docId)
{
$freq = 0;
// Term Id with lowest cardinality
$lowCardTermId = null;
// Calculate $lowCardTermId
foreach ($this->_terms as $termId => $term) {
if ($lowCardTermId === null
|| count($this->_termsPositions... | Score calculator for exact phrase queries (terms sequence is fixed)
@param integer $docId
@return float | entailment |
public function _sloppyPhraseFreq($docId, Zend_Search_Lucene_Interface $reader)
{
$freq = 0;
$phraseQueue = array();
$phraseQueue[0] = array(); // empty phrase
$lastTerm = null;
// Walk through the terms to create phrases.
foreach ($this->_terms as $termId => $term)... | Score calculator for sloppy phrase queries (terms sequence is fixed)
@param integer $docId
@param Zend_Search_Lucene_Interface $reader
@return float | entailment |
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
$this->_resVector = null;
if (count($this->_terms) == 0) {
$this->_resVector = array();
}
$resVectors = array();
$resVectorsSizes = array();
$resVectorsIds = array... | Execute query in context of index reader
It also initializes necessary internal structures
@param Zend_Search_Lucene_Interface $reader
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter | entailment |
public function score($docId, Zend_Search_Lucene_Interface $reader)
{
if (isset($this->_resVector[$docId])) {
if ($this->_slop == 0) {
$freq = $this->_exactPhraseFreq($docId);
} else {
$freq = $this->_sloppyPhraseFreq($docId, $reader);
}
... | Score specified document
@param integer $docId
@param Zend_Search_Lucene_Interface $reader
@return float | entailment |
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
$words = array();
foreach ($this->_terms as $term) {
$words[] = $term->text;
}
$highlighter->highlight($words);
} | Query specific matches highlighting
@param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) | entailment |
public function sumOfSquaredWeights()
{
$sum = 0;
foreach ($this->_weights as $weight) {
// sum sub weights
$sum += $weight->sumOfSquaredWeights();
}
// boost each sub-weight
$sum *= $this->_query->getBoost() * $this->_query->getBoost();
// c... | The sum of squared weights of contained query clauses.
@return float | entailment |
public function normalize($queryNorm)
{
// incorporate boost
$queryNorm *= $this->_query->getBoost();
foreach ($this->_weights as $weight) {
$weight->normalize($queryNorm);
}
} | Assigns the query normalization factor to this.
@param float $queryNorm | entailment |
public static function add($map = array())
{
if (ArrayLib::is_associative($map)) {
self::$mapping = array_merge(self::$mapping, $map);
} else {
user_error("DocumentationPermalinks::add() requires an associative array", E_USER_ERROR);
}
} | Add a mapping of nice short permalinks to a full long path
<code>
DocumentationPermalinks::add(array(
'debugging' => 'current/en/sapphire/topics/debugging'
));
</code>
Do not need to include the language or the version current as it
will add it based off the language or version in the session
@param array | entailment |
public static function map($url)
{
return (isset(self::$mapping[$url])) ? self::$mapping[$url] : false;
} | Return the location for a given short value.
@return string|false | entailment |
public function sendRequest($servicePath,$data) {
// We're using the FLEX Messaging framework
if($this->encoding & SabreAMF_Const::FLEXMSG) {
// Setting up the message
$message = new SabreAMF_AMF3_RemotingMessage();
$message->body = $... | sendRequest
sendRequest sends the request to the server. It expects the servicepath and methodname, and the parameters of the methodcall
@param string $servicePath The servicepath (e.g.: myservice.mymethod)
@param array $data The parameters you want to send
@return mixed | entailment |
public function addHeader($name,$required,$data) {
$this->amfRequest->addHeader(array('name'=>$name,'required'=>$required==true,'data'=>$data));
} | addHeader
Add a header to the client request
@param string $name
@param bool $required
@param mixed $data
@return void | entailment |
private function parseHeaders() {
foreach($this->amfResponse->getHeaders() as $header) {
switch($header['name']) {
case 'ReplaceGatewayUrl' :
if (is_string($header['data'])) {
$this->endPoint = $header['data'];
... | parseHeaders
@return void | entailment |
public function setEncoding($encoding) {
$this->encoding = $encoding;
$this->amfRequest->setEncoding($encoding & SabreAMF_Const::AMF3);
} | Change the AMF encoding (0 or 3)
@param int $encoding
@return void | entailment |
public function process(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
$bundleContainer = $container->getDefinition('atoum.configuration.bundle.container');
$configuration = $container->getParameterBag()->resolveValue($container->getParameter(... | @param ContainerBuilder $container
@throws \LogicException | entailment |
public function processFuzzyProximityModifier($parameter = null)
{
$this->_fuzzyQuery = true;
if ($parameter !== null) {
$this->_similarity = $parameter;
} else {
/**
* Zend_Search_Lucene_Search_Query_Fuzzy
*/
include_once 'Zend/Search/Lucene/Search/Que... | Process modifier ('~')
@param mixed $parameter | entailment |
public function getQuery($encoding)
{
if ($this->_fuzzyQuery) {
/**
* Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy
*/
include_once 'Zend/Search/Lucene/Search/Query/Preprocessing/Fuzzy.php';
$query = new Zend_Search_Lucene_Search_Query_Preprocessing_Fuzzy(
... | Transform entry to a subquery
@param string $encoding
@return Zend_Search_Lucene_Search_Query
@throws Zend_Search_Lucene_Search_QueryParserException | entailment |
function get($key, $default = null) {
if (!is_string($key)) {
throw new InvalidArgumentException('$key must be a string');
}
$value = apcu_fetch($key, $success);
if (!$success) {
return $default;
}
return $value;
} | Fetches a value from the cache.
@param string $key The unique key of this item in the cache.
@param mixed $default Default value to return if the key does not exist.
@throws \Psr\SimpleCache\InvalidArgumentException
MUST be thrown if the $key string is not a legal value.
@return mixed The value of the item from ... | entailment |
function set($key, $value, $ttl = null) {
if (!is_string($key)) {
throw new InvalidArgumentException('$key must be a string');
}
if ($ttl instanceof DateInterval) {
// Converting to a TTL in seconds
$ttl = (new DateTime('now'))->add($ttl)->getTimeStamp() - ti... | Persists data in the cache, uniquely referenced by a key with an
optional expiration TTL time.
@param string $key The key of the item to store.
@param mixed $value The value of the item to store, must
be serializable.
@param null|int|DateInterval $ttl Optional. The TTL value of this ... | entailment |
function setMultiple($values, $ttl = null) {
if (!is_array($values) && !$values instanceof Traversable) {
throw new InvalidArgumentException('$values must be traversable');
}
if ($ttl instanceof DateInterval) {
// Converting to a TTL in seconds
$ttl = (new D... | Persists a set of key => value pairs in the cache, with an optional TTL.
@param iterable $values A list of key => value pairs for a
multiple-set operation.
@param null|int|DateInterval $ttl Optional. The TTL value of this
item. If no value is sent and the
driver supports TTL then the library
may set a ... | entailment |
function deleteMultiple($keys) {
if ($keys instanceof Traversable) {
$keys = iterator_to_array($keys);
} elseif (!is_array($keys)) {
throw new InvalidArgumentException('$keys must be iterable');
}
return apcu_delete($keys);
} | Deletes multiple cache items in a single operation.
@param iterable $keys A list of string-based keys to be deleted.
@throws \Psr\SimpleCache\InvalidArgumentException
MUST be thrown if $keys is neither an array nor a Traversable,
or if any of the $keys are not a legal value.
@return bool True if the items were succes... | entailment |
public function getSearchedEntities()
{
$entities = array();
if (!empty($_REQUEST['Entities'])) {
if (is_array($_REQUEST['Entities'])) {
$entities = Convert::raw2att($_REQUEST['Entities']);
} else {
$entities = explode(',', Convert::raw2att($_... | Return an array of folders and titles
@return array | entailment |
public function getSearchedVersions()
{
$versions = array();
if (!empty($_REQUEST['Versions'])) {
if (is_array($_REQUEST['Versions'])) {
$versions = Convert::raw2att($_REQUEST['Versions']);
$versions = array_combine($versions, $versions);
... | Return an array of versions that we're allowed to return
@return array | entailment |
public function getSearchQuery()
{
if (isset($_REQUEST['Search'])) {
return DBField::create_field('HTMLText', $_REQUEST['Search']);
} elseif (isset($_REQUEST['q'])) {
return DBField::create_field('HTMLText', $_REQUEST['q']);
}
} | Return the current search query.
@return HTMLText|null | entailment |
public function getSearchResults()
{
$query = $this->getSearchQuery();
$search = new DocumentationSearch();
$search->setQuery($query);
$search->setVersions($this->getSearchedVersions());
$search->setModules($this->getSearchedEntities());
$search->setOutputController(... | Past straight to results, display and encode the query. | entailment |
public function attr($attribute)
{
$node = $this->getNode();
$value = null;
if ($node instanceof \DOMNode) {
$value = $node->getAttribute($attribute);
} else {
foreach ($node as $item) {
if ($item->hasAttribute($attribute)) {
... | @param string $attribute
@return null|string | entailment |
protected function registerCustomBindings(): void
{
$repositoryFactory = $this->app->make(IRepositoryFactory::class);
foreach (config('laravel_repositories.bindings') as $className => $repository) {
$repositoryFactory->register($className, $repository);
}
} | Register custom repositories implementations.
@return void
@throws BindingResolutionException | entailment |
static public function getLocalClass($remoteClass) {
$localClass = false;
$cb = false;
$localClass=(isset(self::$maps[$remoteClass]))?self::$maps[$remoteClass]:false;
if (!$localClass && is_callable(self::$onGetLocalClass)) {
$cb = true;
$... | Get the local classname for a remote class
This method will return FALSE when the class is not found
@param string $remoteClass
@return mixed | entailment |
static public function getRemoteClass($localClass) {
$remoteClass = false;
$cb = false;
$remoteClass = array_search($localClass,self::$maps);
if (!$remoteClass && is_callable(self::$onGetRemoteClass)) {
$cb = true;
$remoteClass = call_user... | Get the remote classname for a local class
This method will return FALSE when the class is not found
@param string $localClass
@return mixed | entailment |
public function rewrite(Zend_Search_Lucene_Interface $index)
{
if ($this->_term->field != null) {
return $this;
} else {
include_once 'Zend/Search/Lucene/Search/Query/MultiTerm.php';
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$query->set... | Re-write query into primitive queries in the context of specified index
@param Zend_Search_Lucene_Interface $index
@return Zend_Search_Lucene_Search_Query | entailment |
public function createWeight(Zend_Search_Lucene_Interface $reader)
{
include_once 'Zend/Search/Lucene/Search/Weight/Term.php';
$this->_weight = new Zend_Search_Lucene_Search_Weight_Term($this->_term, $this, $reader);
return $this->_weight;
} | Constructs an appropriate Weight implementation for this query.
@param Zend_Search_Lucene_Interface $reader
@return Zend_Search_Lucene_Search_Weight | entailment |
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
$this->_docVector = array_flip($reader->termDocs($this->_term, $docsFilter));
$this->_termFreqs = $reader->termFreqs($this->_term, $docsFilter);
// Initialize weight if it's not done yet
$this->_init... | Execute query in context of index reader
It also initializes necessary internal structures
@param Zend_Search_Lucene_Interface $reader
@param Zend_Search_Lucene_Index_DocsFilter|null $docsFilter | entailment |
public function score($docId, Zend_Search_Lucene_Interface $reader)
{
if (isset($this->_docVector[$docId])) {
return $reader->getSimilarity()->tf($this->_termFreqs[$docId]) *
$this->_weight->getValue() *
$reader->norm($docId, $this->_term->field) *
... | Score specified document
@param integer $docId
@param Zend_Search_Lucene_Interface $reader
@return float | entailment |
public function highlight($words)
{
$color = $this->_highlightColors[$this->_currentColorIndex];
$this->_currentColorIndex = ($this->_currentColorIndex + 1) % count($this->_highlightColors);
$this->_doc->highlight($words, $color);
} | Highlight specified words
@param string|array $words Words to highlight. They could be organized using the array or string. | entailment |
public function tokenize($data, $encoding = '')
{
$this->setInput($data, $encoding);
$tokenList = array();
while (($nextToken = $this->nextToken()) !== null) {
$tokenList[] = $nextToken;
}
return $tokenList;
} | Tokenize text to a terms
Returns array of Zend_Search_Lucene_Analysis_Token objects
Tokens are returned in UTF-8 (internal Zend_Search_Lucene encoding)
@param string $data
@return array | entailment |
public function setInput($data, $encoding = '')
{
$this->_input = $data;
$this->_encoding = $encoding;
$this->reset();
} | Tokenization stream API
Set input
@param string $data | entailment |
public function addState($state)
{
$this->_states[$state] = $state;
if ($this->_currentState === null) {
$this->_currentState = $state;
}
} | Add state to the state machine
@param integer|string $state | entailment |
public function setState($state)
{
if (!isset($this->_states[$state])) {
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('State \'' . $state . '\' is not on of the possible FSM states.');
}
$this->_currentState = $state;
} | Set FSM state.
No any action is invoked
@param integer|string $state
@throws Zend_Search_Exception | entailment |
public function addRules($rules)
{
foreach ($rules as $rule) {
$this->addrule($rule[0], $rule[1], $rule[2], isset($rule[3])?$rule[3]:null);
}
} | Add transition rules
array structure:
array( array(sourseState, input, targetState[, inputAction]),
array(sourseState, input, targetState[, inputAction]),
array(sourseState, input, targetState[, inputAction]),
...
)
@param array $rules | entailment |
public function addRule($sourceState, $input, $targetState, $inputAction = null)
{
if (!isset($this->_states[$sourceState])) {
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined source state (' . $sourceState . ').');
}
if (!isset($th... | Add symbol to the input alphabet
@param integer|string $sourceState
@param integer|string $input
@param integer|string $targetState
@param Zend_Search_Lucene_FSMAction|null $inputAction
@throws Zend_Search_Exception | entailment |
public function addEntryAction($state, Zend_Search_Lucene_FSMAction $action)
{
if (!isset($this->_states[$state])) {
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined state (' . $state. ').');
}
if (!isset($this->_entryActions[$stat... | Add state entry action.
Several entry actions are allowed.
Action execution order is defined by addEntryAction() calls
@param integer|string $state
@param Zend_Search_Lucene_FSMAction $action | entailment |
public function addExitAction($state, Zend_Search_Lucene_FSMAction $action)
{
if (!isset($this->_states[$state])) {
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined state (' . $state. ').');
}
if (!isset($this->_exitActions[$state]... | Add state exit action.
Several exit actions are allowed.
Action execution order is defined by addEntryAction() calls
@param integer|string $state
@param Zend_Search_Lucene_FSMAction $action | entailment |
public function addInputAction($state, $inputSymbol, Zend_Search_Lucene_FSMAction $action)
{
if (!isset($this->_states[$state])) {
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined state (' . $state. ').');
}
if (!isset($this->_input... | Add input action (defined by {state, input} pair).
Several input actions are allowed.
Action execution order is defined by addInputAction() calls
@param integer|string $state
@param integer|string $input
@param Zend_Search_Lucene_FSMAction $action | entailment |
public function addTransitionAction($sourceState, $targetState, Zend_Search_Lucene_FSMAction $action)
{
if (!isset($this->_states[$sourceState])) {
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('Undefined source state (' . $sourceState. ').');
}
... | Add transition action (defined by {state, input} pair).
Several transition actions are allowed.
Action execution order is defined by addTransitionAction() calls
@param integer|string $sourceState
@param integer|string $targetState
@param Zend_Search_Lucene_FSMAction $action | entailment |
public function process($input)
{
if (!isset($this->_rules[$this->_currentState])) {
include_once 'Zend/Search/Exception.php';
throw new Zend_Search_Exception('There is no any rule for current state (' . $this->_currentState . ').');
}
if (!isset($this->_rules[$this->... | Process an input
@param mixed $input
@throws Zend_Search_Exception | entailment |
public function getToken(string $login, string $pass): GetTokenResponse
{
$response = $this->request('GET', 'getToken', [
'login' => $login,
'pass' => $pass,
]);
return $this->converter->getResponseObject(GetTokenResponse::class, $response);
} | Get auth token.
@param string $login
@param string $pass
@throws ParseException
@throws ValidationException
@return GetTokenResponse | entailment |
public function report(string $uuid, string $token): ReportResponse
{
$response = $this->request(
'GET',
"{$this->groupCode}/report/$uuid",
['tokenid' => $token]
);
return $this->converter->getResponseObject(ReportResponse::class, $response);
} | Report.
@param string $uuid
@param string $token
@return ReportResponse | entailment |
private function register(SellRequest $request, string $operation): SellResponse
{
$response = $this->request(
'POST',
"{$this->groupCode}/{$operation}",
['tokenid' => $request->getToken()],
$request
);
return $this->converter->getResponseObje... | Register (sell / buy with / without refund).
@param SellRequest $request
@param string $operation
@return SellResponse | entailment |
private function request(string $method, string $path, array $query = [], $body = null): string
{
// Prepare request:
$query = build_query($query);
$body = $this->parseBody($body);
$path = trim($path, '/');
$request = new Request(
$method,
"{$this->bas... | Send request.
@param string $method
@param string $path
@param array $query
@param string|object|null $body
@throws ParseException
@return string | entailment |
private function query(RequestInterface $request)
{
return $this->client->send($request, array_merge(
[RequestOptions::HTTP_ERRORS => false],
$this->clientOptions
));
} | @param RequestInterface $request
@throws GuzzleException
@return ResponseInterface | entailment |
public function createStoredFieldsFiles()
{
$this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx');
$this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt');
$this->_files[] = $this->_name . '.fdx';
$this->_files[] = $this->_name . '.fdt';
} | Create stored fields files and open them for write | entailment |
public function close()
{
if ($this->_docCount == 0) {
return null;
}
$this->_dumpFNM();
$this->_generateCFS();
/**
* Zend_Search_Lucene_Index_SegmentInfo
*/
include_once 'Zend/Search/Lucene/Index/SegmentInfo.php';
return new Zend_Search_Lucen... | Close segment, write it to disk and return segment info
@return Zend_Search_Lucene_Index_SegmentInfo | entailment |
public function close()
{
if ($this->_fileHandle !== null ) {
@fclose($this->_fileHandle);
$this->_fileHandle = null;
}
} | Close File object | entailment |
public function size()
{
$position = ftell($this->_fileHandle);
fseek($this->_fileHandle, 0, SEEK_END);
$size = ftell($this->_fileHandle);
fseek($this->_fileHandle, $position);
return $size;
} | Get the size of the already opened file
@return integer | entailment |
protected function _fread($length=1)
{
if ($length == 0) {
return '';
}
if ($length < 1024) {
return fread($this->_fileHandle, $length);
}
$data = '';
while ( $length > 0 && ($nextBlock = fread($this->_fileHandle, $length)) != false ) {
... | Read a $length bytes from the file and advance the file pointer.
@param integer $length
@return string | entailment |
protected function _fwrite($data, $length=null)
{
if ($length === null ) {
fwrite($this->_fileHandle, $data);
} else {
fwrite($this->_fileHandle, $data, $length);
}
} | Writes $length number of bytes (all, if $length===null) to the end
of the file.
@param string $data
@param integer $length | entailment |
public function lock($lockType, $nonBlockingLock = false)
{
if ($nonBlockingLock) {
return flock($this->_fileHandle, $lockType | LOCK_NB);
} else {
return flock($this->_fileHandle, $lockType);
}
} | Lock file
Lock type may be a LOCK_SH (shared lock) or a LOCK_EX (exclusive lock)
@param integer $lockType
@param boolean $nonBlockingLock
@return boolean | entailment |
public function handle(Request $request, Closure $next, $resource = null, $permission = null)
{
if ($this->auth->guest()) {
if (!$this->acl->isAllowed('guest', $resource, $permission)) {
return $this->notAllowed($request);
}
} elseif (!$this->acl->isAllowed($t... | Run the request filter.
@param \Illuminate\Http\Request $request
@param \Closure $next
@return mixed | entailment |
protected function notAllowed(Request $request)
{
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
$action = $this->config->get('zendacl.action', 'redirect');
if ($action == 'redirect') {
$url = $this->config->get('zendacl.re... | Processes not allowed response
@param Request $request
@return \Illuminate\Http\Response | entailment |
public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
{
if (array_key_exists($srcToken->getTermText(), $this->_stopSet)) {
return null;
} else {
return $srcToken;
}
} | Normalize Token or remove it (if null is returned)
@param Zend_Search_Lucene_Analysis_Token $srcToken
@return Zend_Search_Lucene_Analysis_Token | entailment |
public function loadFromFile($filepath = null)
{
if (! $filepath || ! file_exists($filepath)) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception('You have to provide valid file path');
}
$fd = fopen($filepath, "r");
if (... | Fills stopwords set from a text file. Each line contains one stopword, lines with '#' in the first
column are ignored (as comments).
You can call this method one or more times. New stopwords are always added to current set.
@param string $filepath full path for text file with stopwords
@throws Zend_Search_Exception ... | entailment |
public static function setDefaults($options = [])
{
$options = empty($options) ? '{}' : Json::encode($options);
$view = Yii::$app->getView();
$js = <<<EOD
fotoramaDefaults = {$options};
EOD;
$view->registerJs($js, View::POS_HEAD, 'fotorama-defaults');
} | Setup default Fotorama widget options
{@link http://fotorama.io/customize/options/#defaults}
@param array $options | entailment |
public function init()
{
parent::init();
if (empty($this->htmlOptions['id'])) {
$this->htmlOptions['id'] = $this->id;
}
if ($this->useHtmlData) {
if (isset($this->options['data'])) {
$this->items = (array)$this->options['data'];
... | Initializes the widget.
This renders the open tag. | entailment |
public function getRepository(string $modelClass): IRepository
{
if (empty($this->sharedInstances[$modelClass])) {
$this->sharedInstances[$modelClass] = $this->build($modelClass);
}
return $this->sharedInstances[$modelClass];
} | {@inheritdoc} | entailment |
protected function build(string $modelClass): IRepository
{
$repositoryClass = $this->registeredRepositories[$modelClass] ?? Repository::class;
$parameters = [];
if ($repositoryClass === Repository::class || is_subclass_of($repositoryClass, Repository::class)
) {
$param... | Build repository by model class from registered instances or creates default.
@param string $modelClass Model class
@return IRepository
@throws BindingResolutionException | entailment |
public function register(string $modelClass, string $repositoryClass): void
{
if (!is_subclass_of($modelClass, Model::class)) {
throw new RepositoryRegisterException("$modelClass must extend " . Model::class);
}
if (!is_subclass_of($repositoryClass, IRepository::class)) {
... | {@inheritdoc} | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.