Returns a string representation for the Rule in the Fuzzy Inference System
format

@param rule is the rule
@param engine is the engine in which the rule is registered
@return a string representation for the rule in the Fuzzy Inference System
format
543991
public String exportRule(Rule rule, Engine engine) {
        List<Proposition> propositions = new ArrayList<Proposition>();
        List<Operator> operators = new ArrayList<Operator>();
        Deque<Expression> queue = new ArrayDeque<Expression>();

        queue.offer(rule.getAntecedent().getExpression());
        while (!queue.isEmpty()) {
            Expression front = queue.poll();
            if (front instanceof Operator) {
                Operator op = (Operator) front;
                queue.offer(op.getLeft());
                queue.offer(op.getRight());
                operators.add(op);
            } else if (front instanceof Proposition) {
                propositions.add((Proposition) front);
            } else {
                throw new RuntimeException(String.format(
                        "[export error] unexpected class <%s>", front.getClass().getName()));
            }
        }
        boolean equalOperators = true;
        for (int i = 0; i < operators.size() - 1; ++i) {
            if (!operators.get(i).getName().equals(operators.get(i + 1).getName())) {
                equalOperators = false;
                break;
            }
        }
        if (!equalOperators) {
            throw new RuntimeException("[export error] "
                    + "fis files do not support rules with different connectors "
                    + "(i.e. ['and', 'or']). All connectors within a rule must be the same");
        }
        List<Variable> inputVariables = new ArrayList<Variable>();
        List<Variable> outputVariables = new ArrayList<Variable>();
        for (InputVariable inputVariable : engine.getInputVariables()) {
            inputVariables.add(inputVariable);
        }
        for (OutputVariable outputVariable : engine.getOutputVariables()) {
            outputVariables.add(outputVariable);
        }

        StringBuilder result = new StringBuilder();
        result.append(translate(propositions, inputVariables)).append(", ");
        result.append(translate(rule.getConsequent().getConclusions(), outputVariables));
        result.append(String.format("(%s)", Op.str(rule.getWeight())));
        String connector;
        if (operators.isEmpty()) {
            connector = "1";
        } else if (Rule.FL_AND.equals(operators.get(0).getName())) {
            connector = "1";
        } else if (Rule.FL_OR.equals(operators.get(0).getName())) {
            connector = "2";
        } else {
            connector = operators.get(0).getName();
        }
        result.append(" : ").append(connector);
        return result.toString();
    }
614173
public String getRuleId() {
    if (GrammarError_Type.featOkTst
        && ((GrammarError_Type) jcasType).casFeat_ruleId == null)
      jcasType.jcas.throwFeatMissing("ruleId", "cogroo.uima.GrammarError");
    return jcasType.ll_cas.ll_getStringValue(addr,
        ((GrammarError_Type) jcasType).casFeatCode_ruleId);
  }
455021
@Override
    public void _fuzzy(double fuzzy) {
        List<QueryToken> tokens = getCurrentWhereTokens();
        if (tokens.isEmpty()) {
            throw new IllegalStateException("Fuzzy can only be used right after where clause");
        }

        QueryToken whereToken = tokens.get(tokens.size() - 1);
        if (!(whereToken instanceof WhereToken)) {
            throw new IllegalStateException("Fuzzy can only be used right after where clause");
        }

        if (((WhereToken) whereToken).getWhereOperator() != WhereOperator.EQUALS) {
            throw new IllegalStateException("Fuzzy can only be used right after where clause with equals operator");
        }

        if (fuzzy < 0.0 || fuzzy > 1.0) {
            throw new IllegalArgumentException("Fuzzy distance must be between 0.0 and 1.0");
        }

        ((WhereToken) whereToken).getOptions().setFuzzy(fuzzy);
    }
173561
public String header(Engine engine) {
        List<String> result = new LinkedList<String>();
        if (exportInputValues) {
            for (InputVariable inputVariable : engine.getInputVariables()) {
                result.add(inputVariable.getName());
            }
        }
        if (exportOutputValues) {
            for (OutputVariable outputVariable : engine.getOutputVariables()) {
                result.add(outputVariable.getName());
            }
        }
        return Op.join(result, separator);
    }
532735
function getRule(recognizer, dfa) {
    const description = dfa.decision.toString();
    const ruleIndex = dfa.atnStartState.ruleIndex;

    const ruleNames = recognizer.ruleNames;
    if (ruleIndex < 0 || ruleIndex >= ruleNames.length) {
        return description;
    }
    const ruleName = ruleNames[ruleIndex] || '<unknown>';
    return description + " (" + ruleName + ")";
}
926597
public String gaAccessor(final EObject ele) {
    String _switchResult = null;
    boolean _matched = false;
    if (ele instanceof AbstractElement) {
      _matched=true;
      _switchResult = this.gaRuleElementAccessor(((AbstractElement)ele));
    }
    if (!_matched) {
      if (ele instanceof AbstractRule) {
        _matched=true;
        _switchResult = this.gaRuleAccessor(((AbstractRule)ele));
      }
    }
    if (!_matched) {
      String _name = ele.eClass().getName();
      String _plus = ("<error: unknown type " + _name);
      _switchResult = (_plus + ">");
    }
    return _switchResult;
  }
252677
public static Rule getRule(final String field, final String value) {
    if (field.equalsIgnoreCase(LoggingEventFieldResolver.LEVEL_FIELD)) {
        return NotLevelEqualsRule.getRule(value);
    } else {
        return new NotEqualsRule(field, value);
    }
  }
498837
public static String prettyPrintRule(Rule rule)
    {
        StringBuilder result = new StringBuilder();
        if (rule instanceof Context)
        {
            final Context context = (Context) rule;
            RuleProvider provider = (RuleProvider) context.get(RuleMetadataType.RULE_PROVIDER);

            if (provider != null && provider.getMetadata() != null)
            {
                result.append(provider.getMetadata().getPhase().getSimpleName()).append(" - ");
                result.append(provider.getMetadata().getID()).append(" - ");
            }

            if (rule.getId() != null)
                result.append(rule.getId());
        }

        return result.toString();
    }
981983
public final EObject ruleKeyword() throws RecognitionException {
        EObject current = null;

        Token lv_value_0_0=null;


        	enterRule();

        try {
            // InternalXtext.g:1533:2: ( ( (lv_value_0_0= RULE_STRING ) ) )
            // InternalXtext.g:1534:2: ( (lv_value_0_0= RULE_STRING ) )
            {
            // InternalXtext.g:1534:2: ( (lv_value_0_0= RULE_STRING ) )
            // InternalXtext.g:1535:3: (lv_value_0_0= RULE_STRING )
            {
            // InternalXtext.g:1535:3: (lv_value_0_0= RULE_STRING )
            // InternalXtext.g:1536:4: lv_value_0_0= RULE_STRING
            {
            lv_value_0_0=(Token)match(input,RULE_STRING,FollowSets000.FOLLOW_2); 

            				newLeafNode(lv_value_0_0, grammarAccess.getKeywordAccess().getValueSTRINGTerminalRuleCall_0());
            			

            				if (current==null) {
            					current = createModelElement(grammarAccess.getKeywordRule());
            				}
            				setWithLastConsumed(
            					current,
            					"value",
            					lv_value_0_0,
            					"org.eclipse.xtext.common.Terminals.STRING");
            			

            }


            }


            }


            	leaveRule();

        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }
1158500
def _parse_engine(engine):
        
        engine = (engine or '').strip()
        backend, path = URI_RE.match(engine).groups()

        if backend not in SUPPORTED_BACKENDS:
            raise NotImplementedError(
                "Logg supports only {0} for now.".format(SUPPORTED_BACKENDS))
        log.debug('Found engine: {0}'.format(engine))
        return backend, path
181033
@Requires({
    "isValidPattern(pattern)",
    "rule != null"
  })
  @Ensures({
    "rule.equals(get(pattern))",
    "!isOverriden(pattern)"
  })
  public void put(String pattern, R rule) {
    String canon = pattern.replace('/', '.');
    boolean exact = !canon.endsWith(".*");
    if (!exact) {
      canon = canon.substring(0, canon.length() - 2);
    }

    String[] parts = canon.split("\\.");

    TernaryNode current = root;
    TernaryNode parent = root;
    int parentIndex = -1;
    for (int i = 0; i < parts.length; ++i) {
      TernaryNode next = current.children.get(parts[i]);
      if (next == null) {
        next = new TernaryNode(null, false);
        current.children.put(parts[i], next);
      }
      if (next.rule != null && !next.exact) {
        parent = next;
        parentIndex = i;
      }
      current = next;
    }

    if (!exact) {
      /* Override patterns beginning with this one. */
      current.children.clear();
    }

    if (!rule.equals(parent.rule)) {
      current.rule = rule;
      current.exact = exact;
    } else {
      /*
       * The new rule we are inserting is already specified through
       * inheritance. Remove spurious nodes. This ensures that any
       * overriding branch is meaningful; that is, it specifies a rule
       * value different from the inherited one.
       */
      current = parent;
      for (int i = parentIndex + 1; i < parts.length; ++i) {
        TernaryNode next = current.children.get(parts[i]);
        if (next.rule == null) {
          current.children.remove(parts[i]);
          break;
        }
      }
    }
  }
20394
static String stripRules(String rules) {
        StringBuilder strippedRules = new StringBuilder();
        int rulesLength = rules.length();
        for (int idx = 0; idx < rulesLength;) {
            char ch = rules.charAt(idx++);
            if (ch == '#') {
                while (idx < rulesLength
                        && ch != '\r' && ch != '\n' && ch != chNEL) {
                    ch = rules.charAt(idx++);
                }
            }
            if (!UCharacter.isISOControl(ch)) {
                strippedRules.append(ch);
            }
        }
        return strippedRules.toString();
    }
279536
public String getRule() {
    if (Clause_Type.featOkTst && ((Clause_Type)jcasType).casFeat_rule == null)
      jcasType.jcas.throwFeatMissing("rule", "com.digitalpebble.rasp.Clause");
    return jcasType.ll_cas.ll_getStringValue(addr, ((Clause_Type)jcasType).casFeatCode_rule);}
18174
public final EObject ruleXStringLiteral() throws RecognitionException {
        EObject current = null;

        Token lv_value_1_0=null;


        	enterRule();

        try {
            // InternalXbaseWithAnnotations.g:5292:2: ( ( () ( (lv_value_1_0= RULE_STRING ) ) ) )
            // InternalXbaseWithAnnotations.g:5293:2: ( () ( (lv_value_1_0= RULE_STRING ) ) )
            {
            // InternalXbaseWithAnnotations.g:5293:2: ( () ( (lv_value_1_0= RULE_STRING ) ) )
            // InternalXbaseWithAnnotations.g:5294:3: () ( (lv_value_1_0= RULE_STRING ) )
            {
            // InternalXbaseWithAnnotations.g:5294:3: ()
            // InternalXbaseWithAnnotations.g:5295:4: 
            {
            if ( state.backtracking==0 ) {

              				current = forceCreateModelElement(
              					grammarAccess.getXStringLiteralAccess().getXStringLiteralAction_0(),
              					current);
              			
            }

            }

            // InternalXbaseWithAnnotations.g:5301:3: ( (lv_value_1_0= RULE_STRING ) )
            // InternalXbaseWithAnnotations.g:5302:4: (lv_value_1_0= RULE_STRING )
            {
            // InternalXbaseWithAnnotations.g:5302:4: (lv_value_1_0= RULE_STRING )
            // InternalXbaseWithAnnotations.g:5303:5: lv_value_1_0= RULE_STRING
            {
            lv_value_1_0=(Token)match(input,RULE_STRING,FOLLOW_2); if (state.failed) return current;
            if ( state.backtracking==0 ) {

              					newLeafNode(lv_value_1_0, grammarAccess.getXStringLiteralAccess().getValueSTRINGTerminalRuleCall_1_0());
              				
            }
            if ( state.backtracking==0 ) {

              					if (current==null) {
              						current = createModelElement(grammarAccess.getXStringLiteralRule());
              					}
              					setWithLastConsumed(
              						current,
              						"value",
              						lv_value_1_0,
              						"org.eclipse.xtext.xbase.Xtype.STRING");
              				
            }

            }


            }


            }


            }

            if ( state.backtracking==0 ) {

              	leaveRule();

            }
        }

            catch (RecognitionException re) {
                recover(input,re);
                appendSkippedTokens();
            }
        finally {
        }
        return current;
    }
1197009
private String getRuleName(RulesTextProvider textProvider)
    {
		if (!quotedString('"',textProvider))
		{
			return "R"+(textProvider.incrementRuleCount());
		}
    	return textProvider.getLastToken();
    }
698812
public static void processRuleElement(ParserContext context, ConfigurationRuleBuilder rule, Element element)
    {
        String id = $(element).attr("id");

        List<Element> children = $(element).children().get();
        for (Element child : children)
        {
            Object result = context.processElement(child);

            switch ($(child).tag())
            {
            case "when":
                rule.when(((Condition) result));
                break;

            case "perform":
                rule.perform(((Operation) result));
                break;

            case "otherwise":
                rule.otherwise(((Operation) result));
                break;

            case "where":
                break;
            }
        }

        if (StringUtils.isNotBlank(id))
        {
            rule.withId(id);
        }

    }
693491
public final String entryRuleGrammarID() throws RecognitionException {
        String current = null;

        AntlrDatatypeRuleToken iv_ruleGrammarID = null;


        try {
            // InternalXtext.g:252:49: (iv_ruleGrammarID= ruleGrammarID EOF )
            // InternalXtext.g:253:2: iv_ruleGrammarID= ruleGrammarID EOF
            {
             newCompositeNode(grammarAccess.getGrammarIDRule()); 
            pushFollow(FollowSets000.FOLLOW_1);
            iv_ruleGrammarID=ruleGrammarID();

            state._fsp--;

             current =iv_ruleGrammarID.getText(); 
            match(input,EOF,FollowSets000.FOLLOW_2); 

            }

        }

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