Ejemplo n.º 1
0
        private void UpdateClassifiers()
        {
            var settings = Settings.Load();
            var patterns = settings.Patterns ?? new RegExClassification[0];

            var classifiers = patterns.Select(
                pattern => new
            {
                classificationType = pattern.ClassificationType.ToString(),
                test = RegExClassification.RegExFactory(pattern)
            })
                              .Select(temp => new Classifier
            {
                Type = temp.classificationType,
                Test = text => temp.test.IsMatch(text)
            })
                              .ToList();

            classifiers.Add(new Classifier
            {
                Type = ClassificationTypeDefinitions.BuildText,
                Test = t => true
            });

            _classifiers = classifiers;
        }
Ejemplo n.º 2
0
        private void UpdateClassifiers()
        {
            var settings = Settings.Load();
            var patterns = settings.Patterns ?? Array.Empty <RegExClassification>();

            _classifiers = patterns.Select(
                pattern => new Classifier
            {
                Type = pattern.ClassificationType.ToString(),
                Test = RegExClassification.RegExFactory(pattern).IsMatch
            })
                           .Append(new Classifier
            {
                Type = ClassificationTypeDefinitions.BuildText,
                Test = t => true
            })
                           .ToList();
        }