Commit e4ffdf6c authored by Lauri Himanen's avatar Lauri Himanen Committed by Markus Scheidgen
Browse files

Resolve "Failed publish due to missing suggestion value?"

parent 147cedac
......@@ -132,14 +132,7 @@ def variants_formula(value):
return list(set(formulas))
_tokenizer_formula = get_tokenizer(r'[A-Z][a-z]?\d*')
# Tokenizes a formula by splitting it by formula fragments.
def tokenizer_formula(value):
return [
item if item != '' else 'empty'
for item in _tokenizer_formula(value)]
tokenizer_formula = get_tokenizer(r'[A-Z][a-z]?\d*')
class BandGap(MSection):
......
......@@ -530,17 +530,19 @@ def get_tokenizer(regex):
regular epression.
'''
def tokenizer(value):
tokens = [value]
for match in re.finditer(regex, value):
if (match):
token = value[match.end():]
if token != '':
# Notice how we artificially extend the token by taking the
# prefix and adding it at the end. This way the token
# remains unique so that it will be returned by
# ElasticSearch when "skip_duplicates" is used in the
# query.
tokens.append(f'{token} {value[:match.end()]}')
tokens = []
if value:
tokens.append(value)
for match in re.finditer(regex, value):
if (match):
token = value[match.end():]
if token != '':
# Notice how we artificially extend the token by taking the
# prefix and adding it at the end. This way the token
# remains unique so that it will be returned by
# ElasticSearch when "skip_duplicates" is used in the
# query.
tokens.append(f'{token} {value[:match.end()]}')
return tokens
return tokenizer
......
......@@ -168,9 +168,10 @@ class ResultsNormalizer(Normalizer):
atoms = ase.Atoms(''.join(material.elements))
formula = atoms.get_chemical_formula()
results.material.chemical_formula_hill = atomutils.get_formula_hill(formula)
results.material.chemical_formula_descriptive = results.material.chemical_formula_hill
results.material.chemical_formula_reduced = atoms.get_chemical_formula(mode='reduce')
if formula:
results.material.chemical_formula_hill = atomutils.get_formula_hill(formula)
results.material.chemical_formula_descriptive = results.material.chemical_formula_hill
results.material.chemical_formula_reduced = atoms.get_chemical_formula(mode='reduce')
except Exception as e:
logger.warn('could not normalize material', exc_info=e)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment