public float Get(string lat, string lng, int province_id, int amphur_code, int well, int road, int shape, int width, int type_size, int distance, int appraisal, int size) { SearchPlace sp = new SearchPlace(); var search = sp.getPlace(lat, lng); int a = appraisal; float area = size; var nearby_parse = float.Parse(search, CultureInfo.InvariantCulture.NumberFormat); var weight_fac = sp.getWeight(province_id, amphur_code, well, road, shape, width, type_size, distance); var wf_parse = float.Parse(weight_fac, CultureInfo.InvariantCulture.NumberFormat); var weight_road = sp.getRoad(); var wr_parse = float.Parse(weight_road, CultureInfo.InvariantCulture.NumberFormat); var sums = (wf_parse * a) + (nearby_parse * a) + (wr_parse * a); var total = sums * area; return(total); }
public override void OnInspectorGUI() { // DrawDefaultInspector(); place = target as SearchPlace; if (place != null) { GUILayout.BeginHorizontal("Box"); GUILayout.Label("Enter location name", LayerSettingWindows.GuiTitleSize(14, TextAnchor.MiddleCenter, Color.black)); place.namePlace = EditorGUILayout.TextField("", place.namePlace, GUILayout.Height(20)); GUILayout.EndHorizontal(); // Debug.Log(place.namePlace == String.Empty); if (place.namePlace == String.Empty) { place.namePlaceСache = ""; place.DataStructure.dataChache.Clear(); EditorGUILayout.HelpBox("Enter place name", MessageType.Info); } else { place.SearchInOSM(); } if (place.DataStructure.dataChache != null) { EditorGUILayout.Separator(); ShowSaveLocation(); EditorGUILayout.Separator(); ShowFoundLocation(); } } Repaint(); }
private SearchPlace DocToSearchPlace(Document doc) { var place = new SearchPlace(); place.OpeningHours = new OpeningHours(); place.Id = doc.GetField(Schema.Id).StringValue; place.Name = doc.GetField(Schema.Name).StringValue; place.Rating = double.Parse(doc.GetField(Schema.Rating).StringValue); place.Vicinity = doc.GetField(Schema.Vicinity).StringValue; place.Types = doc.GetValues(Schema.Types); bool open = false; if (bool.TryParse(doc.GetField(Schema.OpenNow).StringValue, out open)) { place.OpeningHours.OpenNow = open; } else { place.OpeningHours.OpenNow = false; } return(place); }
public IHttpActionResult PutSearchPlace(int id, SearchPlace searchPlace) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != searchPlace.id) { return(BadRequest()); } db.Entry(searchPlace).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!SearchPlaceExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetSearchPlace(int id) { SearchPlace searchPlace = db.SearchPlaces.Find(id); if (searchPlace == null) { return(NotFound()); } return(Ok(searchPlace)); }
public IHttpActionResult PostSearchPlace(SearchPlace searchPlace) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.SearchPlaces.Add(searchPlace); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = searchPlace.id }, searchPlace)); }
public IHttpActionResult DeleteSearchPlace(int id) { SearchPlace searchPlace = db.SearchPlaces.Find(id); if (searchPlace == null) { return(NotFound()); } db.SearchPlaces.Remove(searchPlace); db.SaveChanges(); return(Ok(searchPlace)); }
public float Get(string lat, string lng) { SearchPlace sp = new SearchPlace(); var search = sp.getPlace(lat, lng); int a = 2000; float area = 60; var nearby_parse = float.Parse(search, CultureInfo.InvariantCulture.NumberFormat); //var weight_fac = sp.getWeight(); //var wf_parse = float.Parse(weight_fac, CultureInfo.InvariantCulture.NumberFormat); var weight_road = sp.getRoad(); var wr_parse = float.Parse(weight_road, CultureInfo.InvariantCulture.NumberFormat); var sums = (nearby_parse * a) + (wr_parse * a); var total = sums * area; return(sums); }
//private string str; void OnEnable() { place = target as SearchPlace; place.DataStructure = HelperExtention.GetOrCreateSObjectReturn <StructSearchData>(ref place.DataStructure, PATH_SAVE_SCRIPTABLE_OBJECT); place.namePlaceСache = ""; // place.namePlace = ""; /*if (place.namePlace!=String.Empty) * { * place.SearchInMapzen(); * } * else * { * place.DataStructure.dataChache.Clear(); * }*/ }
public SearchEvent(string term, int?filterByCategory, int languageId, PostType?postType, SearchPlace searchPlace, int maxResult, SearchResult result) { Term = term; FilterByCategory = filterByCategory; LanguageId = languageId; PostType = postType; SearchPlace = searchPlace; MaxResult = maxResult; Result = result; }
private void Places_Click(object sender, RoutedEventArgs e) { SearchStatus.Visibility = Visibility.Hidden; SearchCategory.Visibility = Visibility.Hidden; SearchPlace.Visibility = Visibility.Visible; SearchPlace.Focus(); string connetionString = null; connetionString = "Data Source=SLAVIK;Initial Catalog=hotel;Integrated Security=True;"; SqlConnection cnn = new SqlConnection(connetionString); string command = "Select NumberOfRoom as [Номер комнаты], Place as [Место] from Places"; SqlDataAdapter da = new SqlDataAdapter(command, cnn); DataSet dt = new DataSet(); da.Fill(dt, "Places"); DataGrid1.ItemsSource = dt.Tables[0].DefaultView; }
/* -------------------------------- * Constructor * ------------------------------*/ public PlaceSearcher(string label) { addressDropdown = new DropDown(label); // Get existing open window or if none, make a new one: place = UnityEngine.Object.FindObjectOfType <SearchPlace>(); if (place == null) { SearchPlace search = new GameObject("Searcher").AddComponent <SearchPlace>(); place = search; } place.DataStructure = HelperExtention.GetOrCreateSObjectReturn <StructSearchData>(ref place.DataStructure, PATH_SAVE_SCRIPTABLE_OBJECT); place.namePlaceСache = ""; place.DataStructure.dataChache.Clear(); EditorApplication.update += this.Update; }
public override void OnInspectorGUI() { // DrawDefaultInspector(); place = target as SearchPlace; if (place != null) { place.namePlace = EditorGUILayout.TextField("NamePlace", place.namePlace); if (place.namePlace == String.Empty) { place.namePlaceСache = ""; place.dataList.Clear(); EditorGUILayout.HelpBox("Enter place name", MessageType.Info); } else { place.SearchInMapzen(); } int fl = 0; if (place.dataList != null) { for (int i = 0; i < place.dataList.Count; i++) { var style = new GUIStyle(GUI.skin.button); style.normal.textColor = Color.black; style.alignment = TextAnchor.MiddleLeft; style.fixedWidth = Screen.width - 40; if (GUILayout.Button(place.dataList[i].label, style, GUILayout.Height(20))) { place.SetupToTileManager(place.dataList[i].coordinates[1], place.dataList[i].coordinates[0]); } } } } Repaint(); }
public virtual async Task <SearchResult> SearchAsync(string term, int?filterByCategory = null, int languageId = -1, PostType?postType = null, SearchPlace searchPlace = SearchPlace.Anywhere, SearchResultSortType orderBy = SearchResultSortType.Score, int maxResult = 1000, bool exactSearch = false) { var result = new SearchResult(); term = term.Trim(); //replace multiple spaces with a single space RegexOptions options = RegexOptions.None; Regex regex = new Regex("[ ]{2,}", options); term = regex.Replace(term, " "); if (string.IsNullOrWhiteSpace(term)) { return(result); } var watch = new System.Diagnostics.Stopwatch(); watch.Start(); try { await Task.Run(() => { using (var directory = FSDirectory.Open(new DirectoryInfo(_indexFilesPath))) { using (var searcher = new IndexSearcher(directory, readOnly: true)) { var searchInFields = new List <string>(); if (searchPlace == SearchPlace.Anywhere) { searchInFields.AddRange(new string[] { "Title", "Description", "Keywords", "Tags" }); } else { if (searchPlace.HasFlagFast(SearchPlace.Title)) { searchInFields.Add("Title"); } if (searchPlace.HasFlagFast(SearchPlace.Description)) { searchInFields.Add("Description"); } if (searchPlace.HasFlagFast(SearchPlace.Keywords)) { searchInFields.Add("Keywords"); } if (searchPlace.HasFlagFast(SearchPlace.Tags)) { searchInFields.Add("Tags"); } } BooleanFilter filter = null; if (languageId > -1 || filterByCategory != null || postType != null) { filter = new BooleanFilter(); if (languageId > -1) { filter.Add(new FilterClause( new QueryWrapperFilter(new TermQuery(new Term("LanguageId", languageId.ToString()))), Occur.MUST)); } if (filterByCategory != null) { filter.Add(new FilterClause( new QueryWrapperFilter(new TermQuery(new Term("Categories", filterByCategory.Value.ToString()))), Occur.MUST)); } if (postType != null) { filter.Add(new FilterClause( new QueryWrapperFilter(new TermQuery(new Term("PostType", postType.Value.ToString()))), Occur.MUST)); } } var currentSettings = _settingService.LoadSetting <SiteSettings>(); if (!currentSettings.EnableBlog) { //Filter Blog Posts if Blog is disabled if (filter == null) { filter = new BooleanFilter(); } filter.Add(new FilterClause( new QueryWrapperFilter(new TermQuery(new Term("PostType", PostType.BlogPost.ToString()))), Occur.MUST_NOT)); } Sort sort = new Sort(SortField.FIELD_SCORE); switch (orderBy) { case SearchResultSortType.NumberOfVisits: sort = new Sort(new SortField("NumberOfVisit", SortField.INT, true)); break; case SearchResultSortType.PublishDate: sort = new Sort(new SortField("PublishDate", SortField.LONG, true)); break; case SearchResultSortType.LastUpDate: sort = new Sort(new SortField("LastUpDate", SortField.LONG, true)); break; } var analyzer = new StandardAnalyzer(Version); var parser = new MultiFieldQueryParser(Version, searchInFields.ToArray(), analyzer); QueryScorer scorer = null; var hits = new List <ScoreDoc>(); Query query = null; if (exactSearch) { query = ParseQuery(term, parser); hits.AddRange(searcher.Search(query, filter, maxResult, sort).ScoreDocs); } else { query = ParseQuery($"(\"{term}\")", parser); hits.AddRange(searcher.Search(query, filter, maxResult, sort).ScoreDocs); query = ParseQuery($"({term.Replace(" ", "*")})", parser); hits.AddRange(searcher.Search(query, filter, maxResult, sort).ScoreDocs); query = ParseQuery($"(+{term.Trim().Replace(" ", " +")})", parser); hits.AddRange(searcher.Search(query, filter, maxResult, sort).ScoreDocs); query = ParseQuery(term, parser); hits.AddRange(searcher.Search(query, filter, maxResult, sort).ScoreDocs); } scorer = new QueryScorer(query); if (hits.Count == 0) { term = SearchByPartialWords(term); query = ParseQuery(term, parser); scorer = new QueryScorer(query); hits.AddRange(searcher.Search(query, filter, maxResult, sort).ScoreDocs); } var formatter = new SimpleHTMLFormatter( "<span class='badge badge-warning'>", "</span>"); var fragmenter = new SimpleFragmenter(300); var highlighter = new Highlighter(formatter, scorer) { TextFragmenter = fragmenter }; foreach (var scoreDoc in hits) { var doc = searcher.Doc(scoreDoc.Doc); result.Documents.Add(new SearchResultDocument() { DocumentId = int.Parse(doc.Get("ID")), LanguageId = int.Parse(doc.Get("LanguageId")), LanguageIsoCode = doc.Get("LanguageCode"), Score = scoreDoc.Score, DocumentTitle = GetHighlight("Title", highlighter, analyzer, doc.Get("Title"), false), DocumentBody = GetHighlight("Description", highlighter, analyzer, doc.Get("Description"), true), DocumentKeywords = doc.Get("Keywords"), DocumentTags = doc.Get("Tags"), }); } result.Documents = result.Documents.DistinctBy(p => new { p.DocumentId }) .ToList(); analyzer.Close(); //SuggestSimilar using (var spellDirectory = FSDirectory.Open(new DirectoryInfo(_spellFilesPath))) { using (var spellChecker = new SpellChecker.Net.Search.Spell.SpellChecker(spellDirectory)) { result.SuggestSimilar.AddRange(spellChecker.SuggestSimilar(term, 10, null, null, true)); } } } } }); } catch (Exception ex) { result.Error = ex; result.HasError = true; } watch.Stop(); result.ElapsedMilliseconds = watch.ElapsedMilliseconds; _eventPublisher.Publish(new SearchEvent(term, filterByCategory, languageId, postType, searchPlace, maxResult, result)); return(result); }
private WorkDataSpellCheck(List<PO.Entry> entries, SearchPlace place, bool ignoreAllCapsWords, bool ignoreHtml, bool ignoreWordsWithDigits) : base(entries) { this.Place = place; this.IgnoreAllCapsWords = ignoreAllCapsWords; this.IgnoreHtml = ignoreHtml; this.IgnoreWordsWithDigits = ignoreWordsWithDigits; }
private WorkDataTidy(List<PO.Entry> entries, SearchPlace place, bool reportErrors, bool reportWarnings, bool unescapeStrings) : base(entries) { this.Place = place; this.ReportErrors = reportErrors; this.ReportWarnings = reportWarnings; this.UnescapeStrings = unescapeStrings; }
public SearchResult(PO.Entry entry, SearchPlace place) : this(entry, place, null, null, null) { }
public SearchResult(PO.Entry entry, SearchPlace place, int? index, int? start, int? length) : this(entry, new SearchPlace[] { place } , new int?[] { index } , new int?[] { start } , new int?[] { length }) { }
public SearchResult(PO.Entry entry, SearchPlace[] places, int?[] indexes, int?[] starts, int?[] lengths) : this(entry) { this.Places.AddRange(places); this.Indexes.AddRange(indexes); this.Starts.AddRange(starts); this.Lengths.AddRange(lengths); }
public SearchResultDescribed(PO.Entry entry, SearchPlace place, string description) : this(entry, place, null, null, null, description) { }
public SearchResultDescribed(PO.Entry entry, SearchPlace place, int? index, int? start, int? length, string description) : this(entry, new SearchPlace[] { place } , new int?[] { index } , new int?[] { start } , new int?[] { length } , description) { }
public SearchResultDescribed(PO.Entry entry, SearchPlace[] places, int?[] indexes, int?[] starts, int?[] lengths, string description) : base(entry, places, indexes, starts, lengths) { this.Description = (description == null) ? "" : description; }
private TermVectorsModel ToTermVectorsModel(ITermVectorsResponse termVectorsResult, SearchPlace doc) { return(new TermVectorsModel() { Document = doc, TermVectors = termVectorsResult.TermVectors }); }
public App() { InitializeComponent(); MainPage = new SearchPlace(); }
public virtual SearchResult MoreLikeThis(int postId, int?filterByCategory = null, int languageId = -1, PostType?postType = null, SearchPlace searchPlace = SearchPlace.Title | SearchPlace.Description, int maxResult = 5, SearchResultSortType orderBy = SearchResultSortType.Score) { var result = new SearchResult(); var watch = new System.Diagnostics.Stopwatch(); watch.Start(); try { using (var directory = FSDirectory.Open(new DirectoryInfo(_indexFilesPath))) { using (var searcher = new IndexSearcher(directory, readOnly: true)) { var docNumber = GetLuceneDocNumber(postId, searcher); if (docNumber == -1) { return(result); } var searchInFields = new List <string>(); if (searchPlace == SearchPlace.Anywhere) { searchInFields.AddRange(new string[] { "Title", "Description", "Keywords", "Tags" }); } else { if (searchPlace.HasFlagFast(SearchPlace.Title)) { searchInFields.Add("Title"); } if (searchPlace.HasFlagFast(SearchPlace.Description)) { searchInFields.Add("Description"); } if (searchPlace.HasFlagFast(SearchPlace.Keywords)) { searchInFields.Add("Keywords"); } if (searchPlace.HasFlagFast(SearchPlace.Tags)) { searchInFields.Add("Tags"); } } var analyzer = new StandardAnalyzer(Version); var moreLikeThis = new MoreLikeThis(searcher.IndexReader) { Analyzer = analyzer }; moreLikeThis.SetFieldNames(searchInFields.ToArray()); moreLikeThis.MinDocFreq = 1; moreLikeThis.MinTermFreq = 1; moreLikeThis.Boost = true; var query = moreLikeThis.Like(docNumber); var filter = new BooleanFilter(); filter.Add(new FilterClause( new QueryWrapperFilter(new TermQuery(new Term("ID", postId.ToString()))), Occur.MUST_NOT)); if (languageId > -1) { filter.Add(new FilterClause( new QueryWrapperFilter(new TermQuery(new Term("LanguageId", languageId.ToString()))), Occur.MUST)); } if (filterByCategory != null) { filter.Add(new FilterClause( new QueryWrapperFilter(new TermQuery(new Term("Categories", filterByCategory.Value.ToString()))), Occur.MUST)); } if (postType != null) { filter.Add(new FilterClause( new QueryWrapperFilter(new TermQuery(new Term("PostType", postType.Value.ToString()))), Occur.MUST)); } Sort sort = new Sort(SortField.FIELD_SCORE); switch (orderBy) { case SearchResultSortType.NumberOfVisits: sort = new Sort(new SortField("NumberOfVisit", SortField.INT, true)); break; case SearchResultSortType.PublishDate: sort = new Sort(new SortField("PublishDate", SortField.LONG, true)); break; case SearchResultSortType.LastUpDate: sort = new Sort(new SortField("LastUpDate", SortField.LONG, true)); break; } var hits = searcher.Search(query, filter, maxResult, sort).ScoreDocs; foreach (var scoreDoc in hits) { var doc = searcher.Doc(scoreDoc.Doc); result.Documents.Add(new SearchResultDocument() { DocumentId = int.Parse(doc.Get("ID")), LanguageId = int.Parse(doc.Get("LanguageId")), LanguageIsoCode = doc.Get("LanguageCode"), Score = scoreDoc.Score, DocumentTitle = doc.Get("Title"), DocumentBody = doc.Get("Description"), DocumentKeywords = doc.Get("Keywords"), DocumentTags = doc.Get("Tags"), }); } result.Documents = result.Documents.DistinctBy(p => new { p.DocumentId }) .ToList(); analyzer.Close(); } } } catch (Exception ex) { result.Error = ex; result.HasError = true; } watch.Stop(); result.ElapsedMilliseconds = watch.ElapsedMilliseconds; return(result); }