Skip to content

Commit

Permalink
Showing name proposals even without manufacturer match. Added Hypethe…
Browse files Browse the repository at this point in the history
…Sonics databases. Renamed U18Tzar as U18t and Linsoul Audio Lokahi as Linsoul Lokahi. Centered 5128 DF targets. Added LMG 5128 target.
  • Loading branch information
jaakkopasanen committed Dec 10, 2023
1 parent be9f08a commit 6c9a097
Show file tree
Hide file tree
Showing 2,077 changed files with 347,015 additions and 19,270 deletions.
29 changes: 20 additions & 9 deletions dbtools/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ def init_name_proposals(self):
self.name_proposals = pd.DataFrame(proposal_data)
self.name_proposals.drop_duplicates(inplace=True)

def get_name_proposals(self, source_name, n=4, normalize_digits=False, normalize_extras=False, threshold=60):
def get_name_proposals(
self, source_name, n=4, normalize_digits=False, normalize_extras=False, threshold=60,
require_manufacturer_match=True
):
"""Prompts manufacturer, model and form from the user
Args:
Expand All @@ -144,6 +147,7 @@ def get_name_proposals(self, source_name, n=4, normalize_digits=False, normalize
normalize_digits: Normalize all digits to zeros before calculating fuzzy string matching score
normalize_extras: Remove extra details in the parentheses
threshold: Score threshold
require_manufacturer_match: Require manufacturer to be found with the given name?
Returns:
NameItem
Expand All @@ -160,16 +164,20 @@ def fuzzy(fn, a, b):
return fn(a, b)

manufacturer, manufacturer_match = self.manufacturers.find(source_name)
if not manufacturer:
if manufacturer:
false_model = self.manufacturers.model(source_name)
# Select only the items with the same manufacturer
models = self.name_proposals[self.name_proposals.manufacturer == manufacturer]
elif require_manufacturer_match:
return NameIndex([])
false_model = self.manufacturers.model(source_name)
# Select only the items with the same manufacturer
models = self.name_proposals[self.name_proposals.manufacturer == manufacturer]
else:
false_model = source_name
models = self.name_proposals.copy()

# Calculate ratios
# Partial ratio to capture the model name (without mods) approximately
partial_ratios = np.array([fuzzy(
fuzz.partial_ratio, re.sub(r' \(.*\)$', '', model), re.sub(r' \(.*\)$', '', false_model)
fuzz.partial_ratio, re.sub(r'(?: \(.*\)$|\s)', '', model), re.sub(r'(?: \(.*\)$|\s)', '', false_model)
) for model in models.model.tolist()])
partial_ratios = np.round(partial_ratios / 2) * 2
# Ratio to fine sort all good model matches
Expand All @@ -181,7 +189,10 @@ def fuzzy(fn, a, b):
models = models[models.partial_ratio >= threshold]
proposals = []
for i, row in models.iterrows():
proposals.append(NameItem(name=f'{manufacturer} {row.model}', form=row.form))
if manufacturer:
proposals.append(NameItem(name=f'{manufacturer} {row.model}', form=row.form))
else:
proposals.append(NameItem(name=f'{row.manufacturer} {row.model}', form=row.form))
ni = NameIndex(items=proposals[:n])
return ni

Expand Down Expand Up @@ -427,11 +438,11 @@ def switch_prompt(self, new_active):
# then rest of the optional properties
self.active_list_item.name_prompt.guessed_name = self.guess_name(self.active_list_item.name_prompt.item)
self.active_list_item.name_prompt.name_proposals = self.get_name_proposals(
self.active_list_item.name_prompt.guessed_name, n=5, threshold=10)
self.active_list_item.name_prompt.guessed_name, n=5, threshold=10, require_manufacturer_match=False)
self.active_list_item.name_prompt.similar_names = [
item.name for item in self.get_name_proposals(
self.active_list_item.name_prompt.guessed_name, n=6, normalize_digits=True,
normalize_extras=True, threshold=0).items]
normalize_extras=True, threshold=0, require_manufacturer_match=False).items]
if self.active_list_item.name_prompt.item.name is not None and self.active_list_item.name_prompt.item.form is not None:
# Prompting can resolve AutoEq name and the headphone form, both got resolved here, no need to prompt
self.prompt_callback(self.active_list_item.name_prompt.item)
Expand Down
55 changes: 32 additions & 23 deletions dbtools/create_webapp_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def write_targets():
{'source': 'freeryder05', 'form': 'in-ear'},
{'source': 'Harpo', 'form': 'in-ear'},
{'source': 'Hi End Portable', 'form': 'in-ear'},
{'source': 'HypetheSonics', 'form': 'in-ear', 'rig': 'GRAS RA0045'},
{'source': 'Jaytiss', 'form': 'in-ear'},
{'source': 'Kazi', 'form': 'in-ear'},
{'source': 'Kazi', 'form': 'earbud'},
Expand All @@ -49,6 +50,7 @@ def write_targets():
{'source': 'freeryder05', 'form': 'in-ear'},
{'source': 'Harpo', 'form': 'in-ear'},
{'source': 'Hi End Portable', 'form': 'in-ear'},
{'source': 'HypetheSonics', 'form': 'in-ear', 'rig': 'GRAS RA0045'},
{'source': 'Jaytiss', 'form': 'in-ear'},
{'source': 'Kazi', 'form': 'in-ear'},
{'source': 'Kazi', 'form': 'earbud'},
Expand All @@ -67,28 +69,20 @@ def write_targets():
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 8}
},
{
'file': TARGETS_PATH.joinpath('Diffuse field 5128 -1dB per octave.csv'),
'label': 'Diffuse Field 5128 (-1 dB/oct)',
'compatible': [{'source': 'crinacle', 'form': 'in-ear', 'rig': 'Bruel & Kjaer 4620'}],
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 0}
'file': TARGETS_PATH.joinpath('crinacle EARS + 711 Harman over-ear 2018 without bass.csv'),
'label': 'crinacle EARS + 711 Harman over-ear 2018',
'compatible': [
{'source': 'crinacle', 'form': 'over-ear', 'rig': 'EARS + 711'},
],
'recommended': [
{'source': 'crinacle', 'form': 'over-ear', 'rig': 'EARS + 711'},
],
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 6}
},
{
'file': TARGETS_PATH.joinpath('JM-1 with Harman treble filter.csv'),
'label': 'JM-1 with Harman filters',
'file': TARGETS_PATH.joinpath('Diffuse field 5128 -1dB per octave.csv'),
'label': 'Diffuse Field 5128 (-1 dB/oct)',
'compatible': [{'source': 'crinacle', 'form': 'in-ear', 'rig': 'Bruel & Kjaer 4620'}],
'recommended': [{'source': 'crinacle', 'form': 'in-ear', 'rig': 'Bruel & Kjaer 4620'}],
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 6.5}
},
{
'file': TARGETS_PATH.joinpath('711 5128 delta.csv'),
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 0}
},
{
'file': TARGETS_PATH.joinpath('Diffuse field GRAS KEMAR.csv'),
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 0}
},
{
'file': TARGETS_PATH.joinpath('Diffuse field ISO 11904-1.csv'),
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 0}
},
{
Expand All @@ -109,6 +103,7 @@ def write_targets():
{'source': 'freeryder05', 'form': 'in-ear'},
{'source': 'Harpo', 'form': 'in-ear'},
{'source': 'Hi End Portable', 'form': 'in-ear'},
{'source': 'HypetheSonics', 'form': 'in-ear', 'rig': 'GRAS RA0045'},
{'source': 'Jaytiss', 'form': 'in-ear'},
{'source': 'Kazi', 'form': 'in-ear'},
{'source': 'Kazi', 'form': 'earbud'},
Expand Down Expand Up @@ -201,13 +196,27 @@ def write_targets():
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 6}
},
{
'file': TARGETS_PATH.joinpath('crinacle EARS + 711 Harman over-ear 2018 without bass.csv'),
'label': 'crinacle EARS + 711 Harman over-ear 2018',
'file': TARGETS_PATH.joinpath('JM-1 with Harman treble filter.csv'),
'label': 'JM-1 with Harman filters',
'compatible': [
{'source': 'crinacle', 'form': 'over-ear', 'rig': 'EARS + 711'},
{'source': 'crinacle', 'form': 'in-ear', 'rig': 'Bruel & Kjaer 4620'},
{'source': 'HypetheSonics', 'form': 'in-ear', 'rig': 'Bruel & Kjaer 4620'},
],
'recommended': [
{'source': 'crinacle', 'form': 'over-ear', 'rig': 'EARS + 711'},
{'source': 'crinacle', 'form': 'in-ear', 'rig': 'Bruel & Kjaer 4620'},
{'source': 'HypetheSonics', 'form': 'in-ear', 'rig': 'Bruel & Kjaer 4620'},
],
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 6.5}
},
{
'file': TARGETS_PATH.joinpath('LMG 5128 0.6 without bass.csv'),
'compatible': [
{'source': 'HypetheSonics', 'form': 'over-ear'},
{'source': 'HypetheSonics', 'form': 'earbud'}
],
'recommended': [
{'source': 'HypetheSonics', 'form': 'over-ear'},
{'source': 'HypetheSonics', 'form': 'earbud'}
],
'bassBoost': {'fc': 105, 'q': 0.7, 'gain': 6}
},
Expand Down
Loading

0 comments on commit 6c9a097

Please sign in to comment.