usaxena95 created this revision.
usaxena95 added a reviewer: adamcz.
Herald added subscribers: kadircet, arphaman.
usaxena95 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.
A better sampling strategy was used to generate the dataset for this
model.
New signals introduced in this model:
- NumNameInContext: Number of words in the context that matches the name
of the candidate.
- FractionNameInContext: Fraction of the words in context matching the
name of the candidate.
We remove the signal `IsForbidden` from the model and down rank
forbidden signals aggresively.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D94697
Files:
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/quality/model/features.json
clang-tools-extra/clangd/quality/model/forest.json
Index: clang-tools-extra/clangd/quality/model/features.json
===================================================================
--- clang-tools-extra/clangd/quality/model/features.json
+++ clang-tools-extra/clangd/quality/model/features.json
@@ -1,8 +1,4 @@
[
- {
- "name": "FilterLength",
- "kind": "NUMBER"
- },
{
"name": "IsDeprecated",
"kind": "NUMBER"
@@ -20,11 +16,15 @@
"kind": "NUMBER"
},
{
- "name": "IsNameInContext",
+ "name": "NumNameInContext",
"kind": "NUMBER"
},
{
- "name": "IsForbidden",
+ "name": "FractionNameInContext",
+ "kind": "NUMBER"
+ },
+ {
+ "name": "IsNameInContext",
"kind": "NUMBER"
},
{
@@ -32,7 +32,7 @@
"kind": "NUMBER"
},
{
- "name": "FileProximityDistance",
+ "name": "FileProximityDistanceCost",
"kind": "NUMBER"
},
{
@@ -40,7 +40,7 @@
"kind": "NUMBER"
},
{
- "name": "SymbolScopeDistance",
+ "name": "SymbolScopeDistanceCost",
"kind": "NUMBER"
},
{
@@ -81,4 +81,4 @@
"type": "clang::clangd::SymbolRelevanceSignals::AccessibleScope",
"header": "Quality.h"
}
-]
\ No newline at end of file
+]
Index: clang-tools-extra/clangd/Quality.cpp
===================================================================
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -501,12 +501,23 @@
SymbolRelevanceSignals::DerivedSignals Derived =
Relevance.calculateDerivedSignals();
- E.setIsNameInContext(Derived.NameMatchesContext);
- E.setIsForbidden(Relevance.Forbidden);
+ int NumMatch = 0;
+ if (Relevance.ContextWords) {
+ for (const auto &Word : Relevance.ContextWords->keys()) {
+ if (Relevance.Name.contains_lower(Word)) {
+ ++NumMatch;
+ }
+ }
+ }
+ E.setIsNameInContext(NumMatch > 0);
+ E.setNumNameInContext(NumMatch);
+ E.setFractionNameInContext(
+ Relevance.ContextWords ? NumMatch * 1.0 / Relevance.ContextWords->size()
+ : 0);
E.setIsInBaseClass(Relevance.InBaseClass);
- E.setFileProximityDistance(Derived.FileProximityDistance);
+ E.setFileProximityDistanceCost(Derived.FileProximityDistance);
E.setSemaFileProximityScore(Relevance.SemaFileProximityScore);
- E.setSymbolScopeDistance(Derived.ScopeProximityDistance);
+ E.setSymbolScopeDistanceCost(Derived.ScopeProximityDistance);
E.setSemaSaysInScope(Relevance.SemaSaysInScope);
E.setScope(Relevance.Scope);
E.setContextKind(Relevance.Context);
@@ -514,7 +525,6 @@
E.setHadContextType(Relevance.HadContextType);
E.setHadSymbolType(Relevance.HadSymbolType);
E.setTypeMatchesPreferred(Relevance.TypeMatchesPreferred);
- E.setFilterLength(Relevance.FilterLength);
DecisionForestScores Scores;
// Exponentiating DecisionForest prediction makes the score of each tree a
@@ -525,6 +535,9 @@
// data that needs fixits is not-feasible.
if (Relevance.NeedsFixIts)
Scores.ExcludingName *= 0.5;
+ if (Relevance.Forbidden)
+ Scores.ExcludingName *= 0;
+
// NameMatch should be a multiplier on total score to support rescoring.
Scores.Total = Relevance.NameMatch * Scores.ExcludingName;
return Scores;
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits