openfarmcc / OpenFarm

A free and open database for farming and gardening knowledge. You can grow anything!
https://OpenFarm.cc
MIT License
1.56k stars 242 forks source link

Make it easier to find a growing guide for a 'parent' or related crop #842

Open CloCkWeRX opened 8 years ago

CloCkWeRX commented 8 years ago

All of these: https://openfarm.cc/en/en/crop_search?q=Cucurbita+pepo

can probably be grown following the general directions tied to https://openfarm.cc/en/crops/pumpkin (Cucurbita).

EOL for example does this with a heirachy control (http://eol.org/pages/38266/overview); however a poor man's version of this might be to simply search for crops with a bionomial name contained entirely in the current crops' binomial name.

in psuedocode, something like:

def find_parent_crops(binomial_name)
  return if binomial_name.empty?
  search_criteria = binomial_name.split(' ')[0...-1].join(' ')
  parent_crop_candidates = Crops.where(name: search_criteria)
  return find_parent_crops(search_criteria) unless parent_crop_candidates.any?
end

Most commonly, it's going to end up being no more than 2-3 queries, unless there is anything horrible like 'foo var bar x bar var foo'.

Alternatively, giving shorter binomial name crops or crops with photos a higher ranking in search results may help in situations like this:

image

CloCkWeRX commented 8 years ago

Not sure if I've really captured the essence of this properly; basically if you search for 'pumpkin' you get no guides; but 'cucurbita pepo' (named squash in this instance) actually has a guide.

simonv3 commented 8 years ago

Yeah, figuring out that search is definitely a necessary thing to do.

One thing to note is that the Crop model has a knowledge of "varieties" and "parent". I don't think any of that data is filled in at the moment, but it's probably relevant. Going through the most popular crops and linking those is probably a necessary todo task as well. There is no interface for this at the moment except for the admin panel.