@param SegmentationRule $segmentation_rule

@return SegmentationRule
@throws Exception

API documentation: https://whatcounts.zendesk.com/hc/en-us/articles/204669745
964170
public function updateSegmentationRule(SegmentationRule &$segmentation_rule)
		{
			$form_data = array(
				'segmentation_id' => $segmentation_rule->getId(),
				'segmentation_name' => $segmentation_rule->getName(),
				'segmentation_type' => $segmentation_rule->getType(),
				'list_id' => $segmentation_rule->getListId(),
				'rules' => $segmentation_rule->getRules(),
				'description' => $segmentation_rule->getDescription()
			);
			$xml = $this->call('updateseg', $form_data);

			return trim($xml[1]);
		}
915439
function segment($n, $no_result=FALSE) {
		return (!isset($this->segments[$n])) ? $no_result : $this->segments[$n];
	}
711905
public function getPreconditionRule(): Rule
    {
        // we combine each topics with an AND and a OR inside of their rules.
        // so all topics have to match, and one topic needs at least 1 rule that matches.
        $requirements = new AndRule(
            []
        );

        $personasFound = false;
        $personaOR = new OrRule();

        // check if we have persona rules and add them
        // to our persona OR as a separate OR rule with all configured rules
        if ($this->getPersonaRules() !== null && count($this->getPersonaRules()->getElements()) > 0) {
            $personaRuleOR = new OrRule();

            /** @var RuleEntity $ruleEntity */
            foreach ($this->getPersonaRules()->getElements() as $ruleEntity) {
                // add rule our rule and also make sure
                // we know that at least a persona exists.
                $personaRuleOR->addRule($ruleEntity->getPayload());
                $personasFound = true;
            }

            $personaOR->addRule($personaRuleOR);
        }

        // check if we have customers.
        // if so, create customer rules for it and add that also as
        // a separate OR condition to our main persona rule
        if ($this->getPersonaCustomers() !== null) {
            $personaCustomerOR = new OrRule();

            /* @var CustomerEntity $ruleEntity */
            foreach ($this->getPersonaCustomers()->getElements() as $customer) {
                // build our new rule for this
                // customer and his/her customer number
                $custRule = new CustomerNumberRule();
                $custRule->assign(['numbers' => [$customer->getCustomerNumber()], 'operator' => CustomerNumberRule::OPERATOR_EQ]);

                // add rule for customer and make sure
                // we know that at least a persona exists.
                $personaCustomerOR->addRule($custRule);
                $personasFound = true;
            }

            $personaOR->addRule($personaCustomerOR);
        }

        // if we have found any persona rule
        // or customer, then add our main persona rule
        if ($personasFound) {
            $requirements->addRule($personaOR);
        }

        if ($this->getCartRules() !== null && count($this->getCartRules()->getElements()) > 0) {
            $cartOR = new OrRule([]);

            /** @var RuleEntity $ruleEntity */
            foreach ($this->getCartRules()->getElements() as $ruleEntity) {
                $cartOR->addRule($ruleEntity->getPayload());
            }

            $requirements->addRule($cartOR);
        }

        if ($this->getOrderRules() !== null && count($this->getOrderRules()->getElements()) > 0) {
            $orderOR = new OrRule([]);

            /** @var RuleEntity $ruleEntity */
            foreach ($this->getOrderRules()->getElements() as $ruleEntity) {
                $orderOR->addRule($ruleEntity->getPayload());
            }

            $requirements->addRule($orderOR);
        }

        return $requirements;
    }
1080428
private SegmentScoreEntry getBestInflectedScoreEntry(Segment s,
			CompostInflectionRules rules) {
		SegmentScoreEntry bestScoreEntry = this.segmentScoreEntries.getUnchecked(s.getSubstring());
		for(String seg:rules.getInflections(s.getSubstring())) {
			SegmentScoreEntry scoreEntry = this.segmentScoreEntries.getUnchecked(seg);
			if(scoreEntry.getScore()>bestScoreEntry.getScore()) 
				bestScoreEntry = scoreEntry;
		}
//		this.segmentScoreEntries.put(s.getSubstring(), bestScoreEntry);
		return bestScoreEntry;
	}
743567
public final String entryRuleOpOther() throws RecognitionException {
        String current = null;

        AntlrDatatypeRuleToken iv_ruleOpOther = null;


        try {
            // InternalXbase.g:945:47: (iv_ruleOpOther= ruleOpOther EOF )
            // InternalXbase.g:946:2: iv_ruleOpOther= ruleOpOther EOF
            {
            if ( state.backtracking==0 ) {
               newCompositeNode(grammarAccess.getOpOtherRule()); 
            }
            pushFollow(FOLLOW_1);
            iv_ruleOpOther=ruleOpOther();

            state._fsp--;
            if (state.failed) return current;
            if ( state.backtracking==0 ) {
               current =iv_ruleOpOther.getText(); 
            }
            match(input,EOF,FOLLOW_2); if (state.failed) return current;

            }

        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }
1339978
public static void removeRule( TerminalNode tn, Collection<InternalWorkingMemory> wms, InternalKnowledgeBase kBase) {
        if (log.isTraceEnabled()) {
            log.trace("Removing Rule {}", tn.getRule().getName());
        }

        boolean hasProtos = kBase.hasSegmentPrototypes();
        boolean hasWms = !wms.isEmpty();

        if (!hasProtos && !hasWms) {
            return;
        }

        RuleImpl      rule       = tn.getRule();
        LeftTupleNode firstSplit = getNetworkSplitPoint(tn);
        PathEndNodes pathEndNodes = getPathEndNodes(kBase, firstSplit, tn, rule, hasProtos, hasWms);

        for (InternalWorkingMemory wm : wms) {
            wm.flushPropagations();

            PathEndNodeMemories tnms = getPathEndMemories(wm, pathEndNodes);

            if ( !tnms.subjectPmems.isEmpty() ) {
                if (NodeTypeEnums.LeftInputAdapterNode == firstSplit.getType() && firstSplit.getAssociationsSize() == 1) {
                    if (tnms.subjectPmem != null) {
                        flushStagedTuples(firstSplit, tnms.subjectPmem, wm);
                    }

                    processLeftTuples(firstSplit, wm, false, tn.getRule());

                    removeNewPaths(wm, tnms.subjectPmems);
                } else {
                    flushStagedTuples(tn, tnms.subjectPmem, pathEndNodes, wm);

                    processLeftTuples(firstSplit, wm, false, tn.getRule());

                    removeNewPaths(wm, tnms.subjectPmems);

                    Map<PathMemory, SegmentMemory[]> prevSmemsLookup = reInitPathMemories(tnms.otherPmems, tn);

                    // must collect all visited SegmentMemories, for link notification
                    Set<SegmentMemory> smemsToNotify = handleExistingPaths(tn, prevSmemsLookup, tnms.otherPmems, wm, ExistingPathStrategy.REMOVE_STRATEGY);

                    notifySegments(smemsToNotify, wm);
                }
            }

            if (tnms.subjectPmem != null && tnms.subjectPmem.isInitialized() && tnms.subjectPmem.getRuleAgendaItem().isQueued()) {
                // SubjectPmem can be null, if it was never initialized
                tnms.subjectPmem.getRuleAgendaItem().dequeue();
            }
        }
    }
612865
protected function getURIsegments($uri, $segmentCount)
    {
        if( $uri === NULL)
        {
            $uri = URI::active();
        }

        
        return explode('/' , rtrim(Datatype::divide($uri, '/', 0, $segmentCount), '/'));
    }
1008623
public static function segment($segment, $default = null)
	{
		if ($request = \Request::active())
		{
			return $request->uri->get_segment($segment, $default);
		}

		return null;
	}
155759
private function _hasAnythingToMerge()
    {
        $segmentSizes = array();
        foreach ($this->_segmentInfos as $segName => $segmentInfo) {
            $segmentSizes[$segName] = $segmentInfo->count();
        }

        $mergePool   = array();
        $poolSize    = 0;
        $sizeToMerge = $this->maxBufferedDocs;
        asort($segmentSizes, SORT_NUMERIC);
        foreach ($segmentSizes as $segName => $size) {
            // Check, if segment comes into a new merging block
            while ($size >= $sizeToMerge) {
                // Merge previous block if it's large enough
                if ($poolSize >= $sizeToMerge) {
                    return true;
                }
                $mergePool   = array();
                $poolSize    = 0;

                $sizeToMerge *= $this->mergeFactor;

                if ($sizeToMerge > $this->maxMergeDocs) {
                    return false;
                }
            }

            $mergePool[] = $this->_segmentInfos[$segName];
            $poolSize += $size;
        }

        if ($poolSize >= $sizeToMerge) {
            return true;
        }

        return false;
    }
588764
public final void entryRuleParserRule() throws RecognitionException {
        try {
            // InternalXtext.g:229:1: ( ruleParserRule EOF )
            // InternalXtext.g:230:1: ruleParserRule EOF
            {
             before(grammarAccess.getParserRuleRule()); 
            pushFollow(FollowSets000.FOLLOW_1);
            ruleParserRule();

            state._fsp--;

             after(grammarAccess.getParserRuleRule()); 
            match(input,EOF,FollowSets000.FOLLOW_2); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }
        finally {
        }
        return ;
    }
956846
public static String ruleToRuleContentsString(Rule originalRule, int indentLevel)
    {
        if (originalRule instanceof Context && ((Context) originalRule).containsKey(RuleMetadataType.RULE_XML))
        {
            return (String) ((Context) originalRule).get(RuleMetadataType.RULE_XML);
        }

        if (!(originalRule instanceof RuleBuilder))
        {
            return wrap(originalRule.toString(), MAX_WIDTH, indentLevel);
        }
        final RuleBuilder rule = (RuleBuilder) originalRule;
        StringBuilder result = new StringBuilder();
        if (indentLevel == 0)
            result.append("addRule()");

        for (Condition condition : rule.getConditions())
        {
            String conditionToString = conditionToString(condition, indentLevel + 1);
            if (!conditionToString.isEmpty())
            {
                result.append(System.lineSeparator());
                insertPadding(result, indentLevel + 1);
                result.append(".when(").append(wrap(conditionToString, MAX_WIDTH, indentLevel + 2)).append(")");
            }

        }
        for (Operation operation : rule.getOperations())
        {
            String operationToString = operationToString(operation, indentLevel + 1);
            if (!operationToString.isEmpty())
            {
                result.append(System.lineSeparator());
                insertPadding(result, indentLevel + 1);
                result.append(".perform(").append(wrap(operationToString, MAX_WIDTH, indentLevel + 2)).append(")");
            }
        }
        if (rule.getId() != null && !rule.getId().isEmpty())
        {
            result.append(System.lineSeparator());
            insertPadding(result, indentLevel);
            result.append("withId(\"").append(rule.getId()).append("\")");
        }

        if (rule.priority() != 0)
        {
            result.append(System.lineSeparator());
            insertPadding(result, indentLevel);
            result.append(".withPriority(").append(rule.priority()).append(")");
        }

        return result.toString();
    }
1100057
public static function getPageOffsetRule(): ?RuleInterface
    {
        // if not given (`null` as an input) then 0 otherwise input should be integer value >= 0
        return r::ifX(
            r::IS_NULL_CALLABLE,
            r::value(0),
            r::stringToInt(r::moreOrEquals(0))
        );
    }
169275
public static com.liferay.commerce.product.model.CPRuleUserSegmentRel deleteCPRuleUserSegmentRel(
		com.liferay.commerce.product.model.CPRuleUserSegmentRel cpRuleUserSegmentRel)
		throws com.liferay.portal.kernel.exception.PortalException {
		return getService().deleteCPRuleUserSegmentRel(cpRuleUserSegmentRel);
	}
1265354
public function addRule(RuleAbstract $rule)
    {
        // Check for allowed instances
        if ($rule instanceof RuleGroupableInterface) {
            $this->rules[] = $rule;
        } else {
            // Invalid rule instance, because only nested statements can be added to conditional group rules.
            $parentClassName = get_class($this);
            $childClassName = get_class($rule);
            $rule->setIsValid(false);
            $rule->addValidationError(
                "Rule instance of type '$childClassName' not allowed " .
                "in conditional group rule of type '$parentClassName'."
            );
            $this->rules[] = $rule;
        }

        return $this;
    }
518887
public final hqlParser.queryRule_return queryRule() throws RecognitionException {
		hqlParser.queryRule_return retval = new hqlParser.queryRule_return();
		retval.start = input.LT(1);

		CommonTree root_0 = null;

		ParserRuleReturnScope selectFrom38 =null;
		ParserRuleReturnScope whereClause39 =null;
		ParserRuleReturnScope groupByClause40 =null;
		ParserRuleReturnScope havingClause41 =null;
		ParserRuleReturnScope orderByClause42 =null;
		ParserRuleReturnScope skipClause43 =null;
		ParserRuleReturnScope takeClause44 =null;


		try {
			// hql.g:233:2: ( selectFrom ( whereClause )? ( groupByClause )? ( havingClause )? ( orderByClause )? ( skipClause )? ( takeClause )? )
			// hql.g:233:4: selectFrom ( whereClause )? ( groupByClause )? ( havingClause )? ( orderByClause )? ( skipClause )? ( takeClause )?
			{
			root_0 = (CommonTree)adaptor.nil();


			pushFollow(FOLLOW_selectFrom_in_queryRule904);
			selectFrom38=selectFrom();
			state._fsp--;

			adaptor.addChild(root_0, selectFrom38.getTree());

			// hql.g:234:3: ( whereClause )?
			int alt9=2;
			int LA9_0 = input.LA(1);
			if ( (LA9_0==WHERE) ) {
				alt9=1;
			}
			switch (alt9) {
				case 1 :
					// hql.g:234:4: whereClause
					{
					pushFollow(FOLLOW_whereClause_in_queryRule909);
					whereClause39=whereClause();
					state._fsp--;

					adaptor.addChild(root_0, whereClause39.getTree());

					}
					break;

			}

			// hql.g:235:3: ( groupByClause )?
			int alt10=2;
			int LA10_0 = input.LA(1);
			if ( (LA10_0==GROUP) ) {
				alt10=1;
			}
			switch (alt10) {
				case 1 :
					// hql.g:235:4: groupByClause
					{
					pushFollow(FOLLOW_groupByClause_in_queryRule916);
					groupByClause40=groupByClause();
					state._fsp--;

					adaptor.addChild(root_0, groupByClause40.getTree());

					}
					break;

			}

			// hql.g:236:3: ( havingClause )?
			int alt11=2;
			int LA11_0 = input.LA(1);
			if ( (LA11_0==HAVING) ) {
				alt11=1;
			}
			switch (alt11) {
				case 1 :
					// hql.g:236:4: havingClause
					{
					pushFollow(FOLLOW_havingClause_in_queryRule923);
					havingClause41=havingClause();
					state._fsp--;

					adaptor.addChild(root_0, havingClause41.getTree());

					}
					break;

			}

			// hql.g:237:3: ( orderByClause )?
			int alt12=2;
			int LA12_0 = input.LA(1);
			if ( (LA12_0==ORDER) ) {
				alt12=1;
			}
			switch (alt12) {
				case 1 :
					// hql.g:237:4: orderByClause
					{
					pushFollow(FOLLOW_orderByClause_in_queryRule930);
					orderByClause42=orderByClause();
					state._fsp--;

					adaptor.addChild(root_0, orderByClause42.getTree());

					}
					break;

			}

			// hql.g:238:3: ( skipClause )?
			int alt13=2;
			int LA13_0 = input.LA(1);
			if ( (LA13_0==SKIP) ) {
				alt13=1;
			}
			switch (alt13) {
				case 1 :
					// hql.g:238:4: skipClause
					{
					pushFollow(FOLLOW_skipClause_in_queryRule937);
					skipClause43=skipClause();
					state._fsp--;

					adaptor.addChild(root_0, skipClause43.getTree());

					}
					break;

			}

			// hql.g:239:3: ( takeClause )?
			int alt14=2;
			int LA14_0 = input.LA(1);
			if ( (LA14_0==TAKE) ) {
				alt14=1;
			}
			switch (alt14) {
				case 1 :
					// hql.g:239:4: takeClause
					{
					pushFollow(FOLLOW_takeClause_in_queryRule944);
					takeClause44=takeClause();
					state._fsp--;

					adaptor.addChild(root_0, takeClause44.getTree());

					}
					break;

			}

			}

			retval.stop = input.LT(-1);

			retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
			adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
			retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);
		}
		finally {
			// do for sure before leaving
		}
		return retval;
	}
1304365
@Override
	@Transactional(enabled = false)
	public CPRuleUserSegmentRel createCPRuleUserSegmentRel(
		long CPRuleUserSegmentRelId) {
		return cpRuleUserSegmentRelPersistence.create(CPRuleUserSegmentRelId);
	}
331039
public final EObject ruleParenthesizedCondition() throws RecognitionException {
        EObject current = null;

        Token otherlv_0=null;
        Token otherlv_2=null;
        EObject this_Disjunction_1 = null;



        	enterRule();

        try {
            // InternalXtext.g:1994:2: ( (otherlv_0= '(' this_Disjunction_1= ruleDisjunction otherlv_2= ')' ) )
            // InternalXtext.g:1995:2: (otherlv_0= '(' this_Disjunction_1= ruleDisjunction otherlv_2= ')' )
            {
            // InternalXtext.g:1995:2: (otherlv_0= '(' this_Disjunction_1= ruleDisjunction otherlv_2= ')' )
            // InternalXtext.g:1996:3: otherlv_0= '(' this_Disjunction_1= ruleDisjunction otherlv_2= ')'
            {
            otherlv_0=(Token)match(input,15,FollowSets000.FOLLOW_26); 

            			newLeafNode(otherlv_0, grammarAccess.getParenthesizedConditionAccess().getLeftParenthesisKeyword_0());
            		

            			newCompositeNode(grammarAccess.getParenthesizedConditionAccess().getDisjunctionParserRuleCall_1());
            		
            pushFollow(FollowSets000.FOLLOW_37);
            this_Disjunction_1=ruleDisjunction();

            state._fsp--;


            			current = this_Disjunction_1;
            			afterParserOrEnumRuleCall();
            		
            otherlv_2=(Token)match(input,16,FollowSets000.FOLLOW_2); 

            			newLeafNode(otherlv_2, grammarAccess.getParenthesizedConditionAccess().getRightParenthesisKeyword_2());
            		

            }


            }


            	leaveRule();

        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }