Remove dashes when matching words

main
Bob Mottram 2021-08-06 17:52:12 +01:00
parent 7d7da68931
commit 8b3f2ce0d4
3 changed files with 12 additions and 2 deletions

View File

@ -434,11 +434,11 @@
{
"@value": "Sari",
"@language": "de"
}
},
{
"@value": "Sari",
"@language": "es"
}
},
{
"@value": "Sari",
"@language": "en"

View File

@ -57,12 +57,16 @@ def _loadDfcIds(baseDir: str, systemLanguage: str,
baseDir + '/ontology/' + productType + 'Types.json'
productTypes = loadJson(productTypesFilename)
if not productTypes:
print('Unable to load ontology: ' + productTypesFilename)
return None
if not productTypes.get('@graph'):
print('No @graph list within ontology')
return None
if len(productTypes['@graph']) == 0:
print('@graph list has no contents')
return None
if not productTypes['@graph'][0].get('rdfs:label'):
print('@graph list entry has no rdfs:label')
return None
languageExists = False
for label in productTypes['@graph'][0]['rdfs:label']:
@ -211,6 +215,7 @@ def _getshareDfcId(baseDir: str, systemLanguage: str,
# bag of words match
maxMatchedWords = 0
for name, uri in dfcIds.items():
name = name.replace('-', ' ')
words = name.split(' ')
score = 0
for wrd in words:

View File

@ -1490,6 +1490,10 @@ def testSharedItemsFederation():
bobDir + '/ontology/toolTypes.json')
copyfile(baseDir + '/ontology/clothesTypes.json',
bobDir + '/ontology/clothesTypes.json')
assert os.path.isfile(bobDir + '/logo.png')
assert os.path.isfile(bobDir + '/ontology/foodTypes.json')
assert os.path.isfile(bobDir + '/ontology/toolTypes.json')
assert os.path.isfile(bobDir + '/ontology/clothesTypes.json')
sessionBob = createSession(proxyType)
sharedItemName = 'cheddar'
sharedItemDescription = 'Some cheese'
@ -1573,6 +1577,7 @@ def testSharedItemsFederation():
assert len(sharesJson.items()) == 3
for itemID, item in sharesJson.items():
if not item.get('dfcId'):
pprint(item)
print(itemID + ' does not have dfcId field')
assert item.get('dfcId')