Skip to content

Commit e7ea18f

Browse files
authored
Change interesting_score to sort_score (#558)
* change interesting_score to sort_score * renaming
1 parent 37efb7d commit e7ea18f

File tree

12 files changed

+41
-41
lines changed

12 files changed

+41
-41
lines changed

apps/api.nameai.dev/nameai/models.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class NameAIReport(BaseModel):
5353
ge=0.0,
5454
le=1.0,
5555
)
56-
interesting_score: float = Field(
57-
title='Interesting score of the input',
58-
description='Score indicating how interesting/memorable the name is. For single labels, returns the score directly. For 2-label names (e.g., "nick.eth"), returns the score for the first label ("nick"). For 3 or more labels, returns 0. If the label is not inspected, this field will be 0. The score ranges from 0.0 to 1.0 inclusive, where 0.0 indicates least interesting and 1.0 indicates most interesting.',
56+
sort_score: float = Field(
57+
title='Sort score of the input',
58+
description='Score indicating the relative ranking of the name. For single labels, returns the score directly. For 2-label names (e.g., "nick.eth"), returns the score for the first label ("nick"). For 3 or more labels, returns 0. If the label is not inspected, this field will be 0. The score ranges from 0.0 to 1.0 inclusive, where 0.0 indicates lowest rank and 1.0 indicates highest rank.',
5959
ge=0.0,
6060
le=1.0,
6161
)

apps/api.nameai.dev/nameai/name_ai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ def inspect_label(self, label: str) -> NameAIResponse:
2323

2424
if nameguard_report.inspected:
2525
nlp_analysis = self.nlp_inspector.nlp_analyse_label(label)
26-
purity, interesting = self.scorer.score_label(nlp_analysis)
26+
purity, sort_score = self.scorer.score_label(nlp_analysis)
2727

2828
nameai_report = NameAIReport(
2929
purity_score=purity,
30-
interesting_score=interesting,
30+
sort_score=sort_score,
3131
analysis=NLPLabelAnalysis(
3232
inspection=nlp_analysis.inspection,
3333
status=nlp_analysis.status,
@@ -41,7 +41,7 @@ def inspect_label(self, label: str) -> NameAIResponse:
4141
else:
4242
nameai_report = NameAIReport(
4343
purity_score=0,
44-
interesting_score=0,
44+
sort_score=0,
4545
analysis=None,
4646
)
4747

@@ -67,7 +67,7 @@ def inspect_name(self, name: str) -> NameAIResponse:
6767
nlp_analysis = self.nlp_inspector.nlp_analyse_label(labels[0])
6868
nameai_report = NameAIReport(
6969
purity_score=0,
70-
interesting_score=0,
70+
sort_score=0,
7171
analysis=NLPLabelAnalysis(
7272
inspection=nlp_analysis.inspection,
7373
status=nlp_analysis.status,
@@ -81,7 +81,7 @@ def inspect_name(self, name: str) -> NameAIResponse:
8181
else:
8282
nameai_report = NameAIReport(
8383
purity_score=0,
84-
interesting_score=0,
84+
sort_score=0,
8585
analysis=None,
8686
)
8787

apps/api.nameai.dev/nameai/nameai_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async def inspect_name_get(
124124
125125
For names with multiple labels:
126126
- If the name has 2 labels (e.g., "nick.eth"), the analysis is performed on the first label ("nick").
127-
- For 3 or more labels, only the first label is analyzed, but the NameRank scores (purity and interesting) are set to 0.
127+
- For 3 or more labels, only the first label is analyzed, but the NameRank scores (purity and sort score) are set to 0.
128128
129129
This endpoint does not perform automated labelhash resolution.
130130
@@ -152,7 +152,7 @@ async def inspect_name_post(request: InspectNameRequest) -> NameAIResponse:
152152
153153
For names with multiple labels:
154154
- If the name has 2 labels (e.g., "nick.eth"), the analysis is performed on the first label ("nick").
155-
- For 3 or more labels, only the first label is analyzed, but the NameRank scores (purity and interesting) are set to 0.
155+
- For 3 or more labels, only the first label is analyzed, but the NameRank scores (purity and sort score) are set to 0.
156156
157157
This endpoint does not perform automated labelhash resolution.
158158

apps/api.nameai.dev/nameai/scorer.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ def __init__(self):
1414

1515
def score_label(self, label_analysis: NLPLabelAnalysis) -> Tuple[float, float]:
1616
"""
17-
Calculates the purity_score and interesting_score of the label.
18-
Returns (purity_score, interesting_score).
17+
Calculates the purity_score and sort_score of the label.
18+
Returns (purity_score, sort_score).
1919
"""
2020
purity = None
21-
interesting = None
21+
sort_score = None
2222

2323
if self.label_is_unknown(label_analysis):
2424
# first check namehash because it is detected as not normalized
@@ -49,12 +49,12 @@ def score_label(self, label_analysis: NLPLabelAnalysis) -> Tuple[float, float]:
4949
purity = 11
5050
elif self.word_count(label_analysis) == 0:
5151
purity = 12
52-
# everything above will have purity == interesting
52+
# everything above will have purity == sort_score
5353
elif self.word_count(label_analysis) > 0:
5454
if not label_analysis.probability:
55-
interesting = 13
55+
sort_score = 13
5656
else:
57-
interesting = 13 + min(-1 / label_analysis.log_probability, 1.0)
57+
sort_score = 13 + min(-1 / label_analysis.log_probability, 1.0)
5858

5959
if self.word_count(label_analysis) >= 4:
6060
purity = 13
@@ -68,13 +68,13 @@ def score_label(self, label_analysis: NLPLabelAnalysis) -> Tuple[float, float]:
6868
if purity is not None:
6969
purity += self.short_label_bonus(label_analysis)
7070

71-
if interesting is None:
72-
interesting = purity
71+
if sort_score is None:
72+
sort_score = purity
7373

74-
if purity is None or interesting is None:
74+
if purity is None or sort_score is None:
7575
raise ValueError('error in scorer algorithm')
7676

77-
return purity / 17, interesting / 14
77+
return purity / 17, sort_score / 14
7878

7979
def label_length(self, label_analysis: NLPLabelAnalysis) -> int:
8080
# not using char_length because it is only available in the normalized response model

apps/api.nameai.dev/tests/test_nameai.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def nameai():
1818
def test_normalized(nameai: 'NameAI'):
1919
result = nameai.inspect_label('nick')
2020
assert abs(result.nameai.purity_score - 0.9976234705882353) < 0.0001, result.nameai.purity_score
21-
assert abs(result.nameai.interesting_score - 0.9354685918689098) < 0.0001, result.nameai.interesting_score
21+
assert abs(result.nameai.sort_score - 0.9354685918689098) < 0.0001, result.nameai.sort_score
2222
assert result.nameai.analysis.status == 'normalized'
2323
assert abs(result.nameai.analysis.probability - 0.0000317942695746393) < 0.0001, result.nameai.analysis.probability
2424
assert (
@@ -32,25 +32,25 @@ def test_name(nameai: 'NameAI'):
3232
result = nameai.inspect_name('')
3333
assert result.nameai.analysis.inspection.label == ''
3434
assert result.nameai.purity_score == 0
35-
assert result.nameai.interesting_score == 0
35+
assert result.nameai.sort_score == 0
3636
assert result.nameai.analysis.status == 'normalized'
3737

3838
result = nameai.inspect_name('nick')
3939
assert result.nameai.analysis.inspection.label == 'nick'
4040
assert abs(result.nameai.purity_score - 0.9976234705882353) < 0.0001, result.nameai.purity_score
41-
assert abs(result.nameai.interesting_score - 0.9354685918689098) < 0.0001, result.nameai.interesting_score
41+
assert abs(result.nameai.sort_score - 0.9354685918689098) < 0.0001, result.nameai.sort_score
4242
assert result.nameai.analysis.status == 'normalized'
4343

4444
result = nameai.inspect_name('nick.eth')
4545
assert result.nameai.analysis.inspection.label == 'nick'
4646
assert abs(result.nameai.purity_score - 0.9976234705882353) < 0.0001, result.nameai.purity_score
47-
assert abs(result.nameai.interesting_score - 0.9354685918689098) < 0.0001, result.nameai.interesting_score
47+
assert abs(result.nameai.sort_score - 0.9354685918689098) < 0.0001, result.nameai.sort_score
4848
assert result.nameai.analysis.status == 'normalized'
4949

5050
result = nameai.inspect_name('nick.eth.eth')
5151
assert result.nameai.analysis.inspection.label == 'nick'
5252
assert result.nameai.purity_score == 0
53-
assert result.nameai.interesting_score == 0
53+
assert result.nameai.sort_score == 0
5454
assert result.nameai.analysis.status == 'normalized'
5555

5656

apps/api.nameai.dev/tests/test_nlp_inspector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_inspector_tokenize(nlp_inspector: 'NLPInspector', input, output):
3131
assert tokenized_labels[0]['tokens'] == tuple(output)
3232

3333

34-
def test_inspector_interesting_score_precision(nlp_inspector: 'NLPInspector'):
34+
def test_inspector_sort_score_precision(nlp_inspector: 'NLPInspector'):
3535
lab1 = 'mrscopcake'
3636
lab2 = 'likemrscopcake'
3737
resp1 = nlp_inspector.nlp_analyse_label(lab1)
@@ -47,7 +47,7 @@ def test_inspector_prob_when_word_count_null_0(nlp_inspector: 'NLPInspector'):
4747
assert resp.log_probability < -100000
4848

4949

50-
def test_inspector_interesting_score(nlp_inspector: 'NLPInspector'):
50+
def test_inspector_sort_score(nlp_inspector: 'NLPInspector'):
5151
lab1 = 'ilikeyourcat'
5252
lab2 = 'catlikeiyour'
5353
resp1 = nlp_inspector.nlp_analyse_label(lab1)

apps/nameai.dev/app/sort/client.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ export function Client({ initialLabels }: { initialLabels: LabelItem[] }) {
2020
const result = await nameai.inspectName(label);
2121
const newLabelItem = {
2222
label,
23-
interestingScore: result.nameai.interesting_score,
23+
sortScore: result.nameai.sort_score,
2424
};
2525
setLabels((prevLabels) => {
2626
const updatedLabels = [...prevLabels, newLabelItem];
2727
return updatedLabels.sort(
28-
(a, b) => b.interestingScore - a.interestingScore,
28+
(a, b) => b.sortScore - a.sortScore,
2929
);
3030
});
3131
} else {

apps/nameai.dev/app/sort/list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function SortedList({ labels }: { labels: LabelItem[] }) {
1313
<span className="font-bold">{item.label}</span>
1414
<div className="flex items-center gap-2">
1515
<span className="text-sm text-gray-600">
16-
{item.interestingScore.toFixed(4)}
16+
{item.sortScore.toFixed(4)}
1717
</span>
1818
</div>
1919
</li>

apps/nameai.dev/app/sort/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Client } from "./client";
55

66
export interface LabelItem {
77
label: string;
8-
interestingScore: number;
8+
sortScore: number;
99
}
1010

1111
const defaultLabels = ["vitalik", "ethereum", "web3", "blockchain", "defi"];
@@ -16,12 +16,12 @@ async function getInitialLabelsItems(): Promise<LabelItem[]> {
1616
const result = await nameai.inspectName(label);
1717
return {
1818
label,
19-
interestingScore: result.nameai.interesting_score,
19+
sortScore: result.nameai.sort_score,
2020
};
2121
}),
2222
);
2323

24-
return loadedNames.sort((a, b) => b.interestingScore - a.interestingScore);
24+
return loadedNames.sort((a, b) => b.sortScore - a.sortScore);
2525
}
2626

2727
export default async function SortPage() {

packages/nameai-sdk/src/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe("inspectName", () => {
1515
const data = await nameai.inspectName("vitalìk.eth");
1616

1717
expect(data.nameai.purity_score).toBeCloseTo(0.28995870588235295, 2);
18-
expect(data.nameai.interesting_score).toBeCloseTo(0.3520927142857143, 2);
18+
expect(data.nameai.sort_score).toBeCloseTo(0.3520927142857143, 2);
1919
});
2020
});
2121

@@ -30,7 +30,7 @@ describe("inspectName edge cases", () => {
3030
const longName = "a".repeat(MAX_INSPECTED_NAME_CHARACTERS + 1) + ".eth";
3131
const data = await nameai.inspectName(longName);
3232
expect(data.nameai.purity_score).toBe(0);
33-
expect(data.nameai.interesting_score).toBe(0);
33+
expect(data.nameai.sort_score).toBe(0);
3434
});
3535

3636
it("should handle empty name", async () => {

0 commit comments

Comments
 (0)