SeaWolf-AI commited on
Commit
e62ec67
ยท
verified ยท
1 Parent(s): 1e3b28a

Classify reference materials into their own division

Browse files

Reference rows carry a formula string but no composition dictionary, so they all fell into other and never appeared beside the submissions they are meant to calibrate. The formula is now parsed with pymatgen, which handles bracketed notation that a regular expression gets wrong.

Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -317,10 +317,27 @@ def _anchors(season):
317
  "tier": a.get("tier", 1),
318
  "axes": {k: v["points"] for k, v in (a.get("axes") or {}).items()},
319
  "detail": {k: v["detail"] for k, v in (a.get("axes") or {}).items()},
 
320
  "note": a.get("note", "")})
321
  return out
322
 
323
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  # ์Œ์ด์˜จ ๊ณจ๊ฒฉ์ด ๋ฌผ์งˆ์˜ ์„ฑ์งˆ์„ ํฌ๊ฒŒ ๊ฐ€๋ฅธ๋‹ค. ๊ฐ™์€ ๊ณ„์—ด๋ผ๋ฆฌ ๊ฒฌ์ฃผ์–ด์•ผ ํ›„๋ณด์˜ ์œ„์น˜๊ฐ€ ์ฝํžŒ๋‹ค.
325
  # ๋ถ€๋ฌธ์„ ๋‚˜๋ˆ„๋˜ **์ ์ˆ˜๋Š” ๊ทธ๋Œ€๋กœ ๋‘”๋‹ค** - ์–ด๋–ค ์ œ์ถœ๋„ ๋ฌดํšจ๊ฐ€ ๋˜์ง€ ์•Š๋Š”๋‹ค.
326
  _ANION_ORDER = ["F", "Cl", "Br", "I", "S", "Se", "O", "N", "P", "H"]
 
317
  "tier": a.get("tier", 1),
318
  "axes": {k: v["points"] for k, v in (a.get("axes") or {}).items()},
319
  "detail": {k: v["detail"] for k, v in (a.get("axes") or {}).items()},
320
+ "division": _division_from_formula(a.get("formula", "")),
321
  "note": a.get("note", "")})
322
  return out
323
 
324
 
325
+ def _division_from_formula(f):
326
+ """๊ธฐ์ค€๋ฌผ์งˆ์—๋Š” ์กฐ์„ฑ ์‚ฌ์ „์ด ์—†๊ณ  ํ™”ํ•™์‹ ๋ฌธ์ž์—ด๋งŒ ์žˆ๋‹ค.
327
+
328
+ ์ง์ ‘ ํŒŒ์‹ฑํ•˜์ง€ ์•Š๋Š”๋‹ค - Li10Ge(PS6)2 ๊ฐ™์€ ๊ด„ํ˜ธ ํ‘œ๊ธฐ์—์„œ ์ˆœ์ง„ํ•œ ์ •๊ทœ์‹์€ P1S6 ์„
329
+ ๋‚ด๋†“๋Š”๋‹ค. ๊ทธ๋Ÿฌ๋ฉด ์ด ๋ฌผ์งˆ์ด ํ™ฉํ™”๋ฌผ์ด ์•„๋‹Œ ๊ฒƒ์œผ๋กœ ๋ถ„๋ฅ˜๋œ๋‹ค.
330
+ """
331
+ if not f:
332
+ return "other"
333
+ try:
334
+ from pymatgen.core import Composition
335
+ return division_of({str(el): n for el, n
336
+ in Composition(f).get_el_amt_dict().items()})
337
+ except Exception:
338
+ return "other"
339
+
340
+
341
  # ์Œ์ด์˜จ ๊ณจ๊ฒฉ์ด ๋ฌผ์งˆ์˜ ์„ฑ์งˆ์„ ํฌ๊ฒŒ ๊ฐ€๋ฅธ๋‹ค. ๊ฐ™์€ ๊ณ„์—ด๋ผ๋ฆฌ ๊ฒฌ์ฃผ์–ด์•ผ ํ›„๋ณด์˜ ์œ„์น˜๊ฐ€ ์ฝํžŒ๋‹ค.
342
  # ๋ถ€๋ฌธ์„ ๋‚˜๋ˆ„๋˜ **์ ์ˆ˜๋Š” ๊ทธ๋Œ€๋กœ ๋‘”๋‹ค** - ์–ด๋–ค ์ œ์ถœ๋„ ๋ฌดํšจ๊ฐ€ ๋˜์ง€ ์•Š๋Š”๋‹ค.
343
  _ANION_ORDER = ["F", "Cl", "Br", "I", "S", "Se", "O", "N", "P", "H"]