public Parameters GenerateParameters(CodeFileCSharp input, Settings pluginSettings, IMetadataReader metadataReader, ILogger logger, IFileGroup <CodeFileCSharp, GroupItemDetails> fileGroup = null)
        {
            if (string.IsNullOrEmpty(pluginSettings.AstDescriptionJsonFilePath))
            {
                throw new InvalidOperationException($"Setting {Settings.AstDescriptionJsonFilePathKey} should be provided.");
            }

            var path = pluginSettings.AstDescriptionJsonFilePath;

            if (!Path.IsPathRooted(pluginSettings.AstDescriptionJsonFilePath))
            {
                path = Path.Combine(pluginSettings.BasePath, pluginSettings.AstDescriptionJsonFilePath);
            }

            var payload = File.ReadAllText(path);

            var description = JsonConvert.DeserializeObject <Root>(payload);

            var fixer = new InstanceReferenceFixer();

            description = (Root)fixer.FixInstanceReferences(description);

            var analyzer       = new DescriptionAnalyzer(pluginSettings);
            var astDescription = analyzer.Analyze(description);

            var parametersBuilder = new ParametersBuilder(pluginSettings);

            return(parametersBuilder.CreateParameters(astDescription));
        }
Exemple #2
0
        public void TokenizerLowercasesCamelCasesAndRemovesStopWordsInput(string text, TokenAttributes[] expected)
        {
            // arrange, act
            var actual = new DescriptionAnalyzer().Tokenize(text);

            // assert
            Assert.Equal(expected, actual);
        }
Exemple #3
0
        public void TokenizerRemovesCorrectStopWords(string stopWord)
        {
            // arrange, act
            var text     = string.Format("stop {0} word", stopWord);
            var actual   = new DescriptionAnalyzer().Tokenize(text);
            var expected = new[]
            {
                new TokenAttributes("stop", 0, 4, 1),
                new TokenAttributes("word", 6 + stopWord.Length, 10 + stopWord.Length, 2)
            };

            // assert
            Assert.Equal(expected, actual);
        }
Exemple #4
0
        static void Test2()
        {
            //string query = "signalrClient";
            //string query = "microsoft";
            string query = "HttpAgilityPack";

            //string description = "Misc MPL Libraries from CodePlex: HttpAgilityPack, InputSimulator, Irony Parser, WCF Rest Start Kit, XObjects\n\nUses the FluentSharp APIs";

            DescriptionAnalyzer analyzer = new DescriptionAnalyzer();

            TokenStream tokenStream = analyzer.TokenStream("", new StringReader(query));

            ITermAttribute termAttribute = tokenStream.AddAttribute <ITermAttribute>();

            while (tokenStream.IncrementToken())
            {
                Console.WriteLine(termAttribute.Term);
            }
        }