private List <TaxonomicClassification> GetBestMatchingTaxonomies(SpeciesInfo candidate, List <TaxonomicClassification> localTaxonomies) { var speciesMatches = GetAllMatchesForSpecies(candidate, localTaxonomies); if (speciesMatches.Count > 0) { return(speciesMatches); } if (candidate.GetName().ToLower() == "human") { return(new List <TaxonomicClassification>()); //TODO: hack to prevent overzealous matching for humans. Need to figure out a better way... } var genusMatches = GetAllMatchesForGenus(candidate, localTaxonomies); if (genusMatches.Count > 0) { return(genusMatches); } var familyMatches = GetAllMatchesForFamily(candidate, localTaxonomies); if (familyMatches.Count > 0) { return(familyMatches); } return(new List <TaxonomicClassification>()); }
private void LoadSpecieInfo() { SpeciesInfo sInfo = _dataAccess.GetSpecieInfo(speciesComboBox.Text); //Load species info enviormentAddTextBox.Text = sInfo.EnviormentName; foodTypeAddTextBox.Text = sInfo.FoodTypName; countryAddBox.Text = sInfo.CountryName; AddParentsToComboBox(); }
public List <SpeciesInfo> Filter(List <SpeciesInfo> speciesInfos, GeographyPoint coordinates) { var sortedSpeciesInfosArray = new SpeciesInfo[speciesInfos.Count]; speciesInfos.CopyTo(sortedSpeciesInfosArray); var sortedSpeciesInfos = new List <SpeciesInfo>(sortedSpeciesInfosArray); sortedSpeciesInfos.Sort((candidate1, candidate2) => candidate2.GetProbability().CompareTo(candidate1.GetProbability())); return(sortedSpeciesInfos.Where(speciesInfo => speciesInfo.GetProbability() >= GetMinProbability(speciesInfo)).ToList()); }
protected void Page_Load(object sender, EventArgs e) { if (String.IsNullOrEmpty(Request.QueryString.Get("SpeciesID"))) { Response.Redirect("Default.aspx"); } // if (!String.IsNullOrEmpty(Request.QueryString.Get("RecipeID"))) int itemID = Convert.ToInt32(Request.QueryString.Get("SpeciesID")); CurrentSpecies = SpeciesGateway.SpeciesInfoGetBySpeciesID(itemID); if (CurrentSpecies == null || CurrentSpecies.Name.Equals("n/a")) { Response.Redirect("Default.aspx"); } Title = CurrentSpecies.Name; } // method Page_Load
} // method GetAllSpecies public static SpeciesInfo SpeciesInfoGetBySpeciesID(long objectID) { string cacheKey = "AllSpeciesBySpeciesID_" + objectID; SpeciesInfo returnObject = HttpContext.Current.Cache[cacheKey] as SpeciesInfo; if (returnObject == null) using (RepopdataEntities myEntities = new RepopdataEntities()) { var result = (from item in myEntities.Species where item.speciesID == objectID select item).FirstOrDefault(); if (result == null) { return null; } returnObject = new SpeciesInfo(result); AppCaching.AddToCache(cacheKey, returnObject); } // using return returnObject; } // method SpeciesInfoGetBySpeciesID
public IActionResult Index(string cName) { ViewBag.cName = cName; ViewBag.noData = ""; if (string.IsNullOrEmpty(cName)) { // return(View()); } else { WebClient obj = new WebClient(); obj.Encoding = Encoding.UTF8; //設定編碼解決亂碼問題 string url = string.Format("http://ngismap.forest.gov.tw/REST/species/ScientificName_C/{0}", cName); var str = obj.DownloadString(url); if (str == @"{""species_info"":[]}") { ViewBag.noData = "查無「" + cName + "」相關資料..."; } else { JObject objJsonTxt = JObject.Parse(str); JToken objNameTxtList = objJsonTxt.SelectToken("species_info"); List <CJData> jDatas = new List <CJData>(); foreach (JToken SpeciesInfo in objNameTxtList) { var addData = new CJData { name = SpeciesInfo.SelectToken("name").Value <string>(), cName = SpeciesInfo.SelectToken("Common_name_c").Value <string>(), nameCode = SpeciesInfo.SelectToken("name_code").Value <string>() }; jDatas.Add(addData); } ViewBag.jDatas = jDatas; } //return Content(objNameTxtList.ToString()); } return(View()); }
private List <SpeciesInfo> GetBestMatchingLocalSpecies(List <SpeciesInfo> candidates, List <TaxonomicClassification> localTaxonomies) { var bestMatchTaxonomies = new List <TaxonomicClassification>(); var selectedCandidate = candidates.First(); foreach (var candidate in candidates) { bestMatchTaxonomies = GetBestMatchingTaxonomies(candidate, localTaxonomies); if (bestMatchTaxonomies.Count <= 0) { continue; } selectedCandidate = candidate; break; } if (bestMatchTaxonomies.Count == 0) { return(new List <SpeciesInfo> { selectedCandidate }); } var bestMatchSpeciesInfos = new List <SpeciesInfo>(); foreach (var taxonomy in bestMatchTaxonomies) { var commonName = _wolframClient.GetCommonNameFromScientific(taxonomy); var scientificName = taxonomy.GetGenus() + " " + taxonomy.GetSpecies(); var finalName = String.IsNullOrEmpty(commonName) ? (String.IsNullOrEmpty(selectedCandidate.GetTagName()) ? scientificName : selectedCandidate.GetTagName()) : commonName; var speciesInfo = SpeciesInfo.GetInstance(taxonomy, finalName, selectedCandidate.GetTagName(), selectedCandidate.GetProbability()); bestMatchSpeciesInfos.Add(speciesInfo); } return(bestMatchSpeciesInfos); }
public SpeciesInfo GetSpecieInfo(string speciesName) { SpeciesInfo specie = null; using (var db = new ZooContext()) { Species species = db.Species.SingleOrDefault(s => s.SName == speciesName); if (species != null) { specie = new SpeciesInfo() { Id = species.Id, SpeciesName = species.SName, EnviormentName = species.Enviorment.EName, CountryName = species.Country, FoodTypName = species.FoodType.FName }; } } return(specie); }
public void DestroyElement() { if (m_RemoveEffect != null) { GameObject effect = (GameObject)Instantiate(m_RemoveEffect, transform.position, transform.rotation); DestroyEffect de = effect.GetComponent <DestroyEffect>(); de.SetRescue(m_Species != null); } m_InfoBar.AddMaterial(1); DestroyObject(gameObject); m_BG.SetElementByCoord(m_TargetCoord, null); if (m_SkillBt != null) { m_SkillBt.AddAmount(0.2f); } if (m_Species != null) { SpeciesInfo si = m_Species.GetComponent <SpeciesInfo>(); si.SpeciesRescued(); m_InfoBar.AddDNANum(1); } }
private Double GetMinProbability(SpeciesInfo speciesInfo) { var key = speciesInfo.GetName().ToLower(); return(ProbabilityMins.ContainsKey(key) ? ProbabilityMins[key] : ProbabilityMins["default"]); }
private void CreateSpeciesInfo() { var defaultSpeciesInfo = _context.SpeciesInfos.IgnoreQueryFilters().FirstOrDefault(e => e.Name == "گاو"); if (defaultSpeciesInfo == null) { defaultSpeciesInfo = new SpeciesInfo() { Code = "1", Name = "گاو" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "2", Name = "گاومیش" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "3", Name = "شتر" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "4", Name = "گوسفند" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "5", Name = "بز" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "6", Name = "اسب" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "7", Name = "پرندگان و طیور" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "8", Name = "حیوانات کوچک و زینتی" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "9", Name = "آبزیان" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "81", Name = "سگ سانان" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "82", Name = "گربه سانان" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); defaultSpeciesInfo = new SpeciesInfo() { Code = "73", Name = "شترمرغ" }; _context.SpeciesInfos.Add(defaultSpeciesInfo); _context.SaveChanges(); } }
//Humans are a special case here- only allow for exact species matches; Otherwise, human identification tends to overfire private List <TaxonomicClassification> GetAllMatchesForFamily(SpeciesInfo candidate, List <TaxonomicClassification> localTaxonomies) { return(localTaxonomies.Where(localTaxonomy => (String.Equals(localTaxonomy.GetFamily(), candidate.Taxonomy.GetFamily(), StringComparison.InvariantCultureIgnoreCase) && !String.Equals(localTaxonomy.GetSpecies(), "Sapiens", StringComparison.InvariantCultureIgnoreCase))).ToList()); }