11#if !CLANGD_DECISION_FOREST
20 llvm::errs() <<
"Clangd was compiled without decision forest support.\n";
29#include "CompletionModel.h"
38 const SymbolRelevanceSignals &Relevance,
float Base) {
40 E.setIsDeprecated(
Quality.Deprecated);
41 E.setIsReservedName(
Quality.ReservedName);
42 E.setIsImplementationDetail(
Quality.ImplementationDetail);
43 E.setNumReferences(
Quality.References);
44 E.setSymbolCategory(
Quality.Category);
46 SymbolRelevanceSignals::DerivedSignals Derived =
47 Relevance.calculateDerivedSignals();
49 if (Relevance.ContextWords) {
50 for (
const auto &
Word : Relevance.ContextWords->keys()) {
51 if (Relevance.Name.contains_insensitive(
Word)) {
56 E.setIsNameInContext(NumMatch > 0);
57 E.setNumNameInContext(NumMatch);
58 E.setFractionNameInContext(
59 Relevance.ContextWords && !Relevance.ContextWords->empty()
60 ? NumMatch * 1.0 / Relevance.ContextWords->size()
62 E.setIsInBaseClass(Relevance.InBaseClass);
63 E.setFileProximityDistanceCost(Derived.FileProximityDistance);
64 E.setSemaFileProximityScore(Relevance.SemaFileProximityScore);
65 E.setSymbolScopeDistanceCost(Derived.ScopeProximityDistance);
66 E.setSemaSaysInScope(Relevance.SemaSaysInScope);
67 E.setScope(Relevance.Scope);
68 E.setContextKind(Relevance.Context);
69 E.setIsInstanceMember(Relevance.IsInstanceMember);
70 E.setHadContextType(Relevance.HadContextType);
71 E.setHadSymbolType(Relevance.HadSymbolType);
72 E.setTypeMatchesPreferred(Relevance.TypeMatchesPreferred);
74 DecisionForestScores Scores;
78 Scores.ExcludingName = pow(Base, Evaluate(
E));
83 if (Relevance.NeedsFixIts)
84 Scores.ExcludingName *= 0.5;
85 if (Relevance.Forbidden)
86 Scores.ExcludingName *= 0;
88 Scores.ExcludingName *= 4;
91 Scores.Total = Relevance.NameMatch * Scores.ExcludingName;
SignatureQualitySignals Quality
DecisionForestScores evaluateDecisionForest(const SymbolQualitySignals &Quality, const SymbolRelevanceSignals &Relevance, float Base)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Attributes of a symbol that affect how much we like it.
Attributes of a symbol-query pair that affect how much we like it.