| 826 | 'module': -1000, 'object': -1000} |
| 827 | |
| 828 | def relevance(name, docstr, kind, index): |
| 829 | r = 0 |
| 830 | # do the keywords occur within the start of the docstring? |
| 831 | first_doc = "\n".join(docstr.lower().strip().split("\n")[:3]) |
| 832 | r += sum([200 for w in whats if w in first_doc]) |
| 833 | # do the keywords occur in the function name? |
| 834 | r += sum([30 for w in whats if w in name]) |
| 835 | # is the full name long? |
| 836 | r += -len(name) * 5 |
| 837 | # is the object of bad type? |
| 838 | r += kind_relevance.get(kind, -1000) |
| 839 | # is the object deep in namespace hierarchy? |
| 840 | r += -name.count('.') * 10 |
| 841 | r += max(-index / 100, -100) |
| 842 | return r |
| 843 | |
| 844 | def relevance_value(a): |
| 845 | return relevance(a, *cache[a]) |