public void Learn(string cucumberProjectDir)
        {
            GetStepDefList(cucumberProjectDir);
            var featuresData = LexicParcer.ParseFolder(cucumberProjectDir);

            Parallel.ForEach(featuresData, (fileInfo) => {
                foreach (var step in fileInfo.Steps)
                {
                    foreach (var stepDefRegex in _stepDefRegexes)
                    {
                        if (!_multiLangRegex.IsMatch(step.Text))
                        {
                            continue;
                        }
                        var mach = stepDefRegex.Key.Match(step.Text);
                        if (!mach.Success)
                        {
                            continue;
                        }
                        stepDefRegex.Value.Add(step);
                        break;
                    }
                }
            });
            var data = _stepDefRegexes.Where(i => i.Value.Count > 0).ToDictionary(i => i.Key, i => i.Value);

            _stepDefRegexes = data;
        }
Exemplo n.º 2
0
        public List <LineTranslationConfig> GeTranslationConfigs(string fileName, IDialogService dialogService)
        {
            var fileInfo = LexicParcer.ParseFile(fileName);
            var res      = new List <LineTranslationConfig>();

            foreach (var step in fileInfo.Steps)
            {
                var stepDef = _featureLocalizer.StepDefStore.StepDefs.FirstOrDefault(s => s.Exp.IsMatch(step.Text));
                if (stepDef == null)
                {
                    continue;
                }
                foreach (var parameter in stepDef.Params)
                {
                    var config = new LineTranslationConfig {
                        LineNumber = step.Line,
                        Regex      = stepDef.Exp,
                        WordIndex  = parameter.Index,
                        Variants   = new ObservableCollection <LineTranslationVariant>()
                    };
                    List <string> existItems = new List <string>();
                    foreach (var storeItem in parameter.ValueStoreGroup.Items)
                    {
                        if (existItems.Contains(storeItem.RuRu, StringComparer.OrdinalIgnoreCase))
                        {
                            continue;
                        }
                        existItems.Add(storeItem.RuRu);
                        config.Variants.Add(new LineTranslationVariant {
                            Config  = config,
                            NameRu  = storeItem.RuRu,
                            NameEng = storeItem.EnUs
                        });
                    }
                    config.Variants.Add(new NewLineTranslationVariant(_featureLocalizer, parameter.ValueStoreGroup, dialogService)
                    {
                        Config  = config,
                        NameRu  = "+ Добавить",
                        NameEng = "Add new"
                    });
                    config.SortVariants();
                    res.Add(config);
                }
            }
            return(res);
        }