Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16879


Ignore:
Timestamp:
05/02/19 07:50:22 (6 years ago)
Author:
chaider
Message:

#2971 Removed unused parser method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraintsParser.cs

    r16865 r16879  
    2727namespace HeuristicLab.Problems.DataAnalysis {
    2828  public static class IntervalConstraintsParser {
    29     public static IEnumerable<IntervalConstraint> Parse(string input) {
    30       var options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
    31       var matches = Regex.Matches(input, @"^(.*)\bin\b\s*([\[\]])(.*[^\s])(\s*\.\.\s*)([^\s].*)([\[\]])\n*\r*\s*$", options);
    3229
    33       for (var i = 0; i < matches.Count; ++i) {
    34         if (matches[i].Groups.Count == 7) {
    35           var intervalConstraint = new IntervalConstraint();
    36           //pattern 1 = defintion
    37           var definition = Regex.Replace(matches[i].Groups[1].Value, @"\s *", "");
    38           if (Regex.IsMatch(definition, @"\/")) {
    39             var splitted = Regex.Split(definition.Replace(" ", string.Empty), @"\/");
    40             var match = Regex.Match(splitted[0], @"([d∂])([0-9]|[²³])?(.*[^\s*])");
    41             if (match.Success) {
    42               intervalConstraint.NumberOfDerivation = match.Groups[2].Success ? ParseDerivationCount(match.Groups[2].Value) : 1;
    43               intervalConstraint.Definition = match.Groups[3].Value;
    44               intervalConstraint.IsDerivation = true;
    45               var formulation = Regex.Match(splitted[1], @"([d∂])(.*[^²³])([²³])?");
    46               if (formulation.Success) {
    47                 intervalConstraint.Variable = formulation.Groups[2].Success ? formulation.Groups[2].Value : "";
    48               }
    49             } else {
    50               throw new ArgumentException($"An error occured in the derivation part: {splitted[0]}");
    51             }
    52           } else {
    53             intervalConstraint.Definition = Regex.Match(definition, @".*[^.\s]*").Value;
    54             intervalConstraint.IsDerivation = false;
    55           }
    56           intervalConstraint.Expression = matches[i].Groups[0].Value.Trim(' ', '\t', '\n', '\r');
    57           intervalConstraint.InclusiveLowerBound = (matches[i].Groups[2].Value == "[");
    58           intervalConstraint.InclusiveUpperBound = (matches[i].Groups[6].Value == "]");
    59           intervalConstraint.Interval = new Interval(ParseIntervalBounds(matches[i].Groups[3].Value.Replace(" ", string.Empty)),
    60             ParseIntervalBounds(matches[i].Groups[5].Value.Replace(" ", string.Empty)));
    61 
    62           yield return intervalConstraint;
    63         } else {
    64           throw new ArgumentException($"The given constraint: {matches[i].Value} is not valid.");
    65         }
    66       }
    67     }
    68 
    69    
    7030    public static IEnumerable<IntervalConstraint> ParseInput(string input, string target = "", IEnumerable<string> variables = null) {
    7131      var lines = input.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
Note: See TracChangeset for help on using the changeset viewer.