Example #1
0
        private Task CreateIndexAsync(string indexName)
        {
            var suggester = new Suggester
            {
                Name = "sg",
                //SearchMode = "analyzingInfixMatching",
                SourceFields = new List <string> {
                    "Name", "FacilityName"
                }
            };

            var definition = new Index
            {
                Name   = indexName,
                Fields = new List <Field>
                {
                    new Field("Id", DataType.String)
                    {
                        IsKey = true
                    },
                    new Field("FacilityId", DataType.Int32)
                    {
                        IsFilterable = true
                    },
                    new Field("Name", DataType.String, AnalyzerName.EnMicrosoft)
                    {
                        IsSearchable = true
                    },
                    new Field("Description", DataType.String, AnalyzerName.EnMicrosoft)
                    {
                        IsSearchable = true
                    },
                    new Field("FacilityName", DataType.String, AnalyzerName.EnMicrosoft)
                    {
                        IsSearchable = true
                    },
                    new Field("FacilityDescription", DataType.String, AnalyzerName.EnMicrosoft)
                    {
                        IsSearchable = true
                    },
                    new Field("Location", DataType.GeographyPoint)
                    {
                        IsFilterable = true
                    },
                    new Field("RoomCount", DataType.Int32)
                    {
                        IsFilterable = true
                    },
                    new Field("Images", DataType.Collection(DataType.String))
                    {
                        IsFilterable = false
                    }
                },
                Suggesters = new List <Suggester> {
                    suggester
                }
            };

            return(client.Indexes.CreateAsync(definition));
        }
Example #2
0
 public void addSuggestionsToLabels()
 {
     suggestionsList = Suggester.getSuggestions(currentWord);
     for (int i = 0; i < 4; i++)
     {
         try
         {
             if (suggestionsList[i].Length < 9 && !naturalSugFontSize[i])
             {
                 naturalSugFontSize[i] = true;
                 adjustSuggestionSize(i, true);
             }
             if (suggestionsList[i].Length > 9 && naturalSugFontSize[i])
             {
                 naturalSugFontSize[i] = false;
                 adjustSuggestionSize(i, false);
             }
             suggestionLabel[i].Text = suggestionsList[i];
         }
         catch
         {
             if (!naturalSugFontSize[i])
             {
                 naturalSugFontSize[i] = true;
                 adjustSuggestionSize(i, true);
             }
             suggestionLabel[i].Text = "";
         }
     }
 }
Example #3
0
 private void Window_Closed(object sender, EventArgs e)
 {
     Suggester.saveInDisk();
     try
     {
         gp.OnExit();
     }
     catch
     {
         Console.WriteLine("Didn't close camera (probably in mouse mode, if not, something's wrong!");
     }
     if (!File.Exists(path))
     {
         using (StreamWriter writer = new StreamWriter(path, true, System.Text.Encoding.UTF8))
         {
             writer.WriteLine(txtInput.Text);
         }
     }
     if (!File.Exists(path2))
     {
         using (StreamWriter writer = new StreamWriter(path2, true, System.Text.Encoding.UTF8))
         {
             writer.WriteLine(characterTimestampRecord);
         }
     }
 }
Example #4
0
        public SuggesterEvaluator(Suggester sugg)
        {
            ToEvaluate = sugg;

            if (readDesiredResultMatrixForSuggester())//if benchmark exists
                analyseResults();
        }
Example #5
0
        public void addSuggestionsToLabels()
        {
            string auxiliar = "4sugs";

            suggestionsList = Suggester.getSuggestions(currentWord);
            for (int i = 0; i < 4; i++)
            {
                try
                {
                    if (suggestionsList[i].Length < 9 && !naturalSugFontSize[i])
                    {
                        naturalSugFontSize[i] = true;
                        adjustSuggestionSize(i, true);
                    }
                    if (suggestionsList[i].Length > 9 && naturalSugFontSize[i])
                    {
                        naturalSugFontSize[i] = false;
                        adjustSuggestionSize(i, false);
                    }
                    suggestionLabel[i].Text = suggestionsList[i];
                }
                catch
                {
                    if (!naturalSugFontSize[i])
                    {
                        naturalSugFontSize[i] = true;
                        adjustSuggestionSize(i, true);
                    }
                    suggestionLabel[i].Text = "";
                }
                auxiliar += "|" + suggestionLabel[i].Text;
            }
            characterTimestampRecord += auxiliar + "\n";
        }
Example #6
0
        //accepts one of the suggestions
        public void acceptSuggestion(int which)
        {
            if (suggestionLabel[which].Text != "")
            {
                chosenWord = suggestionLabel[which].Text;
                // guarantees that if the suggestion was a mistake, the next deletion will make it rollback
                textBeforeAcceptance   = txtInput.Text;
                justAcceptedSuggestion = true;
                justAddedSpace         = false;


                txtInput.Text = txtInput.Text.Substring(0, txtInput.Text.Length - currentWord.Length);
                if (currentWord[0].ToString().ToUpper() == currentWord[0].ToString())
                {
                    chosenWord = chosenWord.Substring(0, 1).ToUpper() + chosenWord.Substring(1, chosenWord.Length - 1);
                }
                txtInput.Text            += chosenWord + " ";
                characterTimestampRecord += "sug|" + which.ToString() + "|" + dataTimer.ElapsedMilliseconds.ToString() + "\n";
                chosenWord.ToLower();

                Suggester.indexWord(chosenWord);
                for (int i = 0; i < 4; i++) //Clear all the suggestion labels
                {
                    suggestionLabel[i].Text = "";
                }
                nextWordInSentence();
                currentWord = "";
            }
        }
Example #7
0
        public static void CreateSearchIndex()
        {
            try
            {
                //connect to Azure Search
                SearchServiceClient serviceClient = CreateSearchServiceClient();

                //defining the suggester
                Suggester sg = new Suggester
                {
                    Name         = "eecip_suggest",
                    SourceFields = new List <string>()
                    {
                        "Name"
                    }
                };

                //defining the scoring profile //boosts items updated in the last 180 days
                ScoringProfile sp = new ScoringProfile {
                    Name = "date_scoring"
                };

                var freshnessFunction = new FreshnessScoringFunction()
                {
                    FieldName     = "LastUpdated",
                    Boost         = 20,
                    Parameters    = new FreshnessScoringParameters(new TimeSpan(180, 0, 0, 0)),
                    Interpolation = ScoringFunctionInterpolation.Linear
                };
                // Assigns the freshness function to the scoring profile
                sp.Functions = new List <ScoringFunction>()
                {
                    freshnessFunction
                };


                //define the index (the fields, and link in the suggester and scoring)
                var definition = new Index()
                {
                    Name       = "eecip",
                    Fields     = FieldBuilder.BuildForType <EECIP_Index>(),
                    Suggesters = new List <Suggester> {
                        sg
                    },
                    ScoringProfiles = new List <ScoringProfile>()
                    {
                        sp
                    }
                };



                serviceClient.Indexes.Create(definition);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
            protected override async Task <TestBlockchain> Build(ISpecProvider?specProvider = null, UInt256?initialValues = null)
            {
                TestBlockchain chain = await base.Build(specProvider, initialValues);

                await chain.BlockchainProcessor.StopAsync(true);

                Suggester.Dispose();
                return(chain);
            }
        private static void AssertSuggestersEqual(Suggester expected, Suggester actual)
        {
            Assert.NotNull(expected);
            Assert.NotNull(actual);

            Assert.Equal(expected.Name, actual.Name);
            Assert.Equal(expected.SearchMode, actual.SearchMode);

            AssertCollectionsEqual(expected.SourceFields, actual.SourceFields);
        }
        public async Task <bool> CreateOrUpdateIndexAsync(string indexName, CreateIndexFieldsCallback createIndexFieldsCallback,
                                                          CreateIndexSuggesterCallback createSuggesterCallback, int creationDelay = 0)
        {
            try
            {
                var fields = new List <Field>();
                createIndexFieldsCallback.Invoke(
                    (name, type, isKey, isSearchable, isFilterable, isSortable, isFacetable, isRetrievable) =>
                {
                    fields.Add(new Field()
                    {
                        Name          = name,
                        Type          = GetEdmType(type),
                        IsKey         = isKey,
                        IsSearchable  = isSearchable,
                        IsFilterable  = isFilterable,
                        IsSortable    = isSortable,
                        IsFacetable   = isFacetable,
                        IsRetrievable = isRetrievable
                    });
                });

                var suggester = default(Suggester);
                createSuggesterCallback.Invoke((name, fieldNames) =>
                {
                    suggester = new Suggester
                    {
                        Name         = name,
                        SourceFields = fieldNames
                    };
                });

                var definition = new Index()
                {
                    Name   = indexName,
                    Fields = fields,
                };
                if (default(Suggester) != suggester)
                {
                    definition.Suggesters.Add(suggester);
                }

                var response = await searchClient.Indexes.CreateOrUpdateAsync(definition);

                await Task.Delay(creationDelay);

                return(true);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"Error creating index: {ex.Message}\r\n");
            }
        }
Example #11
0
        private static void CreateIndex(string indexName, string suggesterName)
        {
            // Create the Azure Search index based on the included schema
            try
            {
                // Create the suggester for suggestions
                Suggester sg = new Suggester();
                sg.Name         = suggesterName;
                sg.SearchMode   = SuggesterSearchMode.AnalyzingInfixMatching;
                sg.SourceFields = new List <string>()
                {
                    "name", "county"
                };

                var definition = new Index()
                {
                    Name   = indexName,
                    Fields = new[]
                    {
                        new Field("id", DataType.String)
                        {
                            IsKey = true, IsSearchable = false, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("name", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("county", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("elevation", DataType.Int64)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("location", DataType.GeographyPoint)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                    },
                    Suggesters = new List <Suggester> {
                        sg
                    }
                };

                _searchClient.Indexes.Create(definition);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error creating index: {0}\r\n", ex.Message.ToString());
            }
        }
Example #12
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            alarm = new SoundPlayer(Properties.Resources.beep01);
            //alarm.Play();
            loudAlarm = new SoundPlayer(Properties.Resources.loudAlarm);
            //loudAlarm.Play();
            stateTransition = new SoundPlayer(Properties.Resources.flip);
            //stateTransition.Play();
            //stateTransition.PlayLooping();

            //initial system values
            composition     = "-";
            isCancelled     = false;
            charToPrint     = "";
            primaryKeyboard = true;
            blockType       = 0;
            isBlocked       = false;
            //suggestionLabel = new Label[4];
            suggestionLabel = new TextBlock[4];
            for (int i = 1; i < 5; i++) //References the suggestion labels with an array and clear their "Content" property
            {
                suggestionLabel[i - 1]      = (TextBlock)(FindName("sug" + i));
                suggestionLabel[i - 1].Text = "";
            }
            suggestionStackPanel = new StackPanel[4];
            for (int i = 1; i < 5; i++) //References the suggestion labels with an array and clear their "Content" property
            {
                suggestionStackPanel[i - 1] = (StackPanel)(FindName("view" + i));
            }
            changeObjectsSize();
            //initialize the Suggester
            Suggester.initializeSuggester();
            suggestionsList = new List <string>();
            currentWord     = "";
            //every 2 seconds after the keyboardTimer has started, the changeKeyboard function will be called
            keyboardTimer.Interval = 2000;
            keyboardTimer.Elapsed += new ElapsedEventHandler(changeKeyboard);

            dataTimer.Start();

            //Mouse.OverrideCursor = Cursors.None; //remove mouse
            //EyeTracker data retrieval
            try
            {
                //gp = new GazePoint();
            }
            catch
            {
                Console.WriteLine("No camera found! Mouse mode! :)");
            }
        }
        public bool CreateIndex(string indexName, CreateIndexFieldsCallback createIndexFieldsCallback, CreateIndexSuggesterCallback createSuggesterCallback)
        {
            try
            {
                var fields = new List <Field>();
                createIndexFieldsCallback.Invoke(
                    (name, type, isKey, isSearchable, isFilterable, isSortable, isFacetable, isRetrievable) =>
                {
                    fields.Add(new Field()
                    {
                        Name          = name,
                        Type          = GetEdmType(type),
                        IsKey         = isKey,
                        IsSearchable  = isSearchable,
                        IsFilterable  = isFilterable,
                        IsSortable    = isSortable,
                        IsFacetable   = isFacetable,
                        IsRetrievable = isRetrievable
                    });
                });

                var suggester = default(Suggester);
                createSuggesterCallback.Invoke((name, names) =>
                {
                    suggester = new Suggester
                    {
                        Name         = name,
                        SourceFields = names
                    };
                });

                var definition = new Index()
                {
                    Name   = indexName,
                    Fields = fields
                };
                if (default(Suggester) != suggester)
                {
                    definition.Suggesters.Add(suggester);
                }

                var response = searchClient.Indexes.Create(definition);
                return(response.StatusCode == HttpStatusCode.Created || response.StatusCode == HttpStatusCode.OK);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException($"Error creating index: {ex.Message}\r\n");
            }
        }
Example #14
0
        private void OnSearchQueryUpdate(string searchQuery)
        {
            var start = DateTime.UtcNow;
            var temp  = Suggester.SuggestionsFor(searchQuery)
                        .Take(50);

            SearchResults = temp
                            .Select(sr => new SearchResultViewModel
            {
                HighlightedName = HighlightMatchedSubstrings(sr.Node.IndexOn, sr.MatchRanges),
                Entity          = sr.Node
            })
                            .ToList();
            var end = DateTime.UtcNow;

            Console.WriteLine("Measured time: " + (end - start).TotalMilliseconds + "ms");
        }
Example #15
0
        /// <summary>
        /// 文本推荐(句子级别,从一系列句子中挑出与输入句子最相似的那一个)
        /// 在搜索引擎的输入框中,用户输入一个词,搜索引擎会联想出最合适的搜索词,HanLP实现了类似的功能。
        /// 可以动态调节每种识别器的权重
        /// 搜索推荐
        /// </summary>
        public void TxtSuggest()
        {
            Suggester suggester = new Suggester();

            string[] titleArray =
                (
                    "威廉王子发表演说 呼吁保护野生动物\n" +
                    "《时代》年度人物最终入围名单出炉 普京马云入选\n" +
                    "“黑格比”横扫菲:菲吸取“海燕”经验及早疏散\n" +
                    "日本保密法将正式生效 日媒指其损害国民知情权\n" +
                    "英报告说空气污染带来“公共健康危机”"
                ).Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (var title in titleArray)
            {
                suggester.addSentence(title);
            }
            Console.WriteLine(suggester.suggest("发言", 1));     // 语义
            Console.WriteLine(suggester.suggest("危机公共", 1));   // 字符
            Console.WriteLine(suggester.suggest("mayun", 1));  // 拼音
        }
Example #16
0
        private void CreateAzureIndex(SearchServiceClient serviceClient)
        {
            #region Delete and Create an Index
            DeleteIndexIfExists(serviceClient);

            var accountIndexDefinition = new Index()
            {
                Name   = indexName,
                Fields = FieldBuilder.BuildForType <Account>()
            };

            #region Add Suggestors
            var suggestor = new Suggester(autoCompleteSuggestor);
            suggestor.SourceFields.Add("firstName");
            suggestor.SourceFields.Add("lastName");

            accountIndexDefinition.Suggesters = new List <Suggester>();
            accountIndexDefinition.Suggesters.Add(suggestor);
            #endregion

            serviceClient.Indexes.CreateOrUpdate(accountIndexDefinition);
            #endregion

            //if (!serviceClient.Indexes.Exists(indexName))
            //{
            //    var accountIndexDefinition = new Index()
            //    {
            //        Name = indexName,
            //        Fields = FieldBuilder.BuildForType<Account>()
            //    };
            //    serviceClient.Indexes.Create(accountIndexDefinition);
            //}

            ISearchIndexClient indexClient = serviceClient.Indexes.GetClient(indexName);

            if (indexClient != null)
            {
                ImportData(indexClient);
            }
        }
        public void GetSuggestions_Tests(float targetCurrent, int suggestionsExpected)
        {
            var connectorsList = new List <Connector>
            {
                new Connector()
                {
                    MaxCurrent = 44, ChargeStationId = 1
                },
                new Connector()
                {
                    MaxCurrent = 10, ChargeStationId = 1
                },
                new Connector()
                {
                    MaxCurrent = 8.9f, ChargeStationId = 2
                },
                new Connector()
                {
                    MaxCurrent = 1.1f, ChargeStationId = 2
                },
                new Connector()
                {
                    MaxCurrent = 20, ChargeStationId = 3
                },
                new Connector()
                {
                    MaxCurrent = 30, ChargeStationId = 3
                },
                new Connector()
                {
                    MaxCurrent = 10, ChargeStationId = 4
                },
            };

            var suggester   = new Suggester();
            var suggestions = suggester.GetSuggestions(connectorsList, targetCurrent);


            Assert.Equal(suggestionsExpected, suggestions.Count);
        }
Example #18
0
        //accepts one of the suggestions
        public void acceptSuggestion(int which)
        {
            if (suggestionLabel[which].Text != "")
            {
                string chosenWord = suggestionLabel[which].Text;
                txtInput.Text = txtInput.Text.Substring(0, txtInput.Text.Length - currentWord.Length);
                if (currentWord[0].ToString().ToUpper() == currentWord[0].ToString())
                {
                    chosenWord = chosenWord.Substring(0, 1).ToUpper() + chosenWord.Substring(1, chosenWord.Length - 1);
                }
                txtInput.Text            += chosenWord + " ";
                characterTimestampRecord += "sug|" + chosenWord + "|" + dataTimer.ElapsedMilliseconds.ToString() + "\n";
                chosenWord.ToLower();

                Suggester.indexWord(chosenWord);
                for (int i = 0; i < 4; i++) //Clear all the suggestion labels
                {
                    suggestionLabel[i].Text = "";
                }
                currentWord = "";
            }
        }
        static void Main()
        {
            NGramService       ngrammer     = new NGramService();
            ConcordanceService concordancer = new ConcordanceService();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            MainWindow        main      = new MainWindow();
            CSVLoader         loader    = new CSVLoader();
            LinearHeatmapForm heatmap   = new LinearHeatmapForm();
            DelimiterStep     delim     = new DelimiterStep();
            ChartForm         chart     = new ChartForm();
            Suggester         suggester = new Suggester();

            CSVReadService                    fileReader = new CSVReadService();
            SearchService                     searcher   = new SearchService();
            HeatmapService                    heater     = new HeatmapService();
            FolderService                     folder     = new FolderService();
            DatasetStatisticsService          dataset    = new DatasetStatisticsService();
            TaggedCollectionStatisticsService corpus     = new TaggedCollectionStatisticsService();

            //var tagger = main;
            TagService       service          = new TagService();
            TagsetEditor     editor           = new TagsetEditor();
            TagFileWriter    writer           = new TagFileWriter();
            TagPresenter     tagPresenter     = new TagPresenter(main, main, service, editor, writer);
            TagsetPresenter  tagsetPresenter  = new TagsetPresenter(editor, service, main);
            SuggestPresenter suggestPresenter = new SuggestPresenter(suggester, main, main);
            MainPresenter    presenter        = new MainPresenter(main, main, service, loader, searcher, folder, dataset, corpus, concordancer, ngrammer);

            CSVPresenter     csv = new CSVPresenter(main, loader, fileReader, delim);
            HeatmapPresenter heatmapPresenter = new HeatmapPresenter(main, heatmap, heater);
            ChartPresenter   chartPresenter   = new ChartPresenter(main, chart);

            main.AddOwnedForm(delim);
            Application.Run(main);
        }
        public IRequest Marshall(DefineSuggesterRequest defineSuggesterRequest)
        {
            IRequest request = new DefaultRequest(defineSuggesterRequest, "AmazonCloudSearch");

            request.Parameters.Add("Action", "DefineSuggester");
            request.Parameters.Add("Version", "2013-01-01");
            if (defineSuggesterRequest != null && defineSuggesterRequest.IsSetDomainName())
            {
                request.Parameters.Add("DomainName", StringUtils.FromString(defineSuggesterRequest.DomainName));
            }
            if (defineSuggesterRequest != null)
            {
                Suggester suggester = defineSuggesterRequest.Suggester;
                if (suggester != null && suggester.IsSetSuggesterName())
                {
                    request.Parameters.Add("Suggester.SuggesterName", StringUtils.FromString(suggester.SuggesterName));
                }
                if (suggester != null)
                {
                    DocumentSuggesterOptions documentSuggesterOptions = suggester.DocumentSuggesterOptions;
                    if (documentSuggesterOptions != null && documentSuggesterOptions.IsSetSourceField())
                    {
                        request.Parameters.Add("Suggester.DocumentSuggesterOptions.SourceField", StringUtils.FromString(documentSuggesterOptions.SourceField));
                    }
                    if (documentSuggesterOptions != null && documentSuggesterOptions.IsSetFuzzyMatching())
                    {
                        request.Parameters.Add("Suggester.DocumentSuggesterOptions.FuzzyMatching", StringUtils.FromString(documentSuggesterOptions.FuzzyMatching));
                    }
                    if (documentSuggesterOptions != null && documentSuggesterOptions.IsSetSortExpression())
                    {
                        request.Parameters.Add("Suggester.DocumentSuggesterOptions.SortExpression", StringUtils.FromString(documentSuggesterOptions.SortExpression));
                    }
                }
            }

            return(request);
        }
Example #21
0
        private static void CreateIndex()
        {
            // Create the Azure Search index based on the included schema
            try
            {
                // Create the suggester for suggestions
                Suggester sg = new Suggester();
                sg.Name         = "sg";
                sg.SearchMode   = SuggesterSearchMode.AnalyzingInfixMatching;
                sg.SourceFields = new List <string>()
                {
                    "FEATURE_NAME", "COUNTY_NAME"
                };


                var definition = new Index()
                {
                    Name   = "geonames",
                    Fields = new[]
                    {
                        new Field("FEATURE_ID", DataType.String)
                        {
                            IsKey = true, IsSearchable = false, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("FEATURE_NAME", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("FEATURE_CLASS", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("STATE_ALPHA", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("STATE_NUMERIC", DataType.Int32)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("COUNTY_NAME", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("COUNTY_NUMERIC", DataType.Int32)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("ELEV_IN_M", DataType.Int32)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("ELEV_IN_FT", DataType.Int32)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("MAP_NAME", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = true, IsSortable = true, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("DESCRIPTION", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("HISTORY", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("LOCATION", DataType.GeographyPoint)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("DATE_CREATED", DataType.DateTimeOffset)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("DATE_EDITED", DataType.DateTimeOffset)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        }
                    },
                    Suggesters = new List <Suggester> {
                        sg
                    }
                };

                _searchClient.Indexes.Create(definition);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error creating index: {0}\r\n", ex.Message.ToString());
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");



            float target = 9;

            var connectorsList = new List <Connector>();

            connectorsList.Add(new Connector()
            {
                MaxCurrent = 6, ChargeStationId = 1, CK_Id = 1
            });
            connectorsList.Add(new Connector()
            {
                MaxCurrent = 5, ChargeStationId = 2, CK_Id = 2
            });
            connectorsList.Add(new Connector()
            {
                MaxCurrent = 4, ChargeStationId = 3, CK_Id = 3
            });
            connectorsList.Add(new Connector()
            {
                MaxCurrent = 3, ChargeStationId = 4, CK_Id = 4
            });
            connectorsList.Add(new Connector()
            {
                MaxCurrent = 3, ChargeStationId = 7, CK_Id = 7
            });
            //  connectorsList.Add(new Connector() { MaxCurrent = 3, ChargeStationId = 5, CK_Id = 5 });
            //  connectorsList.Add(new Connector() { MaxCurrent = 1, ChargeStationId = 6, CK_Id = 6 });

            //connectorsList.Add(new Connector() { MaxCurrent = 33, ChargeStationId = 1, CK_Id = 1 });
            //connectorsList.Add(new Connector() { MaxCurrent = 20, ChargeStationId = 2, CK_Id = 2 });
            //connectorsList.Add(new Connector() { MaxCurrent = 19, ChargeStationId = 3, CK_Id = 3 });
            //connectorsList.Add(new Connector() { MaxCurrent = 17, ChargeStationId = 4, CK_Id = 4 });
            //connectorsList.Add(new Connector() { MaxCurrent = 16, ChargeStationId = 4, CK_Id = 4 });
            //connectorsList.Add(new Connector() { MaxCurrent = 10, ChargeStationId = 5, CK_Id = 5 });
            //connectorsList.Add(new Connector() { MaxCurrent = 9, ChargeStationId = 6, CK_Id = 6 });
            //connectorsList.Add(new Connector() { MaxCurrent = 3, ChargeStationId = 7, CK_Id = 7 });
            //connectorsList.Add(new Connector() { MaxCurrent = 2, ChargeStationId = 8, CK_Id = 8 });
            //connectorsList.Add(new Connector() { MaxCurrent = 17, ChargeStationId = 9, CK_Id = 9 });



            ///////


            var watch2 = System.Diagnostics.Stopwatch.StartNew();

            var suggestions2 = ConnectorRemovalSuggestionService.SuggestConnectors(connectorsList, target);

            watch2.Stop();
            var elapsedMs2 = watch2.ElapsedMilliseconds;

            Console.WriteLine("Suggestions count : " + suggestions2.Count);
            Console.WriteLine("Time : " + elapsedMs2);

            foreach (var item in suggestions2)
            {
                Console.WriteLine("Suggestion Start : ***********");
                foreach (var element in item)
                {
                    Console.WriteLine($"ID : {element.ConnectorId} chargeStationID : {element.StationId} MaxCurrent : {element.ConnectorCurrent}");
                }
                Console.WriteLine("Suggestion End  **************");
            }



            Console.WriteLine("\nThe Other Solution  //////////////////////////**************");
            Console.WriteLine("**************\n");


            var suggester = new Suggester();

            var watch = System.Diagnostics.Stopwatch.StartNew();

            var suggestions = suggester.GetSuggestions(connectorsList, target);

            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            Console.WriteLine("My Suggestions count : " + suggestions.Count);
            Console.WriteLine("My Time : " + elapsedMs);

            foreach (var item in suggestions)
            {
                Console.WriteLine("Suggestion Start : ***********");
                if (item is SingleElementSuggestion)
                {
                    var sinSuggestion = (SingleElementSuggestion)item;
                    Console.WriteLine($"ID : {sinSuggestion.Element.CK_Id} chargeStationID : {sinSuggestion.Element.ChargeStationId} MaxCurrent : {sinSuggestion.Element.MaxCurrent}");
                }
                else
                {
                    var muSuggestion = (MultipleElementSuggestion)item;
                    foreach (var element in muSuggestion.Elements)
                    {
                        Console.WriteLine($"ID : {element.CK_Id} chargeStationID : {element.ChargeStationId} MaxCurrent : {element.MaxCurrent}");
                    }
                }
                Console.WriteLine("Suggestion End  **************");
            }



            Console.ReadKey();
        }
Example #23
0
        public async Task <bool> CreateIndex <T>() where T : class
        {
            try
            {
                var indexName = SearchableModelAttribute.GetIndexName(typeof(T));

                if (string.IsNullOrEmpty(indexName))
                {
                    throw new Exception("Model class should have SearchableModelAttribute with indexName specified.");
                }

                List <ScoringProfile> scoringProfiles = null;
                string defaultScoringProfile          = null;

                string newIndexVersionSuffix = DateTime.Now.ToString("yyyyMMddHHmmss");

                try
                {
                    var existingIndexNames = await _serviceClient.Indexes.ListNamesAsync();

                    var  foundIndexName    = "";
                    long foundIndexVersion = 0;
                    var  indexMatcher      = new Regex(indexName + "-(?<timestamp>\\d{12})+");
                    // find last index
                    foreach (var existingIndexName in existingIndexNames)
                    {
                        var match = indexMatcher.Match(existingIndexName);

                        if (match.Success)
                        {
                            var timestampGroup = new List <Group>(match.Groups).FirstOrDefault(g => g.Name == "timestamp");

                            if (timestampGroup != null && timestampGroup.Success && timestampGroup.Value != null && timestampGroup.Value.Length > 0)
                            {
                                var version = long.Parse(timestampGroup.Value);

                                if (version > foundIndexVersion)
                                {
                                    foundIndexName    = existingIndexName;
                                    foundIndexVersion = version;
                                }
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(foundIndexName))
                    {
                        Console.WriteLine("Unable to find last index version for index: " + indexName + ". New index will be created.");
                        foundIndexName = indexName;
                    }
                    else
                    {
                        Console.WriteLine("Found last index version: " + foundIndexName);
                    }

                    var existingIndex = await _serviceClient.Indexes.GetAsync(foundIndexName);

                    scoringProfiles = (List <ScoringProfile>)existingIndex.ScoringProfiles;

                    Console.WriteLine("ScoringProfiles:");
                    Console.Write(JsonConvert.SerializeObject(scoringProfiles, Formatting.Indented));
                    string mydocpath =
                        Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                    var path = mydocpath + @"\AzureSearch_" + DateTime.Now.ToString("yyyyMMdd_HH_mm_ss") + "_scoringProfilesBackup.json";
                    using (StreamWriter outputFile = new StreamWriter(path))
                    {
                        outputFile.Write(JsonConvert.SerializeObject(scoringProfiles, Formatting.Indented));
                    }

                    defaultScoringProfile = existingIndex.DefaultScoringProfile;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                List <Field>     fields     = new List <Field>();
                List <Suggester> suggesters = new List <Suggester>();

                PropertyInfo[] props = typeof(T).GetProperties();
                foreach (PropertyInfo prop in props)
                {
                    object[] attrs = prop.GetCustomAttributes(true);
                    foreach (object attr in attrs)
                    {
                        SearchablePropertyAttribute propertyAttribute = attr as SearchablePropertyAttribute;

                        if (propertyAttribute != null)
                        {
                            Type propertyType = prop.PropertyType;

                            if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable <>))
                            {
                                propertyType = Nullable.GetUnderlyingType(propertyType);
                            }

                            var field = new Field();

                            field.Name = prop.Name;

                            switch (Type.GetTypeCode(propertyType))
                            {
                            case TypeCode.Int32:
                                field.Type = DataType.Int32;
                                break;

                            case TypeCode.Int64:
                                field.Type = DataType.Int64;
                                break;

                            case TypeCode.Double:
                                field.Type = DataType.Double;
                                break;

                            case TypeCode.Boolean:
                                field.Type = DataType.Boolean;
                                break;

                            case TypeCode.String:
                                field.Type = DataType.String;
                                if (propertyAttribute.IsSearchable && !propertyAttribute.UseForSuggestions &&
                                    string.IsNullOrWhiteSpace(propertyAttribute.SearchAnalyzer) && string.IsNullOrWhiteSpace(propertyAttribute.IndexAnalyzer))
                                // Azure search doesn't support custom analyzer on fields enabled for suggestions
                                // If Search & IndexAnalyzers are specified, we cannot set Analyzer
                                {
                                    field.Analyzer = "standardasciifolding.lucene";
                                }
                                break;

                            case TypeCode.Object:
                                var elementType = propertyType.GetElementType();
                                if (Type.GetTypeCode(elementType) != TypeCode.String)
                                {
                                    throw new Exception("Unsupported array element type!");
                                }
                                field.Type = DataType.Collection(DataType.String);
                                if (propertyAttribute.IsSearchable && !propertyAttribute.UseForSuggestions)     // Azure search doesn't support custom analyzer on fields enabled for suggestions
                                {
                                    field.Analyzer = "standardasciifolding.lucene";
                                }
                                break;

                            case TypeCode.DateTime:
                                field.Type = DataType.DateTimeOffset;
                                break;

                            default:
                                throw new Exception($"Azure Search doesn't support {propertyType.Name} type.");
                            }

                            if (propertyAttribute.Analyzer != null && propertyAttribute.Analyzer != "")
                            {
                                field.Analyzer = propertyAttribute.Analyzer;
                            }
                            //SearchAnalyzer & IndexAnalyzer should be specified together
                            if (!string.IsNullOrWhiteSpace(propertyAttribute.SearchAnalyzer) && !string.IsNullOrWhiteSpace(propertyAttribute.IndexAnalyzer))
                            {
                                field.SearchAnalyzer = propertyAttribute.SearchAnalyzer;
                                field.IndexAnalyzer  = propertyAttribute.IndexAnalyzer;
                            }
                            else if ((string.IsNullOrWhiteSpace(propertyAttribute.SearchAnalyzer) && !string.IsNullOrWhiteSpace(propertyAttribute.IndexAnalyzer)) ||
                                     (!string.IsNullOrWhiteSpace(propertyAttribute.SearchAnalyzer) && string.IsNullOrWhiteSpace(propertyAttribute.IndexAnalyzer))
                                     )
                            {
                                throw new Exception($"Both SearchAnalyzer & IndexAnalyzer are should be specified together.");
                            }

                            field.IsKey        = propertyAttribute.IsKey;
                            field.IsFilterable = propertyAttribute.IsFilterable;
                            field.IsSortable   = propertyAttribute.IsSortable;
                            field.IsSearchable = propertyAttribute.IsSearchable;
                            field.IsFacetable  = propertyAttribute.IsFacetable;

                            if (propertyAttribute.SynonymMaps.Length > 0)
                            {
                                field.SynonymMaps = propertyAttribute.SynonymMaps;
                            }

                            fields.Add(field);

                            if (propertyAttribute.UseForSuggestions)
                            {
                                var suggester = new Suggester {
                                    Name = field.Name, SourceFields = new[] { field.Name }
                                };

                                suggesters.Add(suggester);
                            }
                        }
                    }
                }

                string newIndexName = indexName + "-" + newIndexVersionSuffix;

                var definition = new Index()
                {
                    Name                  = newIndexName,
                    Fields                = fields,
                    Suggesters            = suggesters,
                    ScoringProfiles       = scoringProfiles,
                    DefaultScoringProfile = defaultScoringProfile
                };

                await _serviceClient.Indexes.CreateOrUpdateAsync(definition);

                Console.WriteLine($"Created index " + definition.Name);

                //await _serviceClient.Indexes.DeleteAsync(indexName);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error creating index: {0}\r\n", ex.Message);
            }

            return(true);
        }
Example #24
0
        /// <summary>
        /// Processes the sequence of movements the user performed since the last centre focus
        /// </summary>
        private void centreProcessing()
        {
            keyboardTimer.Stop();

            if (isBetsy) //changing back to the original font
            {
                for (int i = 0; i <= 7; i++)
                {
                    var obj = (Label)FindName("min" + i.ToString());
                    obj.FontFamily = new FontFamily("Segoe UI");
                }
                isBetsy = false;
            }
            string finalChar;

            lastPanel = "";
            if (centreProcessed) //if the centre was already processed (no movement to the borders so far), no operation needed
            {
                return;
            }

            switch (blockType)
            {
            case 1:     //Blocked to rest
                if (composition == "-12345" || composition == "-10765")
                {
                    stateTransition.Play();
                    isBlocked = false;
                    blockType = 0;
                    //Restoring default UI
                    locklogo.Visibility = System.Windows.Visibility.Hidden;
                    txtInput.Visibility = System.Windows.Visibility.Visible;
                    for (int i = 8; i < 35; i++)
                    {
                        var obj = (Label)FindName(labelNames[i]);
                        obj.Visibility = System.Windows.Visibility.Visible;
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        suggestionStackPanel[i].Visibility = Visibility.Visible;
                    }
                }
                break;

            case 2:     //Blocked to read full text
                if (composition == "-12345" || composition == "-10765")
                {
                    stateTransition.Play();
                    isBlocked = false;
                    blockType = 0;
                    // Restoring default UI
                    txtInput.Margin = new Thickness(txtInput.Margin.Left / textBoxMarginCoefW,
                                                    txtInput.Margin.Top / textBoxMarginCoefH, txtInput.Margin.Right / textBoxMarginCoefW,
                                                    txtInput.Margin.Bottom / textBoxMarginCoefH);
                    for (int i = 8; i < 35; i++)
                    {
                        var obj = (Label)FindName(labelNames[i]);
                        obj.Visibility = System.Windows.Visibility.Visible;
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        suggestionStackPanel[i].Visibility = Visibility.Visible;
                    }
                }
                break;

            case 3:
                if (composition == "-3")
                {
                    stateTransition.Play();
                    isBlocked = false;
                    blockType = 0;
                    unblockingEvent();
                }
                break;

            default:     //No Block
                if (!isCancelled)
                {
                    if (composition == "-")     //if there was no movement to the extremities
                    {
                        goto didntLeaveCentre;  //jumps all the character processing
                    }
                    if (composition == "-12345")
                    {
                        stateTransition.Play();
                        isBlocked = true;
                        blockType = 1;
                        // Blocking Screen to rest mode
                        locklogo.Visibility = System.Windows.Visibility.Visible;
                        txtInput.Visibility = System.Windows.Visibility.Hidden;
                        for (int i = 8; i < 35; i++)
                        {
                            var obj = (Label)FindName(labelNames[i]);
                            obj.Visibility = System.Windows.Visibility.Hidden;
                        }

                        for (int i = 0; i < 4; i++)
                        {
                            suggestionStackPanel[i].Visibility = Visibility.Hidden;
                        }
                        goto hasJustBeenBlocked;     //jumps all the character processing
                    }
                    if (composition == "-10765")
                    {
                        stateTransition.Play();
                        isBlocked = true;
                        blockType = 2;
                        // Block Screen to read mode
                        txtInput.Margin = new Thickness(txtInput.Margin.Left * textBoxMarginCoefW,
                                                        txtInput.Margin.Top * textBoxMarginCoefH, txtInput.Margin.Right * textBoxMarginCoefW,
                                                        txtInput.Margin.Bottom * textBoxMarginCoefH);

                        for (int i = 8; i < 35; i++)
                        {
                            var obj = (Label)FindName(labelNames[i]);
                            obj.Visibility = Visibility.Hidden;
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            suggestionStackPanel[i].Visibility = Visibility.Hidden;
                        }
                        goto hasJustBeenBlocked;     //jumps all the character processing
                    }

                    //suggestions' acceptance
                    if (composition == "-701" || composition == "-107")
                    {
                        acceptSuggestion(0);
                        goto acceptedSuggestion;
                    }
                    if (composition == "-123" || composition == "-321")
                    {
                        acceptSuggestion(1);
                        goto acceptedSuggestion;
                    }
                    if (composition == "-567" || composition == "-765")
                    {
                        acceptSuggestion(2);
                        goto acceptedSuggestion;
                    }
                    if (composition == "-345" || composition == "-543")
                    {
                        acceptSuggestion(3);
                        goto acceptedSuggestion;
                    }


                    //No suggestion accepted, so go on...
                    for (int i = 0; i < 4; i++)     //Clear all the suggestion labels
                    {
                        //suggestionLabel[i].Content = "";
                        suggestionLabel[i].Text = "";
                    }
                    try
                    {       //Prepare to print a character composed of 2 movements
                        charToPrint = composition.Substring(1, 2);
                    }
                    catch
                    {       //Prepare to print a character composed of a single movement
                        charToPrint = composition.Substring(1, 1);
                    }

                    //Process the "character to be concatenated" / "operation to be done" in the TextBox
                    finalChar = CharacterDecoder.generateCharacter(charToPrint, blockType, primaryKeyboard);


                    // enteredCharacter1|number1(milliseconds)-enteredCharacter2|number2(milliseconds)
                    characterTimestampRecord += "char|" + finalChar + "|" + dataTimer.ElapsedMilliseconds.ToString() + "\n";


                    switch (finalChar)
                    {
                    case "&":
                        goto cancelledCharacter;

                    case "ESPAÇO":
                        finalChar = " ";
                        //if (justAcceptedSuggestion) //if the last word was an accepted suggestion
                        //{
                        //    justAcceptedSuggestion = false;
                        //    nextWordInSentence(); //calls next word or sentence
                        //}
                        //else
                        //{
                        justAddedSpace = true;
                        if (txtInput.Text[txtInput.Text.Length - 1] != ' ')
                        {
                            //if there is no repeated space, calls next word or sentence
                            nextWordInSentence();
                        }
                        //}

                        txtInput.AppendText(finalChar);         //append a space
                        Suggester.indexWord(currentWord);
                        currentWord = "";
                        break;

                    case ".":
                        if (txtInput.Text.Length == 0)
                        {
                            goto didntLeaveCentre;
                        }
                        nextIsUpper = false;
                        if (txtInput.Text.Substring(txtInput.Text.Length - 1) == " ")
                        {
                            txtInput.Text = txtInput.Text.Substring(0, txtInput.Text.Length - 1);
                        }
                        txtInput.AppendText(finalChar + " ");
                        Suggester.indexWord(currentWord);
                        justAcceptedSuggestion = false;
                        justAddedSpace         = false;
                        nextWordInSentence();
                        currentWord = "";
                        break;         //append a point and a space

                    case "DEL":
                        nDeletions++;
                        string inputContent = txtInput.Text;
                        string aux;
                        try
                        {
                            if (justAcceptedSuggestion)
                            {
                                justAcceptedSuggestion = false;
                                justAddedSpace         = false;
                                inputContent           = textBeforeAcceptance + " ";
                                //DIMINUIR O PESO DA CHOSENWORD
                            }
                            aux = inputContent.Substring(0, inputContent.Length - 1);
                            //delete a character. If it was in upper case, the next character to be written must be written in upper case too
                            if (inputContent.Substring(inputContent.Length - 1) == ".")
                            {
                                nextIsUpper = false;
                            }
                            else
                            {           //if the last erased character was a space, do not uppercase the next letter to be inserted
                                if (inputContent.LastIndexOf(" ") != inputContent.Length - 1)
                                {
                                    if (inputContent.Substring(inputContent.Length - 1) == inputContent.Substring(inputContent.Length - 1).ToUpper())
                                    {
                                        nextIsUpper = false;
                                    }

                                    if (currentWord.Length > 0)
                                    {
                                        currentWord = currentWord.Substring(0, currentWord.Length - 1);
                                    }
                                }
                                else         //if it was a space, so the current word is the whole last word
                                {
                                    //aux is the current text written without the last character (space in this case)
                                    if (inputContent[inputContent.Length - 2] != ' ')
                                    {
                                        previousWordInSentence();
                                    }
                                    try
                                    {
                                        //takes the last written word as current word
                                        currentWord = aux.Substring(aux.LastIndexOf(" ") + 1, aux.Length - aux.LastIndexOf(" ") - 1);
                                    }
                                    catch
                                    {
                                        currentWord = aux.Substring(0, aux.Length);
                                    }

                                    //if '.' is the last character, it must be removed too.
                                    if (aux[aux.Length - 1] == '.')
                                    {
                                        currentWord = currentWord.Substring(0, currentWord.Length - 1);
                                        aux         = aux.Substring(0, aux.Length - 1);
                                        nextIsUpper = false;
                                    }
                                }
                            }
                            addSuggestionsToLabels();

                            txtInput.Text = "";
                            txtInput.AppendText(aux);
                        }
                        catch
                        {
                            Console.WriteLine("txtInput is empty!");
                        }
                        break;

                    default:         //if it's not space, '.' or delete operations, so the character must be simply added to the TextBox
                        justAcceptedSuggestion = false;
                        justAddedSpace         = false;
                        if (!nextIsUpper)
                        {
                            finalChar = finalChar.ToLower();
                        }

                        txtInput.AppendText(finalChar);
                        currentWord += finalChar;         //currentWord receives the last char

                        //TODO: fazer sons tocarem quando digitar jj e jjj em loop e parar quando digitar outro simbolo que não j.

                        addSuggestionsToLabels();

                        nextIsUpper = false;         //after the upper case letter has been already entered, the next one will be lower for sure
                        break;
                    }
                }
                else
                {
                    isCancelled = !isCancelled; //the letter that was cancelled wasn't processed and the next may not be cancelled
                }
                break;                          //breaking the default case
            }
acceptedSuggestion:
didntLeaveCentre:
hasJustBeenBlocked:
cancelledCharacter:
            txtInput.ScrollToEnd(); //always focus the end of the txtBox
            primaryKeyboard = true;
            composition     = "-";
            centreProcessed = true;
        }
Example #25
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            alarm = new SoundPlayer(Properties.Resources.beep01);
            //alarm.Play();
            loudAlarm = new SoundPlayer(Properties.Resources.loudAlarm);
            //loudAlarm.Play();
            stateTransition = new SoundPlayer(Properties.Resources.flip);
            //stateTransition.Play();
            //stateTransition.PlayLooping();

            sentencesList = new List <string>(); //list of sentences to be written during the test
            try
            {                                    // Open the text file using a stream reader.
                using (StreamReader sr = new StreamReader("sentencas_de_teste.txt"))
                {
                    string line;
                    do
                    {
                        line = sr.ReadLine();
                        sentencesList.Add(line);
                    } while (line != null);

                    //sentencesList has all the test sentences inside of it
                    sentencesList.RemoveAt(sentencesList.Count - 1);

                    sentencesList.Shuffle();
                    //foreach(string x in sentencesList)
                    //{
                    //    Console.WriteLine(x);
                    //}
                }
            }
            catch
            {
                Console.WriteLine("The file could not be read:");
            }

            //initial system values
            composition     = "-";
            isCancelled     = false;
            charToPrint     = "";
            primaryKeyboard = true;
            blockType       = 0;
            isBlocked       = false;
            //suggestionLabel = new Label[4];

            changeObjectsSize();
            //initialize the Suggester
            Suggester.initializeSuggester();
            suggestionsList = new List <string>();
            currentWord     = "";
            //every 2 seconds after the keyboardTimer has started, the changeKeyboard function will be called
            keyboardTimer.Interval = 2000;
            keyboardTimer.Elapsed += new ElapsedEventHandler(changeKeyboard);

            dataTimer.Start();
            dataTimer2.Start();

            startNewSentence(); //first sentence to be written during tests is shown to the user


            if (IS_USING_CAMERA)
            {
                Mouse.OverrideCursor = Cursors.None; //remove mouse
                                                     //EyeTracker data retrieval
                try
                {
                    gp = new GazePoint();
                }
                catch
                {
                    Console.WriteLine("No camera found! Mouse mode! :)");
                }
            }
        }
 public void Suggeste_LoadSevealSources_checkSourcesPropertyThatTheyAreTheer()
 {
     var name1 = "name1";
     var name2 = "name2";
     var MockSource1 = new Moq.Mock<ISuggestionSource>();
     MockSource1.Setup(m => m.Name).Returns(name1);
     var MockSource2 = new Moq.Mock<ISuggestionSource>();
     MockSource2.Setup(m => m.Name).Returns(name2);
     var sut = new Suggester(new ISuggestionSource[] { MockSource1.Object, MockSource2.Object });
     var returnedsources = sut.Sources;
     CollectionAssert.AreEquivalent(new string[] { name1, name2 }, returnedsources.Select(s => s.Name).ToArray());
 }
 public void InSuggester_PassNullDependency_CheckExeption()
 {
     var sut = new Suggester(null);
 }
Example #28
0
        private void VisElementCanvas_Drop(object sender, System.Windows.DragEventArgs e)
        {
            if (!string.IsNullOrEmpty(modelFile) && sourceASTL != null) //sourceASTL was tvvm (before 15/08/2012)
            {
                System.Windows.Point pos = e.GetPosition(VisElementCanvas);

                /*if (e.Data.GetDataPresent("ToolboxItem"))
                {
                    //clear canvas children
                    VisElementCanvas.Children.Clear();

                    //get toolbox item
                    ToolboxItem t = e.Data.GetData("ToolboxItem") as ToolboxItem;

                    visEl = new VisualElement();
                    visEl = (t.visualElement.Clone()) as VisualElement;//must be call by value

                    visEl.Position = pos;

                    Canvas.SetLeft(visEl, Math.Max(0, pos.X - 100 / 2));
                    Canvas.SetTop(visEl, Math.Max(0, pos.Y - 100 / 2));
                    visEl.Content = t.visualElement.Content;

                    VisElementCanvas.Children.Add(visEl);

                    //suggestions
                    visEl.abstractTree.prepare();
                    this.sourceASTL.prepare();

                    SuggesterConfig config = new SuggesterConfig();
                    config.UseNameSimSuggester = true;
                    config.UseTypeSimSuggester = true;
                    config.UseIsoRankSimSuggester = false;
                    config.UseValueSimSuggester = true;
                    config.UseStructSimSuggester = false;
                    this.visualiserSuggester = new Suggester(sourceASTL, visEl.abstractTree, config);
                    this.updateSuggestions(this.visualiserSuggester.getSuggestionsAsStrings(this.visualiserSuggester.imFeelingLucky()));

                }
                else*/
                if (e.Data.GetDataPresent("VisualElement"))
                {
                    //clear canvas children
                    VisElementCanvas.Children.Clear();

                    VisualElement temp = new VisualElement();
                    temp = (e.Data.GetData("VisualElement") as VisualElement).Clone() as VisualElement;

                    visEl = xrenderer.render(temp.ItemXML) as VisualElement; //render visual elements, no need for return valu, the notation contents will be added to same visual element 6/11/2012
                    visEl.templateVM.TemplateXmlNode = temp.templateVM.TemplateXmlNode.Clone() as XmlNode;
                    // visEl.templateVMR.TemplateXmlNode = temp.templateVMR.TemplateXmlNode.Clone() as XmlNode;
                    visEl.templateVM.TemplateName = temp.templateVM.TemplateName;
                    visEl.templateVMR.TemplateName = temp.templateVMR.TemplateName;
                    visEl.Data = temp.Data.Clone() as XmlNode;
                    //visEl.ReverseData = temp.ReverseData.Clone() as XmlNode;

                    visEl.Position = pos;

                    //prepare view box for large items
                    Viewbox vb = new Viewbox();
                    vb.MaxHeight = 180;
                    vb.MaxWidth = 180;
                    vb.StretchDirection = StretchDirection.DownOnly;
                    vb.Stretch = System.Windows.Media.Stretch.Fill;
                    vb.Child = visEl;

                    Canvas.SetLeft(vb, Math.Max(0, pos.X - 100 / 2));
                    Canvas.SetTop(vb, Math.Max(0, pos.Y - 100 / 2));

                    if (visEl != null)
                    {
                        VisElementCanvas.Children.Add(vb);

                        //suggestions
                        visEl.abstractTree.prepare();
                        this.sourceASTL.prepare();

                        SuggesterConfig config = new SuggesterConfig();
                        config.UseNameSimSuggester = true;
                        config.UseTypeSimSuggester = true;
                        config.UseIsoRankSimSuggester = false;
                        config.UseValueSimSuggester = true;
                        config.UseStructSimSuggester = false;

                        this.visualiserSuggester = new Suggester(sourceASTL, visEl.abstractTree, config);
                        this.updateSuggestions(this.visualiserSuggester.getSuggestionsAsStrings(this.visualiserSuggester.imFeelingLucky()));

                        //log event
                        logger.log("Visual Element \"" + visEl.VEName + "\" droppped on Visualisation canvas.");

                    }
                    else
                    {
                        reportMessage("Unable to render visual", ReportIcon.Error);
                    }

                }
                else if (e.Data.GetDataPresent("VisualFunction"))
                {
                    VisualFunction vf = e.Data.GetData("VisualFunction") as VisualFunction;

                    if (VisElementCanvas.Children.Count > 0)//if there exists visual element, match functions header node with the element header node
                    {
                        foreach (UIElement u in VisElementCanvas.Children)//assign same header node to the function as well
                            if (u is Viewbox)
                            {
                                if (((u as Viewbox).Child as VisualElement).templateVM.HeaderNode != null)//header node has been set
                                {
                                    //set visualfunction's target metamodel as this visual element
                                    vf.targetASTL = new AbstractLattice(((u as Viewbox).Child as VisualElement).abstractTree.Root.duplicate());
                                    //set visualfunction's source abstraction from source model
                                    vf.sourceASTL = new AbstractLattice(this.sourceASTL.getAbstractNodeAtAddress(((u as Viewbox).Child as VisualElement).templateVM.TemplateAddress).duplicate());

                                    vf.sourceRootNode = ((u as Viewbox).Child as VisualElement).templateVM.HeaderNode;

                                    Canvas.SetLeft(vf, Math.Max(0, pos.X - 100 / 2));
                                    Canvas.SetTop(vf, Math.Max(0, pos.Y - 100 / 2));

                                    VisElementCanvas.Children.Add(vf);

                                    //log event
                                    logger.log("Visual Finction droppped on Visualisation canvas.", ReportIcon.Info);

                                    break;
                                }
                                else
                                {
                                    reportMessage("Set header node for visual Element first", ReportIcon.Error);
                                }
                            }
                    }
                    else

                        reportMessage("No visual element has been set yet", ReportIcon.Error);
                }
                else if (e.Data.GetDataPresent("VisualCondition"))
                {
                    VisualCondition vc = e.Data.GetData("VisualCondition") as VisualCondition;

                    if (VisElementCanvas.Children.Count > 0)//if there exists visual element, match functions header node with the element header node
                    {
                        foreach (UIElement u in VisElementCanvas.Children)//assign same header node to the condition as well
                            if (u is Viewbox)
                            {
                                if (((u as Viewbox).Child as VisualElement).templateVM.HeaderNode != null)//header node has been set
                                {
                                    //set visualfunction's target metamodel as this visual element
                                    vc.targetASTL = new AbstractLattice(((u as Viewbox).Child as VisualElement).abstractTree.Root.duplicate());
                                    //set visualfunction's source abstraction from source model
                                    vc.sourceASTL = new AbstractLattice(this.sourceASTL.getAbstractNodeAtAddress(((u as Viewbox).Child as VisualElement).templateVM.TemplateAddress).duplicate());

                                    vc.sourceRootNode = ((u as Viewbox).Child as VisualElement).templateVM.HeaderNode;

                                    Canvas.SetLeft(vc, Math.Max(0, pos.X - 100 / 2));
                                    Canvas.SetTop(vc, Math.Max(0, pos.Y - 100 / 2));

                                    VisElementCanvas.Children.Add(vc);

                                    //log event
                                    logger.log("Visual Condition droppped on Visualisation canvas.", ReportIcon.Info);

                                    break;
                                }
                                else
                                {
                                    reportMessage("Set header node for visual Element first", ReportIcon.Error);
                                }
                            }
                    }
                    else
                        reportMessage("No visual element has been set yet", ReportIcon.Error);
                }

            }
            else
                reportMessage("Please open input model first!", ReportIcon.Error);
        }
Example #29
0
        private void Test_Click(object sender, RoutedEventArgs e)
        {
            //AbstractLattice sabs = new AbstractLattice(@"C:\Users\iavazpour\Desktop\CitationsEndNote.xml");
            //AbstractLattice tabs = new AbstractLattice(@"C:\Users\iavazpour\Desktop\FromJobRefDocBook.xml");

            AbstractLattice tabs = new AbstractLattice("real_estate_nky.xml");
            //AbstractLattice sabs = new AbstractLattice("real_estate_texas.xml");
            //AbstractLattice tabs = new AbstractLattice("real_estate_yahoo.xml");
            //AbstractLattice tabs = new AbstractLattice("real_estate_homeseeker.xml");
            AbstractLattice sabs = new AbstractLattice("real_estate_windermere.xml");

            Suggester testSugg;

            SuggesterConfig scP = new SuggesterConfig();
            SuggesterConfig scR = new SuggesterConfig();

            double prec = 0;
            double reca = 1;

            SuggesterConfig sct = new SuggesterConfig();
            sct.UseIsoRankSimSuggester = true;
            sct.UseNameSimSuggester = true;
            sct.UseNeighborSimSuggester = true;
            sct.UseStructSimSuggester = true;
            sct.UseTypeSimSuggester = true;
            sct.UseValueSimSuggester = true;

            testSugg = new Suggester(sabs, tabs, sct);
            testSugg.imFeelingLucky();

            String test1 =  "Evaluation Results for test1 " + testSugg.evaluator.printAnalysisResults();
            //MessageBox.Show(test1);

            SuggesterConfig sc = new SuggesterConfig();
            sc.UseIsoRankSimSuggester = false;
            sc.UseNameSimSuggester = false;
            sc.UseNeighborSimSuggester = false;
            sc.UseStructSimSuggester = false;
            sc.UseTypeSimSuggester = false;
            sc.UseValueSimSuggester = false;

            for (int i = 1; i < 2; i++)
            {
                sc.UseIsoRankSimSuggester = !sc.UseIsoRankSimSuggester;
                for (int j = 1; j < 2; j++)
                {
                    sc.UseNameSimSuggester = !sc.UseNameSimSuggester;
                    for (int t = 0; t < 2; t++)
                    {
                        sc.UseNeighborSimSuggester = !sc.UseNeighborSimSuggester;
                        for (int a = 0; a < 2; a++)
                        {
                            sc.UseStructSimSuggester = !sc.UseStructSimSuggester;
                            for (int b = 0; b < 2; b++)
                            {
                                sc.UseTypeSimSuggester = !sc.UseTypeSimSuggester;
                                for (int d = 0; d < 2; d++)
                                {
                                    sc.UseValueSimSuggester = !sc.UseValueSimSuggester;

                                    testSugg = new Suggester(sabs, tabs, sc);
                                    testSugg.imFeelingLucky();

                                    if (testSugg.evaluator.Precision > prec)
                                    {
                                        scP = sc;
                                        prec = testSugg.evaluator.Precision;
                                    }

                                    if (testSugg.evaluator.Recall < reca)
                                    {
                                        scR = sc;
                                        reca = testSugg.evaluator.Recall;
                                    }
                                }
                            }
                        }
                    }
                }
            }

            testSugg = new Suggester(sabs, tabs, scP);
            testSugg.imFeelingLucky();
            //MessageBox.Show(scP.ToString() + testSugg.evaluator.printAnalysisResults(), "Evaluation Results for precision");
            string test2 = "Evaluation Results for precision" + testSugg.evaluator.printAnalysisResults();

            testSugg = new Suggester(sabs, tabs, scR);
            testSugg.imFeelingLucky();
            //MessageBox.Show(scR.ToString() + testSugg.evaluator.printAnalysisResults(), "Evaluation Results for recall");
            string test3 = "Evaluation Results for recall" + testSugg.evaluator.printAnalysisResults();

            MessageBox.Show(test1 + test2 + test3);

            //AbstractLattice sabsR = new AbstractLattice(@"C:\Users\iavazpour\Desktop\CitationsEndNote.xml");
            //AbstractLattice tabsR = new AbstractLattice(@"C:\Users\iavazpour\Desktop\FromJobRefDocBook.xml");

            //First Create the instance of Stopwatch Class
            //Stopwatch sw = new Stopwatch();

            // Start The StopWatch ...From 000
            //sw.Start();

            //testSugg.imFeelingLucky();

            //sw.Stop();

            //this.updateSuggestions(testSugg.getSuggestionsAsStrings(testSugg.LastResults));

            //MessageBox.Show(string.Format("Minutes :{0}\nSeconds :{1}\n Mili seconds :{2}", sw.Elapsed.Minutes,
             //   sw.Elapsed.Seconds, sw.Elapsed.TotalMilliseconds));

            //testSugg = new Suggester(sabs, tabs, sc);

            //sw = new Stopwatch();

            // Start The StopWatch ...From 000
            //sw.Start();

            //testSugg.imFeelingLucky();

            //sw.Stop();

            //this.updateSuggestions(testSugg.getSuggestionsAsStrings(testSugg.LastResults));

            //MessageBox.Show(string.Format("Minutes :{0}\nSeconds :{1}\n Mili seconds :{2}", sw.Elapsed.Minutes,
               // sw.Elapsed.Seconds, sw.Elapsed.TotalMilliseconds));

            /*Object obj = TestVisual.Resources["sourceData"];
            MessageBox.Show(obj.GetType().ToString());
            if ((obj as XmlDataProvider) != null)
            {
                XmlNode xnode = (obj as XmlDataProvider).Document.DocumentElement.Clone();
                if (xnode != null)
                {
                    XElement xmlDocumentWithoutNs = RemoveAllNamespaces(XElement.Parse(xnode.OuterXml));
                    MessageBox.Show(xmlDocumentWithoutNs.ToString());
                    XmlDocument xdoc = new XmlDocument();
                    xdoc.LoadXml(xmlDocumentWithoutNs.ToString());
                    TestVisual.Data =  xdoc.DocumentElement;
                }

            }*/

            //string test = @"javasource/class_declarations/class_declaration/properties/java_property/identifier";

            //MyLogicalTreeHelper helper = new MyLogicalTreeHelper();
            //Collection<object> results = helper.getVisualElementsByName(SourceCanvas, QualifiedNameString.Convert("javasource"));

            //foreach (var obj in results)
            //{
            //    AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
            //    FrameworkElement found = (obj) as FrameworkElement;
            //    FrameworkElementAdorner fea = new FrameworkElementAdorner(found);
            //    if (myAdornerLayer != null)
            //    {
            //        myAdornerLayer.Add(fea);

            //    }
            //}

            //var foundTextBox = LogicalTreeHelper.FindLogicalNode(SourceCanvas, "type");
            //if (foundTextBox != null)
            //{
            //    AdornerLayer myAdornerLayer = AdornerLayer.GetAdornerLayer(this);
            //    FrameworkElementAdorner fea = new FrameworkElementAdorner(foundTextBox as FrameworkElement);
            //    if (myAdornerLayer != null)
            //    {
            //        myAdornerLayer.Add(fea);
            //        //(foundTextBox as Label).Background = Brushes.Red;
            //    }
            //}
            //else
            //    ReportStatusBar.ShowMessage("not found", ReportIcon.Error);
            //evaluateCombination();
        }
Example #30
0
        public void evaluateCombination()
        {
            List<SuggesterConfig> MaxPrecisionConfigurations = new List<SuggesterConfig>();
            List<SuggesterConfig> MaxRecallConfigurations = new List<SuggesterConfig>();
            List<SuggesterConfig> MaxFMeasureConfigurations = new List<SuggesterConfig>();
            double maxPrecision = 0;
            double maxRecall = 0;
            double maxFMeasure = 0;

            if (sourceASTL != null && targetASTL != null)
            {
                this.sourceASTL.prepare();
                this.targetASTL.prepare();

                SuggesterConfig config = new SuggesterConfig();

                //use different combintions
                for (int i = 0; i < 2; i++)
                {
                    config.UseIsoRankSimSuggester = !config.UseIsoRankSimSuggester;
                    for (int j = 0; j < 2; j++)
                    {
                        config.UseNameSimSuggester = !config.UseNameSimSuggester;
                        for (int k = 0; k < 2; k++)
                        {
                            config.UseStructSimSuggester = !config.UseStructSimSuggester;
                            for (int l = 0; l < 2; l++)
                            {
                                config.UseTypeSimSuggester = !config.UseTypeSimSuggester;
                                for (int m = 0; m < 2; m++)
                                {
                                    config.UseValueSimSuggester = !config.UseValueSimSuggester;
                                    for (int p = 0; p < 2; p++)
                                    {
                                        config.UseNeighborSimSuggester = !config.UseNeighborSimSuggester;

                                        //create suggester and test it
                                        mapperSuggester = new Suggester(sourceASTL, targetASTL, config);
                                        mapperSuggester.imFeelingLucky();
                                        //apperSuggester.getRankedSuggestions(2);

                                        SuggesterEvaluator eval = new SuggesterEvaluator(mapperSuggester);

                                        //get max precision
                                        if (eval.Precision > maxPrecision)
                                        {
                                            MaxPrecisionConfigurations.Clear();
                                            MaxPrecisionConfigurations.Add(config.Clone());
                                            maxPrecision = eval.Precision;
                                        }
                                        else if (eval.Precision == maxPrecision)
                                            MaxPrecisionConfigurations.Add(config.Clone());

                                        //get best recalls
                                        if (eval.Recall > maxRecall)
                                        {
                                            MaxRecallConfigurations.Clear();
                                            MaxRecallConfigurations.Add(config.Clone());
                                            maxRecall = eval.Recall;
                                        }
                                        else if (eval.Recall == maxRecall)
                                            MaxRecallConfigurations.Add(config.Clone());

                                        //get best FMeasures
                                        if (eval.FMeasure > maxFMeasure)
                                        {
                                            MaxFMeasureConfigurations.Clear();
                                            MaxFMeasureConfigurations.Add(config.Clone());
                                            maxFMeasure = eval.FMeasure;
                                        }
                                        else if (eval.FMeasure == maxFMeasure)
                                            MaxFMeasureConfigurations.Add(config.Clone());

                                        //SuggesterEvaluator eval = new SuggesterEvaluator(mapperSuggester);//evaluation is included in imFeelingLucky
                                    }
                                }
                            }
                        }
                    }
                }

                StreamWriter writer = new StreamWriter("Eval.csv");

                //write best precisions
                writer.WriteLine("Max precision of: " + maxPrecision + " Achieved by:");
                writer.WriteLine("");
                string header = "ISO, Name, Struct, Type, Value, Neighbors, Precision, Recall, FMeasure";
                writer.WriteLine(header);
                writer.WriteLine("");

                foreach (SuggesterConfig sc in MaxPrecisionConfigurations)
                {
                    string rl = (sc.UseIsoRankSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseNameSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseStructSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseTypeSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseValueSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseNeighborSimSuggester ? "1" : "0");

                    writer.WriteLine(rl);
                }
                writer.WriteLine("");
                writer.WriteLine("");

                //write best recalls
                writer.WriteLine("Max Recall of: " + maxRecall + " Achieved by:");
                writer.WriteLine("");
                writer.WriteLine(header);
                writer.WriteLine("");

                foreach (SuggesterConfig sc in MaxRecallConfigurations)
                {
                    string rl = (sc.UseIsoRankSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseNameSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseStructSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseTypeSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseValueSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseNeighborSimSuggester ? "1" : "0");

                    writer.WriteLine(rl);
                }
                writer.WriteLine("");
                writer.WriteLine("");

                //write best FMeasures
                writer.WriteLine("Max FMeasure of: " + maxFMeasure + " Achieved by:");
                writer.WriteLine("");
                writer.WriteLine(header);
                writer.WriteLine("");

                foreach (SuggesterConfig sc in MaxFMeasureConfigurations)
                {
                    string rl = (sc.UseIsoRankSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseNameSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseStructSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseTypeSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseValueSimSuggester ? "1" : "0") + ", ";
                    rl += (sc.UseNeighborSimSuggester ? "1" : "0");

                    writer.WriteLine(rl);
                }

                writer.Flush();
                writer.Close();

                ReportStatusBar.ShowStatus("Suggestor valuation complete!", ReportIcon.Info);
            }
        }
Example #31
0
        private static void CreateIndex()
        {
            try
            {
                Suggester sg = new Suggester();
                sg.Name         = "sg";
                sg.SearchMode   = SuggesterSearchMode.AnalyzingInfixMatching;
                sg.SourceFields = new string[] { "brand_name", "product_name", "sku", "product_subcategory", "product_category", "product_department", "product_family" };

                var definition = new Index()
                {
                    Name   = IndexName,
                    Fields = new[]
                    {
                        new Field("product_id", DataType.String)
                        {
                            IsKey = true, IsSearchable = false, IsFilterable = true, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("product_class_id", DataType.Int32)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = false, IsSortable = true, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("brand_name", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("product_name", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("sku", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("srp", DataType.Int32)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("gross_weight", DataType.Double)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("net_weight", DataType.Double)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("recyclable_package", DataType.String)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = false, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("low_fat", DataType.String)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = false, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("units_per_case", DataType.Int32)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("cases_per_pallet", DataType.Int32)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("shelf_width", DataType.Double)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("shelf_height", DataType.Double)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("shelf_depth", DataType.Double)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = true, IsSortable = true, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("product_subcategory", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("product_category", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("product_department", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("product_family", DataType.String)
                        {
                            IsKey = false, IsSearchable = true, IsFilterable = false, IsSortable = false, IsFacetable = true, IsRetrievable = true
                        },
                        new Field("url", DataType.String)
                        {
                            IsKey = false, IsSearchable = false, IsFilterable = false, IsSortable = false, IsFacetable = false, IsRetrievable = true
                        },
                        new Field("recommendations", DataType.Collection(DataType.String))
                        {
                            IsSearchable = true, IsFilterable = true, IsFacetable = true
                        }
                    }
                };
                definition.Suggesters.Add(sg);
                _searchClient.Indexes.Create(definition);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error creating index: {0}:\r\n", ex.Message.ToString());
            }
        }
Example #32
0
        public IList <SuggestionEventForPersonDTO> GetSuggestionsRefactored(Person p, IList <int> enabledIds)
        {
            var profiler = MiniProfiler.Current;

            Suggester s = new Suggester();

            IDictionary <string, AdminSuggestionFeaturePersonResponsibility> features = this.GetAdminSuggestionFeaturePersonResponsibilities();

            using (profiler.Step("set counts of previous suggestions"))
                s.SetFeatureProbabilityCalcs(this.CountSuggestedFeatures());

            using (profiler.Step("get person relationship suggestions"))
                s.AddSuggestedFeatures(this.GetPersonRelationshipSuggestions(p));

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.RESPONSIBLE_FOR_RELATED_EVENT].Id))
            {
                using (profiler.Step("get event relationship suggestions"))
                    s.AddSuggestedFeatures(this.GetEventRelationshipSuggestions(p));
            }

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.LAST_NAME_APPEARS].Id))
            {
                using (profiler.Step("get last name suggestions"))
                    s.AddSuggestedFeatures(this.GetLastNameSuggestions(p));
            }

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.FIRST_NAME_APPEARS].Id))
            {
                using (profiler.Step("get first name suggestions"))
                    s.AddSuggestedFeatures(this.GetFirstNameSuggestions(p));
            }

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.ALIAS_APPEARS].Id))
            {
                using (profiler.Step("get alias suggestions"))
                    s.AddSuggestedFeatures(this.GetAliasSuggestions(p));
            }

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.COMMON_SOURCE].Id))
            {
                using (profiler.Step("get shared source suggestions"))
                    s.AddSuggestedFeatures(this.GetSourceSuggestions(p));
            }

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.CAREER_IN_LOCATION].Id))
            {
                using (profiler.Step("get career location suggestions"))
                    s.AddSuggestedFeatures(this.GetCareerLocationSuggestions(p));
            }

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.CAREER_IN_ORG_RESPONSIBLE].Id))
            {
                using (profiler.Step("get career in responsible org suggestions"))
                    s.AddSuggestedFeatures(this.GetCareerInResponsibleOrganizationSuggestions(p));
            }

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.CAREER_IN_UNIT_RESPONSIBLE].Id))
            {
                using (profiler.Step("get career in responsible unit suggestions"))
                    s.AddSuggestedFeatures(this.GetCareerInResponsibleUnitSuggestions(p));
            }

            if (enabledIds.Contains(features[AdminSuggestionFeaturePersonResponsibility.RESPONSIBILITY_IN_LOCATION].Id))
            {
                using (profiler.Step("get event in same location suggestions"))
                    s.AddSuggestedFeatures(this.GetEventInSameLocationSuggestions(p));
            }

            IList <SuggestionEventForPersonDTO> dtos;

            using (profiler.Step("Suggester.Suggest"))
                dtos = s.Suggest(p);

            return(dtos);
        }
Example #33
0
        public void CreateIndex(string name, IEnumerable <IFieldDefinition> fieldDefinitions)
        {
            var amazonSearchParameters = this.GetAmazonParams();
            var region = RegionEndpoint.GetBySystemName(amazonSearchParameters[Region]);

            //You must add here your accessKey and SecretAccessKey. See here how to get them: http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html
            using (IAmazonCloudSearch cloudSearchClient = AWSClientFactory.CreateAmazonCloudSearchClient(amazonSearchParameters[AccessKey], amazonSearchParameters[SecretAccessKey], region))
            {
                try
                {
                    var domainNames = cloudSearchClient.ListDomainNames();
                    if (!domainNames.DomainNames.ContainsKey(name))
                    {
                        CreateDomainRequest domainRequest = new CreateDomainRequest();
                        domainRequest.DomainName = name;
                        cloudSearchClient.CreateDomain(domainRequest);
                    }

                    if (fieldDefinitions == null)
                    {
                        throw new ArgumentNullException("fieldDefinitions");
                    }

                    foreach (var fieldDefinition in fieldDefinitions)
                    {
                        DefineIndexFieldRequest request = new DefineIndexFieldRequest();
                        request.DomainName = name;
                        request.IndexField = new IndexField();
                        request.IndexField.IndexFieldName = fieldDefinition.Name.ToLowerInvariant();
                        if (fieldDefinition.Type == null || fieldDefinition.Type == typeof(string))
                        {
                            request.IndexField.IndexFieldType = IndexFieldType.Text;
                        }
                        if (fieldDefinition.Type == typeof(string[]))
                        {
                            request.IndexField.IndexFieldType = IndexFieldType.TextArray;
                        }
                        if (fieldDefinition.Type == typeof(int))
                        {
                            request.IndexField.IndexFieldType = IndexFieldType.Int;
                        }
                        if (fieldDefinition.Type == typeof(DateTime))
                        {
                            request.IndexField.IndexFieldType = IndexFieldType.Date;
                        }
                        cloudSearchClient.DefineIndexField(request);
                    }

                    SearchResults searchResults = new SearchResults();
                    foreach (var field in searchResults.HighlightedFields)
                    {
                        Suggester suggester = new Suggester();
                        DocumentSuggesterOptions suggesterOptions = new DocumentSuggesterOptions();
                        suggesterOptions.FuzzyMatching     = SuggesterFuzzyMatching.None;
                        suggesterOptions.SourceField       = field.ToLowerInvariant();
                        suggester.DocumentSuggesterOptions = suggesterOptions;
                        suggester.SuggesterName            = this.GetSuggesterName(field);
                        DefineSuggesterRequest defineRequest = new DefineSuggesterRequest();
                        defineRequest.DomainName = name;
                        defineRequest.Suggester  = suggester;

                        cloudSearchClient.DefineSuggester(defineRequest);
                    }

                    searchResults.Dispose();

                    IndexDocumentsRequest documentRequest = new IndexDocumentsRequest();
                    documentRequest.DomainName = name;
                    cloudSearchClient.IndexDocuments(documentRequest);
                }
                catch (BaseException ex)
                {
                    Log.Write(ex.InnerException.Message);
                }
                catch (LimitExceededException ex)
                {
                    Log.Write(ex.InnerException.Message);
                }
                catch (InternalException ex)
                {
                    Log.Write(ex.InnerException.Message);
                }
            }
        }
Example #34
0
        /// <summary>
        /// Processes the sequence of movements the user performed since the last centre focus
        /// </summary>
        private void centreProcessing()
        {
            keyboardTimer.Stop();

            if (isBetsy) //changing back to the original font
            {
                for (int i = 0; i <= 7; i++)
                {
                    var obj = (Label)FindName("min" + i.ToString());
                    obj.FontFamily = new FontFamily("Segoe UI");
                }
                isBetsy = false;
            }
            string finalChar;

            lastPanel = "";
            if (centreProcessed) //if the centre was already processed (no movement to the borders so far), no operation needed
            {
                return;
            }

            switch (blockType)
            {
            case 1:     //Blocked to rest
                if (composition == "-12345" || composition == "-10765")
                {
                    stateTransition.Play();
                    isBlocked = false;
                    blockType = 0;
                    //Restoring default UI
                    locklogo.Visibility = System.Windows.Visibility.Hidden;
                    txtInput.Visibility = System.Windows.Visibility.Visible;
                    for (int i = 8; i < 35; i++)
                    {
                        var obj = (Label)FindName(labelNames[i]);
                        obj.Visibility = System.Windows.Visibility.Visible;
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        suggestionStackPanel[i].Visibility = Visibility.Visible;
                    }
                }
                break;

            case 2:     //Blocked to read full text
                if (composition == "-12345" || composition == "-10765")
                {
                    stateTransition.Play();
                    isBlocked = false;
                    blockType = 0;
                    // Restoring default UI
                    txtInput.Margin = new Thickness(txtInput.Margin.Left / textBoxMarginCoefW,
                                                    txtInput.Margin.Top / textBoxMarginCoefH, txtInput.Margin.Right / textBoxMarginCoefW,
                                                    txtInput.Margin.Bottom / textBoxMarginCoefH);
                    for (int i = 8; i < 35; i++)
                    {
                        var obj = (Label)FindName(labelNames[i]);
                        obj.Visibility = System.Windows.Visibility.Visible;
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        suggestionStackPanel[i].Visibility = Visibility.Visible;
                    }
                }
                break;

            case 3:
                if (composition == "-3")
                {
                    stateTransition.Play();
                    isBlocked = false;
                    blockType = 0;
                    unblockingEvent();
                }
                break;

            default:     //No Block
                if (!isCancelled)
                {
                    if (composition == "-")     //if there was no movement to the extremities
                    {
                        goto didntLeaveCentre;  //jumps all the character processing
                    }
                    if (composition == "-12345")
                    {
                        stateTransition.Play();
                        isBlocked = true;
                        blockType = 1;
                        // Blocking Screen to rest mode
                        locklogo.Visibility = System.Windows.Visibility.Visible;
                        txtInput.Visibility = System.Windows.Visibility.Hidden;
                        for (int i = 8; i < 35; i++)
                        {
                            var obj = (Label)FindName(labelNames[i]);
                            obj.Visibility = System.Windows.Visibility.Hidden;
                        }

                        for (int i = 0; i < 4; i++)
                        {
                            suggestionStackPanel[i].Visibility = Visibility.Hidden;
                        }
                        goto hasJustBeenBlocked;     //jumps all the character processing
                    }
                    if (composition == "-10765")
                    {
                        stateTransition.Play();
                        isBlocked = true;
                        blockType = 2;
                        // Block Screen to read mode
                        txtInput.Margin = new Thickness(txtInput.Margin.Left * textBoxMarginCoefW,
                                                        txtInput.Margin.Top * textBoxMarginCoefH, txtInput.Margin.Right * textBoxMarginCoefW,
                                                        txtInput.Margin.Bottom * textBoxMarginCoefH);

                        for (int i = 8; i < 35; i++)
                        {
                            var obj = (Label)FindName(labelNames[i]);
                            obj.Visibility = Visibility.Hidden;
                        }
                        for (int i = 0; i < 4; i++)
                        {
                            suggestionStackPanel[i].Visibility = Visibility.Hidden;
                        }
                        goto hasJustBeenBlocked;     //jumps all the character processing
                    }

                    //suggestions' acceptance
                    if (composition == "-701" || composition == "-107")
                    {
                        acceptSuggestion(0);
                        goto acceptedSuggestion;
                    }
                    if (composition == "-123" || composition == "-321")
                    {
                        acceptSuggestion(1);
                        goto acceptedSuggestion;
                    }
                    if (composition == "-567" || composition == "-765")
                    {
                        acceptSuggestion(2);
                        goto acceptedSuggestion;
                    }
                    if (composition == "-345" || composition == "-543")
                    {
                        acceptSuggestion(3);
                        goto acceptedSuggestion;
                    }


                    //No suggestion accepted, so go on...
                    for (int i = 0; i < 4; i++)     //Clear all the suggestion labels
                    {
                        //suggestionLabel[i].Content = "";
                        suggestionLabel[i].Text = "";
                    }
                    try
                    {       //Prepare to print a character composed of 2 movements
                        charToPrint = composition.Substring(1, 2);
                    }
                    catch
                    {       //Prepare to print a character composed of a single movement
                        charToPrint = composition.Substring(1, 1);
                    }

                    //Process the "character to be concatenated" / "operation to be done" in the TextBox
                    finalChar = CharacterDecoder.generateCharacter(charToPrint, blockType, primaryKeyboard);

                    #region codigoDoColetor

                    /*
                     * //Data colector implementation below
                     * if (!File.Exists(path))
                     * {
                     *  using (StreamWriter writer = new StreamWriter(path))
                     *  {
                     *      writer.WriteLine("0"); // Tempo Total
                     *      writer.WriteLine("0"); // Caracteres Total
                     *      writer.WriteLine("0"); // Erros Total
                     *      writer.WriteLine(" "); // Vetor de erros
                     *  }
                     * }
                     * using(StreamReader readtext = new StreamReader(path))
                     * {
                     * arquivo[0] = readtext.ReadLine();
                     * arquivo[1] = readtext.ReadLine();
                     * arquivo[2] = readtext.ReadLine();
                     * arquivo[3] = readtext.ReadLine();
                     * }
                     *
                     * if (colectorOn == true && finalChar != "ESPAÇO" && finalChar != "." && finalChar != "DEL")
                     * {
                     *  caracteresTotal++;
                     * }
                     *
                     * //Erro no coletor aqui!
                     *
                     * //if (colectorOn == true && finalChar == "DEL")
                     * //{
                     * //    erros++;
                     * //    arquivo[3] = arquivo[3] + ";" + txtInput.Text.Substring(txtInput.Text.Length - 1);
                     * //}
                     *
                     * if (colectorOn == true && finalChar == "ESPAÇO" || finalChar == ".")
                     * {
                     *  timer.Stop();
                     *  colectorOn = false;
                     *
                     *  int aux;
                     *  long aux2;
                     *  aux2 = Int32.Parse(arquivo[0]);
                     *  aux2 += timer.ElapsedMilliseconds;
                     *  arquivo[0] = aux2.ToString();
                     *
                     *  aux = Int32.Parse(arquivo[1]);
                     *  aux += caracteresTotal;
                     *  arquivo[1] = aux.ToString();
                     *
                     *  aux = Int32.Parse(arquivo[2]);
                     *  aux += erros;
                     *  arquivo[2] = aux.ToString();
                     *
                     *  caracteresTotal = 0;
                     *  erros = 0;
                     *
                     * }
                     *
                     * if (colectorOn == false && finalChar != "ESPAÇO" && finalChar != "." && finalChar != "DEL")
                     * {
                     *  colectorOn = true;
                     *  timer.Start();
                     *  caracteresTotal++;
                     * }
                     *
                     * using (StreamWriter writer = new StreamWriter(path))
                     * {
                     *  writer.WriteLine(arquivo[0]); // Tempo Total
                     *  writer.WriteLine(arquivo[1]); // Caracteres Total
                     *  writer.WriteLine(arquivo[2]); // Erros Total
                     *  writer.WriteLine(arquivo[3]); // Vetor de erros
                     * }
                     */
                    #endregion


                    // enteredCharacter1|number1(milliseconds)-enteredCharacter2|number2(milliseconds)
                    characterTimestampRecord += "char|" + finalChar + "|" + dataTimer.ElapsedMilliseconds.ToString() + "\n";


                    switch (finalChar)
                    {
                    case "&":
                        goto cancelledCharacter;

                    case "ESPAÇO":
                        finalChar = " ";
                        txtInput.AppendText(finalChar);         //append a space
                        Suggester.indexWord(currentWord);
                        currentWord = "";
                        break;

                    case ".":
                        if (txtInput.Text.Length == 0)
                        {
                            goto didntLeaveCentre;
                        }
                        nextIsUpper = true;
                        if (txtInput.Text.Substring(txtInput.Text.Length - 1) == " ")
                        {
                            txtInput.Text = txtInput.Text.Substring(0, txtInput.Text.Length - 1);
                        }
                        txtInput.AppendText(finalChar + " ");
                        Suggester.indexWord(currentWord);
                        currentWord = "";
                        MessageBox.Show("pontofinal!");
                        isBlocked = true;
                        blockType = 3;
                        blockingEvent(txtInput.Text, dataTimer.ElapsedMilliseconds, numberOfDeletions);
                        goto sentenceIsOver;

                    case "DEL":
                        string inputContent = txtInput.Text;
                        string aux;
                        numberOfDeletions++;
                        try
                        {
                            aux = inputContent.Substring(0, inputContent.Length - 1);
                            //delete a character. If it was in upper case, the next character to be written must be written in upper case too
                            if (inputContent.Substring(inputContent.Length - 1) == ".")
                            {
                                nextIsUpper = false;
                            }
                            else
                            {           //if the last erased character was a space, do not uppercase the next letter to be inserted
                                if (inputContent.LastIndexOf(" ") != inputContent.Length - 1)
                                {
                                    if (inputContent.Substring(inputContent.Length - 1) == inputContent.Substring(inputContent.Length - 1).ToUpper())
                                    {
                                        nextIsUpper = true;
                                    }

                                    if (currentWord.Length > 0)
                                    {
                                        currentWord = currentWord.Substring(0, currentWord.Length - 1);
                                    }
                                }
                                else         //if it was a space, so the current word is the whole last word
                                {
                                    //aux is the current text written without the last character (space in this case)

                                    try
                                    {
                                        //takes the last written word as current word
                                        currentWord = aux.Substring(aux.LastIndexOf(" ") + 1, aux.Length - aux.LastIndexOf(" ") - 1);
                                    }
                                    catch
                                    {
                                        currentWord = aux.Substring(0, aux.Length);
                                    }

                                    //if '.' is the last character, it must be removed too.
                                    if (aux[aux.Length - 1] == '.')
                                    {
                                        currentWord = currentWord.Substring(0, currentWord.Length - 1);
                                        aux         = aux.Substring(0, aux.Length - 1);
                                        nextIsUpper = false;
                                    }
                                }
                            }
                            addSuggestionsToLabels();

                            txtInput.Text = "";
                            txtInput.AppendText(aux);
                        }
                        catch
                        {
                            Console.WriteLine("txtInput is empty!");
                        }
                        break;

                    default:         //if it's not space, '.' or delete operations, so the character must be simply added to the TextBox

                        if (!nextIsUpper)
                        {
                            finalChar = finalChar.ToLower();
                        }

                        txtInput.AppendText(finalChar);
                        currentWord += finalChar;         //currentWord receives the last char

                        //TODO: fazer sons tocarem quando digitar jj e jjj em loop e parar quando digitar outro simbolo que não j.

                        addSuggestionsToLabels();

                        nextIsUpper = false;         //after the upper case letter has been already entered, the next one will be lower for sure
                        break;
                    }
                }
                else
                {
                    isCancelled = !isCancelled; //the letter that was cancelled wasn't processed and the next may not be cancelled
                }
                break;                          //breaking the default case
            }
acceptedSuggestion:
didntLeaveCentre:
hasJustBeenBlocked:
cancelledCharacter:
sentenceIsOver:
            txtInput.ScrollToEnd(); //always focus the end of the txtBox
            primaryKeyboard = true;
            composition     = "-";
            centreProcessed = true;
        }
Example #35
0
        /// <summary>
        /// prepare suggestion for suggesting based on whole input models
        /// A pretty CPU intensive task!
        /// </summary>
        private void prepareSuggestions()
        {
            if (sourceASTL != null && targetASTL != null)
            {
                SuggesterConfig config = new SuggesterConfig();
                config.UseIsoRankSimSuggester = true;
                config.UseNameSimSuggester = true;
                config.UseStructSimSuggester = true;
                config.UseValueSimSuggester = true;
                config.UseTypeSimSuggester = true;

                this.sourceASTL.prepare();
                this.targetASTL.prepare();
                mapperSuggester = new Suggester(sourceASTL, targetASTL, config);

                //this.updateSuggestions(this.mapperSuggester.getOrderedSuggestionsAsStrings(this.mapperSuggester.getSuggestions()));
                //this.updateSuggestions(this.mapperSuggester.getSuggestionsAsStrings(this.mapperSuggester.getRankedSuggestions(1)));
                this.updateSuggestions(this.mapperSuggester.getSuggestionsAsStrings(this.mapperSuggester.imFeelingLucky()), true);

                ReportStatusBar.ShowStatus("Suggestions updated.", ReportIcon.Info);
            }
        }
Example #36
0
        public Mapper()
        {
            InitializeComponent();

            //For interaction modes in Mapper.
            InteractModes = new List<string> { "Mouse", "Stylus", "Gesture", "Stylus and Gesture" };
            InteractionModeCombobox.ItemsSource = InteractModes;
            InteractionModeCombobox.SelectedIndex = 0;

            //style for values list box -> rule designer
            Style valuesListboxStyle = new Style();
            EventSetter esVSMouseDown = new EventSetter(ListBoxItem.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(ValueListBox_PreviewMouseDown));
            EventSetter esVSMouseMove = new EventSetter(ListBoxItem.PreviewMouseMoveEvent, new MouseEventHandler(ValueListBox_PreviewMouseMove));
            valuesListboxStyle.Setters.Add(esVSMouseDown);
            valuesListboxStyle.Setters.Add(esVSMouseMove);
            ValuesListBox.ItemContainerStyle = valuesListboxStyle;

            RulesListBox.ItemsSource = Matches;

            //style for defined rules list box
            //Style rulesListboxStyle = new Style();
            //EventSetter esMouseDown = new EventSetter(ListBoxItem.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(ListBoxItem_PreviewMouseDown));
            //EventSetter esMouseMove = new EventSetter(ListBoxItem.PreviewMouseMoveEvent, new MouseEventHandler(ListBoxItem_MouseMove));
            //rulesListboxStyle.Setters.Add(esMouseDown);
            //rulesListboxStyle.Setters.Add(esMouseMove);
            //RulesListBox.ItemContainerStyle = rulesListboxStyle;

            suggestions = new ObservableCollection<Suggestion>();
            SuggestionsListBox.ItemsSource = suggestions;

            //set them to true
            mapperSuggester = new Suggester();

            //load functions toolbox
            functionsToolBox = new Toolbox();
            string functionsFile = "../../Resources/Functions.xml";
            loadFunctionsToolbox(functionsFile, functionsToolBox);

            FunctionsExpander.Content = functionsToolBox;
            FunctionsExpander.IsExpanded = true;

            //Logger
            logger = new Logger("MapperLogger");
            logsTab.Content = logger;
        }