sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function optimize()
{
if (Zend_Search_Lucene_LockManager::obtainOptimizationLock($this->_directory) === false) {
return false;
}
// Update segments list to be sure all segments are not merged yet by another process
//
// Segment merging functionality is co... | Merges all segments together into new one
Returns true on success and false if another optimization or auto-optimization process
is running now
@return boolean | entailment |
private function _newSegmentName()
{
Zend_Search_Lucene_LockManager::obtainWriteLock($this->_directory);
$generation = Zend_Search_Lucene::getActualGeneration($this->_directory);
$segmentsFile = $this->_directory->getFileObject(Zend_Search_Lucene::getSegmentFileName($generation), false);
... | Get name for new segment
@return string | entailment |
public function send($recipient, $body, $originator = '')
{
if (empty($recipient) || empty($body)) {
// let's save a request
return $this->transformResult(array(
'status' => ResultInterface::STATUS_FAILED,
));
}
try {
$data = $... | {@inheritDoc} | entailment |
public function registerProvider(ProviderInterface $provider)
{
if (null !== $provider) {
$this->providers[$provider->getName()] = $provider;
}
return $this;
} | Registers a provider.
@param \SmsSender\Provider\ProviderInterface $provider
@return \SmsSender\SmsSenderInterface | entailment |
public function using($name)
{
if (isset($this->providers[$name])) {
$this->provider = $this->providers[$name];
}
return $this;
} | Sets the provider to use.
@param string $name A provider's name
@return \SmsSender\SmsSenderInterface | entailment |
public function getProvider()
{
if (null === $this->provider) {
if (0 === count($this->providers)) {
throw new \RuntimeException('No provider registered.');
} else {
$this->provider = $this->providers[key($this->providers)];
}
}
... | Returns the provider to use.
@return \SmsSender\Provider\ProviderInterface | entailment |
public function getField($fieldName)
{
if (!array_key_exists($fieldName, $this->_fields)) {
include_once 'Zend/Search/Lucene/Exception.php';
throw new Zend_Search_Lucene_Exception("Field name \"$fieldName\" not found in document.");
}
return $this->_fields[$fieldName]... | Returns Zend_Search_Lucene_Field object for a named field in this document.
@param string $fieldName
@return Zend_Search_Lucene_Field | entailment |
public function getAMFData() {
return (object)array(
'serverInfo' => (object)array(
'totalCount' => $this->count(),
'initialData' => $this->getData(),
'cursor' => 1,
'serviceName' => false,
... | getAMFData
@return object | entailment |
protected function parserHeaders()
{
$headers = $this->asArray();
$this->_to = isset($headers['to']) ? self::decodeMimeString(current($headers['to'])) : '';
$this->_cc = isset($headers['cc']) ? self::decodeMimeString(current($headers['cc'])) : '';
$this->_from = isset($headers['from'... | Parser headers | entailment |
public static function decodeMimeString($strMime, $charset = null)
{
$items = preg_split('/[\r\n]{2,}/si', $strMime);
$result = '';
$strArray = [];
$tmpItems = [];
foreach ($items as $key => $item) {
$commaArray = explode('>,', $item);
if (count($comma... | @param string $strMime
@param string $charset
@return string | entailment |
public static function decodeStrArray($strArray)
{
$str = '';
foreach ($strArray as $encode => $part) {
$encodedStr = '';
foreach ($part as $type => $strings) {
if ($type === 'B') {
$resultStr = is_array($strings) ? implode(array_map('base6... | @param array $strArray
@return string | entailment |
public static function decodeMimeStringPart(&$data)
{
array_shift($data);
$encode = strtoupper(array_shift($data));
$type = strtoupper(array_shift($data));
if ($type === '') {
return [];
}
$str = array_shift($data);
return [
$encode =... | @param $data
@return array | entailment |
public static function toArray($headers)
{
$headers .= "\r\n\r\n";
preg_match_all('#[\r\n]*([\w-]+\:)(.+?)(?=([\r\n]+[\w-]+\:|[\r\n]{3,}|\n{2,}))#si', $headers, $result);
$headers = [];
foreach ($result[1] as $k => $header) {
$header = strtolower(rtrim($header, ':'));
... | @param string $headers
@return array | entailment |
public function readAMFData($settype = null) {
if (is_null($settype)) {
$settype = $this->stream->readByte();
}
switch ($settype) {
case SabreAMF_AMF3_Const::DT_UNDEFINED : return null;
case SabreAMF_AMF3_Const::DT_NULL : return... | readAMFData
@param mixed $settype
@return mixed | entailment |
public function readObject() {
$objInfo = $this->readU29();
$storedObject = ($objInfo & 0x01)==0;
$objInfo = $objInfo >> 1;
if ($storedObject) {
$objectReference = $objInfo;
if (!isset($this->storedObjects[$objectReference])) {
... | readObject
@return object | entailment |
public function readArray() {
$arrId = $this->readU29();
if (($arrId & 0x01)==0) {
$arrId = $arrId >> 1;
if ($arrId>=count($this->storedObjects)) {
throw new Exception('Undefined array reference: ' . $arrId);
return false... | readArray
@return array | entailment |
public function readString() {
$strref = $this->readU29();
if (($strref & 0x01) == 0) {
$strref = $strref >> 1;
if ($strref>=count($this->storedStrings)) {
throw new Exception('Undefined string reference: ' . $strref);
ret... | readString
@return string | entailment |
public function readXMLString() {
$strref = $this->readU29();
$strlen = $strref >> 1;
$str = $this->stream->readBuffer($strlen);
return simplexml_load_string($str);
} | readString
@return string | entailment |
public function readByteArray() {
$strref = $this->readU29();
$strlen = $strref >> 1;
$str = $this->stream->readBuffer($strlen);
return new SabreAMF_ByteArray($str);
} | readString
@return string | entailment |
public function readU29() {
$count = 1;
$u29 = 0;
$byte = $this->stream->readByte();
while((($byte & 0x80) != 0) && $count < 4) {
$u29 <<= 7;
$u29 |= ($byte & 0x7f);
$byte = $this->stream->readByte();
$c... | readU29
@return int | entailment |
public function readInt() {
$int = $this->readU29();
// if int and has the sign bit set
// Check if the integer is an int
// and is signed
if (($int & 0x18000000) == 0x18000000) {
$int ^= 0x1fffffff;
$int *= -1;
... | readInt
@return int | entailment |
public function readDate() {
$dateref = $this->readU29();
if (($dateref & 0x01) == 0) {
$dateref = $dateref >> 1;
if ($dateref>=count($this->storedObjects)) {
throw new Exception('Undefined date reference: ' . $dateref);
ret... | readDate
@return int | entailment |
public function writeAMFData($data,$forcetype=null) {
if (is_null($forcetype)) {
// Autodetecting data type
$type=false;
if (!$type && is_null($data)) $type = SabreAMF_AMF3_Const::DT_NULL;
if (!$type && is_bool($data)) {
$... | writeAMFData
@param mixed $data
@param int $forcetype
@return mixed | entailment |
public function writeObject($data) {
$encodingType = SabreAMF_AMF3_Const::ET_PROPLIST;
if ($data instanceof SabreAMF_ITypedObject) {
$classname = $data->getAMFClassName();
$data = $data->getAMFData();
} else if (!$classname = $this->getRe... | writeObject
@param mixed $data
@return void | entailment |
public function writeInt($int) {
// Note that this is simply a sanity check of the conversion algorithm;
// when live this sanity check should be disabled (overflow check handled in this.writeAMFData).
/*if ( ( ( $int & 0x70000000 ) != 0 ) && ( ( $int & 0x80000000 ) == 0 ) )
throw new Exce... | writeInt
@param int $int
@return void | entailment |
public function writeString($str) {
$strref = strlen($str) << 1 | 0x01;
$this->writeInt($strref);
$this->stream->writeBuffer($str);
} | writeString
@param string $str
@return void | entailment |
public function writeArray(array $arr) {
//Check if this is an associative array or not.
if ( $this->isPureArray( $arr ) ) {
// Writing the length for the numeric keys in the array
$arrLen = count($arr);
$arrId = ($arrLen << 1) | 0x01;
... | writeArray
@param array $arr
@return void | entailment |
public function addValueSortToCollection($collection, $dir = 'asc')
{
$attributeCode = $this->getAttribute()->getAttributeCode();
$attributeId = $this->getAttribute()->getId();
$attributeTable = $this->getAttribute()->getBackend()->getTable();
$linkField = $this->getAttribute()->getE... | Add Value Sort To Collection Select
@param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
@param string $dir direction
@return AbstractSource | entailment |
public function getMessage($id)
{
$header = $this->_protocol->top($id);
$message = $this->_protocol->retrieve($id);
return new Message($header, $message, $id);
} | Получение сообщения
@param int $id
@return Message | entailment |
public function getTitle()
{
if (!$this->title) {
$this->title = DocumentationHelper::clean_page_name($this->key);
}
return $this->title;
} | Get the title of this module.
@return string | entailment |
public function Link($short = false)
{
if ($this->getIsDefaultEntity()) {
$base = Controller::join_links(
Director::baseURL(),
Config::inst()->get('DocumentationViewer', 'link_base'),
$this->getLanguage(),
'/'
);
... | Returns the web accessible link to this entity.
Includes the version information
@param boolean $short If true, will attempt to return a short version of the url
This might omit the version number if this is the default version.
@return string | entailment |
public function hasRecord($page)
{
if (!$page) {
return false;
}
return strstr($page->getPath(), $this->getPath()) !== false;
} | @param DocumentationPage $page
@return boolean | entailment |
public function compare(DocumentationEntity $other)
{
$v1 = $this->getVersion();
$v2 = $other->getVersion();
// Normalise versions prior to comparison
$dots = substr_count($v1, '.') - substr_count($v2, '.');
while ($dots > 0) {
$dots--;
$v2 .= '.99999... | Returns an integer value based on if a given version is the latest
version. Will return -1 for if the version is older, 0 if versions are
the same and 1 if the version is greater than.
@param DocumentationEntity $other
@return int | entailment |
public function sumOfSquaredWeights()
{
// compute idf
$this->_idf = $this->_reader->getSimilarity()->idf($this->_query->getTerms(), $this->_reader);
// compute query weight
$this->_queryWeight = $this->_idf * $this->_query->getBoost();
// square it
return $this->_q... | The sum of squared weights of contained query clauses.
@return float | entailment |
public function normalize($queryNorm)
{
$this->_queryNorm = $queryNorm;
// normalize query weight
$this->_queryWeight *= $queryNorm;
// idf for documents
$this->_value = $this->_queryWeight * $this->_idf;
} | Assigns the query normalization factor to this.
@param float $queryNorm | entailment |
protected function getApiResponseAuthToken($username, $password)
{
$response = $this->sendRequest('GET', sprintf(
self::API_AUTH_URL,
urlencode($username),
urlencode($password)
));
return $response->getBody()->getContents();
} | @param string $username
@param string $password
@return string | entailment |
protected function _initWeight(Zend_Search_Lucene_Interface $reader)
{
// Check, that it's a top-level query and query weight is not initialized yet.
if ($this->_weight !== null) {
return $this->_weight;
}
$this->createWeight($reader);
$sum = $this->_weight->sumO... | Constructs an initializes a Weight for a _top-level_query_.
@param Zend_Search_Lucene_Interface $reader | entailment |
public function highlightMatches($inputHTML, $defaultEncoding = '', $highlighter = null)
{
if ($highlighter === null) {
include_once 'Zend/Search/Lucene/Search/Highlighter/Default.php';
$highlighter = new Zend_Search_Lucene_Search_Highlighter_Default();
}
/**
* Zend... | Highlight matches in $inputHTML
@param string $inputHTML
@param string $defaultEncoding HTML encoding, is used if it's not specified using Content-type HTTP-EQUIV meta tag.
@param Zend_Search_Lucene_Search_Highlighter_Interf... | entailment |
public function htmlFragmentHighlightMatches($inputHtmlFragment, $encoding = 'UTF-8', $highlighter = null)
{
if ($highlighter === null) {
include_once 'Zend/Search/Lucene/Search/Highlighter/Default.php';
$highlighter = new Zend_Search_Lucene_Search_Highlighter_Default();
}
... | Highlight matches in $inputHtmlFragment and return it (without HTML header and body tag)
@param string $inputHtmlFragment
@param string $encoding Input HTML string encoding
@param Zend_Search_Lucene_Search_Highlight... | entailment |
public function countMessages()
{
$count = 0; // "Declare" variable before first usage.
$octets = 0; // "Declare" variable since it's passed by reference
$this->_protocol->status($count, $octets);
return (int)$count;
} | Count Message
@return int | entailment |
public function getMessage($id)
{
$bodyLines = 0;
$header = $this->_protocol->top($id, $bodyLines, true);
$message = $message = $this->getRawContent($id);
return new Message($header, $message, $id);
} | Fetch message
@param int $id
@return Message
@throws \Exception
@throws protocol\Exception | entailment |
public function send($recipient, $body, $originator = '')
{
return array(
'id' => uniqid(),
'recipient' => $recipient,
'body' => $body,
'originator' => $originator,
'status' => ResultInterface::STATUS_SENT,
);
} | {@inheritDoc} | entailment |
protected function getUserImage(array $response, AccessToken $token)
{
$guid = $token->getResourceOwnerId();
$url = 'https://social.yahooapis.com/v1/user/' . $guid . '/profile/image/' . $this->imageSize . '?format=json';
$request = $this->getAuthenticatedRequest('get', $url, $token);
... | Get user image from provider
@param array $response
@param AccessToken $token
@return array | entailment |
protected function getUserImageUrl(array $response, AccessToken $token)
{
$image = $this->getUserImage($response, $token);
if (isset($image['image']['imageUrl'])) {
return $image['image']['imageUrl'];
}
return null;
} | Get user image url from provider, if available
@param array $response
@param AccessToken $token
@return string | entailment |
public function serialize(SabreAMF_OutputStream $stream) {
$this->outputStream = $stream;
$stream->writeByte(0x00);
$stream->writeByte($this->encoding);
$stream->writeInt(count($this->headers));
foreach($this->headers as $header) {
... | serialize
This method serializes a request. It requires an SabreAMF_OutputStream as an argument to read
the AMF Data from. After serialization the Outputstream will contain the encoded AMF data.
@param SabreAMF_OutputStream $stream
@return void | entailment |
public function deserialize(SabreAMF_InputStream $stream) {
$this->headers = array();
$this->bodies = array();
$this->InputStream = $stream;
$stream->readByte();
$this->clientType = $stream->readByte();
$deserializer = new SabreAMF_A... | deserialize
This method deserializes a request. It requires an SabreAMF_InputStream with valid AMF data. After
deserialization the contents of the request can be found through the getBodies and getHeaders methods
@param SabreAMF_InputStream $stream
@return void | entailment |
public function addDocument(Zend_Search_Lucene_Document $document)
{
/**
* Zend_Search_Lucene_Search_Similarity
*/
include_once 'Zend/Search/Lucene/Search/Similarity.php';
$storedFields = array();
$docNorms = array();
$similarity = Zend_Search_Lucene_Search_Similarit... | Adds a document to this segment.
@param Zend_Search_Lucene_Document $document
@throws Zend_Search_Lucene_Exception | entailment |
protected function _dumpDictionary()
{
ksort($this->_termDictionary, SORT_STRING);
$this->initializeDictionaryFiles();
foreach ($this->_termDictionary as $termId => $term) {
$this->addTerm($term, $this->_termDocs[$termId]);
}
$this->closeDictionaryFiles();
... | Dump Term Dictionary (.tis) and Term Dictionary Index (.tii) segment files | entailment |
public function getConfigTreeBuilder()
{
$tb = new TreeBuilder();
return $tb
->root('atoum_atoum')
->children()
->arrayNode('bundles')
->useAttributeAsKey('name')
->prototype('array')
... | Generates the configuration tree builder.
@return TreeBuilder The tree builder | entailment |
public function withSpecialMark($mark, string $name = 'default'): self
{
$this->special_marks[$name] = $mark;
return $this;
} | Mark this object
@param mixed $mark
@return $this | entailment |
public function send($recipient, $body, $originator = '')
{
if (null === $this->api_key || null === $this->api_secret) {
throw new Exception\InvalidCredentialsException('No API credentials provided');
}
if (empty($originator)) {
throw new Exception\InvalidArgumentExc... | {@inheritDoc} | entailment |
protected function makeResult($response, $method) {
//Make sure we got the complete response.
if(
$method != 'HEAD' &&
isset($response->headers->{'content-length'}) &&
strlen($response->body) != $response->headers->{'content-length'}
) {
throw new SagException('Unexpected end of pack... | Used by the concrete HTTP adapters, this abstracts out the generic task of
turning strings from the net into response objects.
@param string $response The body of the HTTP packet.
@param string $method The request's HTTP method ("HEAD", etc.).
@returns stdClass The response object. | entailment |
protected function parseCookieString($cookieStr) {
$cookies = new stdClass();
foreach(explode('; ', $cookieStr) as $cookie) {
$crumbs = explode('=', $cookie);
if(!isset($crumbs[1])) {
$crumbs[1] = '';
}
$cookies->{trim($crumbs[0])} = trim($crumbs[1]);
}
return $cookies;... | A utility function for the concrete adapters to turn the HTTP Cookie
header's value into an object (map).
@param string $cookieStr The HTTP Cookie header value (not including the
"Cookie: " key.
@returns stdClass An object mapping cookie name to cookie value. | entailment |
public function setRWTimeout($seconds, $microseconds) {
if(!is_int($microseconds) || $microseconds < 0) {
throw new SagException('setRWTimeout() expects $microseconds to be an integer >= 0.');
}
//TODO make this better, including checking $microseconds
//$seconds can be 0 if $microseconds > 0
... | Set how long we should wait for an HTTP request to be executed.
@param int $seconds The number of seconds.
@param int $microseconds The number of microseconds. | entailment |
public function setTimeoutsFromArray($arr) {
/*
* Validation is lax in here because this should only ever be used with
* getTimeouts() return values. If people are using it by hand then there
* might be something wrong with the API.
*/
if(!is_array($arr)) {
throw SagException('Expected... | A utility function that sets the different timeout values based on an
associative array.
@param array $arr An associative array with the keys 'open', 'rwSeconds',
and 'rwMicroseconds'.
@see getTimeouts() | entailment |
private function makeFollowAdapter($parts) {
// re-use $this if we just got a path or the host/proto info matches
if(empty($parts['host']) ||
($parts['host'] == $this->host &&
$parts['port'] == $this->port &&
$parts['scheme'] == $this->proto
)
) {
return $this;
... | Used when we need to create a new adapter to follow a redirect because
cURL can't.
@param array $parts Return value from url_parts() for the location header.
@return SagCURLHTTPAdapter Returns $this if talking to the same server
with the same protocol, otherwise creates a new instance. | entailment |
public static function getSubscribingMethods()
{
$methods = parent::getSubscribingMethods();
foreach (self::$additionalFormats as $format) {
$methods[] = [
'type' => 'DateTime',
'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
'fo... | {@inheritdoc} | entailment |
public function reset()
{
$this->_position = 0;
$this->_bytePosition = 0;
// convert input into UTF-8
if (strcasecmp($this->_encoding, 'utf8') != 0
&& strcasecmp($this->_encoding, 'utf-8') != 0
) {
$this->_input = iconv($this->_encoding, 'U... | Reset token stream | entailment |
public function nextToken()
{
if ($this->_input === null) {
return null;
}
do {
if (! preg_match('/[\p{L}\p{N}]+/u', $this->_input, $match, PREG_OFFSET_CAPTURE, $this->_bytePosition)) {
// It covers both cases a) there are no matches (preg_match(...) ... | Tokenization stream API
Get next token
Returns null at the end of stream
@return Zend_Search_Lucene_Analysis_Token|null | entailment |
public function multiple(): self
{
$unique_array = array_unique($this->getArrayCopy());
return new ArrayMap(array_diff_assoc($this->getArrayCopy(), $unique_array));
} | Get duplicate values in an array
@return $this | entailment |
public function sort($sort_flags = SORT_REGULAR): self
{
$temp = $this->getArrayCopy();
sort($temp, $sort_flags);
return new ArrayMap($temp);
} | sort
@param int $sort_flags
@return $this | entailment |
public function register()
{
$this->app->configure('zendacl');
$this->app->singleton(function (Application $app) {
$acl = new Acl;
if (file_exists(base_path('app/Http/acl.php'))) {
include base_path('app/Http/acl.php');
}
return $acl;
... | Register the service provider.
@return void | entailment |
public function put($element)
{
$nodeId = count($this->_heap);
$parentId = ($nodeId-1) >> 1; // floor( ($nodeId-1)/2 )
while ($nodeId != 0 && $this->_less($element, $this->_heap[$parentId])) {
// Move parent node down
$this->_heap[$nodeId] = $this->_heap[$paren... | Add element to the queue
O(log(N)) time
@param mixed $element | entailment |
public function pop()
{
if (count($this->_heap) == 0) {
return null;
}
$top = $this->_heap[0];
$lastId = count($this->_heap) - 1;
/**
* Find appropriate position for last node
*/
$nodeId = 0; // Start from a top
$childId = ... | Removes and return least element of the queue
O(log(N)) time
@return mixed | entailment |
public function VersionWarning()
{
$page = $this->owner->getPage();
if (!$page) {
return false;
}
$entity = $page->getEntity();
if (!$entity) {
return false;
}
$versions = $this->owner->getManifest()->getAllVersionsOfEntity($entity)... | Check to see if the currently accessed version is out of date or perhaps a
future version rather than the stable edition.
@return false|ArrayData | entailment |
public function resetTermsStream()
{
/**
* Zend_Search_Lucene_Index_TermsPriorityQueue
*/
include_once 'Zend/Search/Lucene/Index/TermsPriorityQueue.php';
$this->_termsStreamQueue = new Zend_Search_Lucene_Index_TermsPriorityQueue();
foreach ($this->_termStreams as $termStream) {
... | Reset terms stream. | entailment |
public function skipTo(Zend_Search_Lucene_Index_Term $prefix)
{
$termStreams = array();
while (($termStream = $this->_termsStreamQueue->pop()) !== null) {
$termStreams[] = $termStream;
}
foreach ($termStreams as $termStream) {
$termStream->skipTo($prefix);
... | Skip terms stream up to specified term preffix.
Prefix contains fully specified field info and portion of searched term
@param Zend_Search_Lucene_Index_Term $prefix | entailment |
public function nextTerm()
{
while (($termStream = $this->_termsStreamQueue->pop()) !== null) {
if ($this->_termsStreamQueue->top() === null
|| $this->_termsStreamQueue->top()->currentTerm()->key() != $termStream->currentTerm()->key()
) {
... | Scans term streams and returns next term
@return Zend_Search_Lucene_Index_Term|null | entailment |
public function closeTermsStream()
{
while (($termStream = $this->_termsStreamQueue->pop()) !== null) {
$termStream->closeTermsStream();
}
$this->_termsStreamQueue = null;
$this->_lastTerm = null;
} | Close terms stream
Should be used for resources clean up if stream is not read up to the end | entailment |
public function addTerm(Zend_Search_Lucene_Index_Term $term, $sign = null)
{
if ($sign !== true || $this->_signs !== null) { // Skip, if all terms are required
if ($this->_signs === null) { // Check, If all previous terms are required
$this->_signs = ar... | Add a $term (Zend_Search_Lucene_Index_Term) to this query.
The sign is specified as:
TRUE - term is required
FALSE - term is prohibited
NULL - term is neither prohibited, nor required
@param Zend_Search_Lucene_Index_Term $term
@param boolean|null $sign
@return void | 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();
}
// Check, that all fields are qualified
$allQualifi... | 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)
{
$terms = $this->_terms;
$signs = $this->_signs;
foreach ($terms as $id => $term) {
if (!$index->hasTerm($term)) {
if ($signs === null || $signs[$id] === true) {
// Term is requi... | 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/MultiTerm.php';
$this->_weight = new Zend_Search_Lucene_Search_Weight_MultiTerm($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 |
private function _calculateConjunctionResult(Zend_Search_Lucene_Interface $reader)
{
$this->_resVector = null;
if (count($this->_terms) == 0) {
$this->_resVector = array();
}
// Order terms by selectivity
$docFreqs = array();
$ids = array();
... | Calculate result vector for Conjunction query
(like '+something +another')
@param Zend_Search_Lucene_Interface $reader | entailment |
private function _calculateNonConjunctionResult(Zend_Search_Lucene_Interface $reader)
{
$requiredVectors = array();
$requiredVectorsSizes = array();
$requiredVectorsIds = array(); // is used to prevent arrays comparison
$optional = array();
$prohibited = array();
... | Calculate result vector for non Conjunction query
(like '+something -another')
@param Zend_Search_Lucene_Interface $reader | entailment |
public function _conjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
{
if ($this->_coord === null) {
$this->_coord = $reader->getSimilarity()->coord(
count($this->_terms),
count($this->_terms)
);
}
$score = 0.0;
fo... | Score calculator for conjunction queries (all terms are required)
@param integer $docId
@param Zend_Search_Lucene_Interface $reader
@return float | entailment |
public function _nonConjunctionScore($docId, $reader)
{
if ($this->_coord === null) {
$this->_coord = array();
$maxCoord = 0;
foreach ($this->_signs as $sign) {
if ($sign !== false /* not prohibited */) {
$maxCoord++;
}... | Score calculator for non conjunction queries (not all terms are required)
@param integer $docId
@param Zend_Search_Lucene_Interface $reader
@return float | entailment |
public function execute(Zend_Search_Lucene_Interface $reader, $docsFilter = null)
{
if ($this->_signs === null) {
$this->_calculateConjunctionResult($reader);
} else {
$this->_calculateNonConjunctionResult($reader);
}
// Initialize weight if it's not done yet... | 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 getQueryTerms()
{
if ($this->_signs === null) {
return $this->_terms;
}
$terms = array();
foreach ($this->_signs as $id => $sign) {
if ($sign !== false) {
$terms[] = $this->_terms[$id];
}
}
return ... | Return query terms
@return array | entailment |
protected function _highlightMatches(Zend_Search_Lucene_Search_Highlighter_Interface $highlighter)
{
$words = array();
if ($this->_signs === null) {
foreach ($this->_terms as $term) {
$words[] = $term->text;
}
} else {
foreach ($this->_sig... | Query specific matches highlighting
@param Zend_Search_Lucene_Search_Highlighter_Interface $highlighter Highlighter object (also contains doc for highlighting) | entailment |
public function normalize(Zend_Search_Lucene_Analysis_Token $srcToken)
{
$newToken = new Zend_Search_Lucene_Analysis_Token(
mb_strtolower($srcToken->getTermText(), 'UTF-8'),
$srcToken->getStartOffset(),
$srcToken->getEndOffset()
);
$newToken->setPositionI... | 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 addField(Zend_Search_Lucene_Field $field)
{
if (!isset($this->_fields[$field->name])) {
$fieldNumber = count($this->_fields);
$this->_fields[$field->name] =
new Zend_Search_Lucene_Index_FieldInfo(
$fi... | Add field to the segment
Returns actual field number
@param Zend_Search_Lucene_Field $field
@return integer | entailment |
public function addFieldInfo(Zend_Search_Lucene_Index_FieldInfo $fieldInfo)
{
if (!isset($this->_fields[$fieldInfo->name])) {
$fieldNumber = count($this->_fields);
$this->_fields[$fieldInfo->name] =
new Zend_Search_Lucene_Index_FieldInfo(
... | Add fieldInfo to the segment
Returns actual field number
@param Zend_Search_Lucene_Index_FieldInfo $fieldInfo
@return integer | entailment |
public function addStoredFields($storedFields)
{
if (!isset($this->_fdxFile)) {
$this->_fdxFile = $this->_directory->createFile($this->_name . '.fdx');
$this->_fdtFile = $this->_directory->createFile($this->_name . '.fdt');
$this->_files[] = $this->_name . '.fdx';
... | Add stored fields information
@param array $storedFields array of Zend_Search_Lucene_Field objects | entailment |
protected function _dumpFNM()
{
$fnmFile = $this->_directory->createFile($this->_name . '.fnm');
$fnmFile->writeVInt(count($this->_fields));
$nrmFile = $this->_directory->createFile($this->_name . '.nrm');
// Write header
$nrmFile->writeBytes('NRM');
// Write format ... | Dump Field Info (.fnm) segment file | entailment |
public function initializeDictionaryFiles()
{
$this->_tisFile = $this->_directory->createFile($this->_name . '.tis');
$this->_tisFile->writeInt((int)0xFFFFFFFD);
$this->_tisFile->writeLong(0 /* dummy data for terms count */);
$this->_tisFile->writeInt(self::$indexInterval);
$... | Create dicrionary, frequency and positions files and write necessary headers | entailment |
public function addTerm($termEntry, $termDocs)
{
$freqPointer = $this->_frqFile->tell();
$proxPointer = $this->_prxFile->tell();
$prevDoc = 0;
foreach ($termDocs as $docId => $termPositions) {
$docDelta = ($docId - $prevDoc)*2;
$prevDoc = $docId;
... | Add term
Term positions is an array( docId => array(pos1, pos2, pos3, ...), ... )
@param Zend_Search_Lucene_Index_Term $termEntry
@param array $termDocs | entailment |
public function closeDictionaryFiles()
{
$this->_tisFile->seek(4);
$this->_tisFile->writeLong($this->_termCount);
$this->_tiiFile->seek(4);
// + 1 is used to count an additional special index entry (empty term at the start of the list)
$this->_tiiFile->writeLong(($this->_ter... | Close dictionary | entailment |
protected function _dumpTermDictEntry(Zend_Search_Lucene_Storage_File $dicFile,
&$prevTerm, Zend_Search_Lucene_Index_Term $term,
&$prevTermInfo, Zend_Search_Lucene_Index_TermInfo $termInfo
) {
if (isset($prevTerm) && $prevTerm->field == $term->field) {
$matchedBytes ... | Dump Term Dictionary segment file entry.
Used to write entry to .tis or .tii files
@param Zend_Search_Lucene_Storage_File $dicFile
@param Zend_Search_Lucene_Index_Term $prevTerm
@param Zend_Search_Lucene_Index_Term $term
@param Zend_Search_Lucene_Index_TermInfo $prevTermInfo
@param Zend_Search_Lucene_Index_T... | entailment |
protected function _generateCFS()
{
$cfsFile = $this->_directory->createFile($this->_name . '.cfs');
$cfsFile->writeVInt(count($this->_files));
$dataOffsetPointers = array();
foreach ($this->_files as $fileName) {
$dataOffsetPointers[$fileName] = $cfsFile->tell();
... | Generate compound index file | entailment |
public function getDocument()
{
if (!$this->_document instanceof Zend_Search_Lucene_Document) {
$this->_document = $this->_index->getDocument($this->id);
}
return $this->_document;
} | Return the document object for this hit
@return Zend_Search_Lucene_Document | entailment |
public function register()
{
$this->mergeConfigFrom(
dirname(dirname(__DIR__)) . '/config/zendacl.php',
'zendacl'
);
$this->app->singleton('acl', function (Application $app) {
$acl = new Acl;
if (file_exists(base_path('routes/acl.php'))) {
... | Register the service provider.
@return void | entailment |
protected function withBulk(array $data = [])
{
if (!$this->isArray($data)) {
return;
}
foreach ($data['data'] as $index => $element) {
$row = $this->data->addChild('row');
$row->addAttribute('no', ++$index);
foreach ($element as $key => $va... | One or more elements in data array.
@param array $data | entailment |
protected function withoutBulk(array $data = [])
{
if ($this->isArray($data)) {
return;
}
$row = $this->data->addChild('row');
$row->addAttribute('no', 1);
foreach ($data['data'] as $key => $value) {
$child = $row->addChild('FL', $value);
... | Only one element in data array. For BC.
@param array $data | entailment |
public function setHTTPAdapter($type = null) {
if(!$type) {
$type = extension_loaded("curl") ? self::$HTTP_CURL : self::$HTTP_NATIVE_SOCKETS;
}
// nothing to be done
if($type === $this->httpAdapterType) {
return true;
}
// remember what was already set (ie., might have called decod... | Set which HTTP library you want to use for communicating with CouchDB.
@param string $type The type of adapter you want to use. Should be one of
the Sag::$HTTP_* variables.
@return Sag Returns $this.
@see Sag::$HTTP_NATIVE_SOCKETS
@see Sag::$HTTP_CURL | entailment |
public function login($user, $pass, $type = null) {
if($type == null) {
$type = Sag::$AUTH_BASIC;
}
$this->authType = $type;
switch($type) {
case Sag::$AUTH_BASIC:
//these will end up in a header, so don't URL encode them
$this->user = $user;
$this->pass = $pass;
... | Updates the login credentials in Sag that will be used for all further
communications. Pass null to both $user and $pass to turn off
authentication, as Sag does support blank usernames and passwords - only
one of them has to be set for packets to be sent with authentication.
Cookie authentication will cause a call to ... | entailment |
public function decode($decode) {
if(!is_bool($decode)) {
throw new SagException('decode() expected a boolean');
}
$this->httpAdapter->decodeResp = $decode;
return $this;
} | Sets whether Sag will decode CouchDB's JSON responses with json_decode()
or to simply return the JSON as a string. Defaults to true.
@param bool $decode True to decode, false to not decode.
@return Sag Returns $this. | entailment |
public function get($url) {
if(!$this->db) {
throw new SagException('No database specified');
}
//The first char of the URL should be a slash.
if(strpos($url, '/') !== 0) {
$url = "/$url";
}
$url = "/{$this->db}$url";
if($this->staleDefault) {
$url = self::setURLParamete... | Performs an HTTP GET operation for the supplied URL. The database name you
provided is automatically prepended to the URL, so you only need to give
the portion of the URL that comes after the database name.
You are responsible for URL encoding your own parameters.
@param string $url The URL, with or without the leadi... | entailment |
public function head($url) {
if(!$this->db) {
throw new SagException('No database specified');
}
//The first char of the URL should be a slash.
if(strpos($url, '/') !== 0) {
$url = "/$url";
}
if($this->staleDefault) {
$url = self::setURLParameter($url, 'stale', 'ok');
}
... | Performs an HTTP HEAD operation for the supplied document. This operation
does not try to read from a provided cache, and does not cache its
results.
@see http://wiki.apache.org/couchdb/HTTP_Document_API#HEAD
@param string $url The URL, with or without the leading slash.
@return mixed | entailment |
public function delete($id, $rev)
{
if(!$this->db) {
throw new SagException('No database specified');
}
if(!is_string($id) || !is_string($rev) || empty($id) || empty($rev)) {
throw new SagException('delete() expects two strings.');
}
$url = "/{$this->db}/$id";
if($this->cache) {... | DELETE's the specified document.
@param string $id The document's _id.
@param string $rev The document's _rev.
@return mixed | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.