auto: 2026-09-19 17:57 (ESD_LAPTOP)
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""기계설비 글 속 계산용 수 → 계수 표 줄 (토목 규칙 + 기계설비 규칙)."""
|
||||
"""기계설비 글 속 계산용 수 → 계수 표 줄 (토목 규칙 + 기계설비 규칙).
|
||||
|
||||
주 한 줄 → [(구분, 값, 단위, 딸린 칸)]. 식 값은 값 칸에 식 글자 + 딸린 칸 「값원문」.
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
@@ -8,44 +11,153 @@ from _토목_계수 import clean
|
||||
from _토목_계수 import rows_of as base_rows
|
||||
|
||||
PCT = r"([\d.]+)%"
|
||||
BASE = {"기준": "본 품"}
|
||||
|
||||
|
||||
def pct(name, v, sign, **more):
|
||||
return (name, R(v), "%", {**BASE, "가감": sign, **more})
|
||||
|
||||
|
||||
def formulas(s):
|
||||
out = []
|
||||
m = re.search(r"(보온공 품) = (\([^ ]+\)×V/C)", s)
|
||||
if m:
|
||||
out.append((m.group(1), m.group(2), "", {"값원문": m.group(0)}))
|
||||
m = re.search(r"(특별인부 품) = (보온공 품×[\d.]+)", s)
|
||||
if m:
|
||||
out.append((m.group(1), m.group(2), "", {"값원문": m.group(0)}))
|
||||
m = re.search(r"다음과 같이 계산한다\. (π×Tank직경×\(Tank철판단수-1\))", s)
|
||||
if m:
|
||||
out.append(("원주방향 용접장", m.group(1), "", {"값원문": m.group(1)}))
|
||||
return out
|
||||
|
||||
|
||||
def specific(s):
|
||||
out = []
|
||||
for k, v in re.findall(r"(\d+)(?:㎜)? : ([\d.]+)(?= |$)", s) if "환산기준" in s else []:
|
||||
out.append((f"6㎜ 철판 환산기준 두께 {k}㎜", R(v), "", {}))
|
||||
m = re.search(
|
||||
r"수동용접 : "
|
||||
+ PCT
|
||||
+ r"\(공장가공\), "
|
||||
+ PCT
|
||||
+ r"\(현장가공\) 자동용접 : "
|
||||
+ PCT
|
||||
+ r"\(공장가공\), "
|
||||
+ PCT
|
||||
+ r"\(현장가공\)",
|
||||
s,
|
||||
)
|
||||
if m:
|
||||
for nm, v in zip(
|
||||
("수동용접 공장가공", "수동용접 현장가공", "자동용접 공장가공", "자동용접 현장가공"),
|
||||
m.groups(),
|
||||
):
|
||||
out.append((f"작업효율 {nm}", R(v), "%", {}))
|
||||
m = re.search(
|
||||
r"전체배관 설치중량의 "
|
||||
+ PCT
|
||||
+ r"로 간주하여 배관하는 품으로 "
|
||||
+ PCT
|
||||
+ r" 증감할 때마다 본 품에 "
|
||||
+ PCT
|
||||
+ r"씩 가감",
|
||||
s,
|
||||
)
|
||||
if m:
|
||||
out += [
|
||||
("Fitting류 등 중량 비율", R(m.group(1)), "%", {"기준": "전체배관 설치중량"}),
|
||||
("증감 단위", R(m.group(2)), "%", {"기준": "전체배관 설치중량"}),
|
||||
("증감 단위당 가감", R(m.group(3)), "%", BASE),
|
||||
]
|
||||
m2 = re.search(r"본 품에 " + PCT + r" 범위 내에서 감하여", s)
|
||||
if m2:
|
||||
out.append(pct("공장제작조립 시 감", m2.group(1), "감"))
|
||||
m = re.search(r"옥내배관의 " + PCT + r"가산, 옥외매설관은 옥외배관의 " + PCT + r" 감", s)
|
||||
if m:
|
||||
out += [
|
||||
("기계실배관", R(m.group(1)), "%", {"기준": "옥내배관", "가감": "가산"}),
|
||||
("옥외매설관", R(m.group(2)), "%", {"기준": "옥외배관", "가감": "감"}),
|
||||
]
|
||||
m = re.search(
|
||||
r"조도가 (\d+#)를 기준한 것으로 (\d+#)까지 " + PCT + r", (\d+#)까지 " + PCT + r"를 감", s
|
||||
)
|
||||
if m:
|
||||
out += [
|
||||
("조도 기준", R(m.group(1)[:-1]), "#", {}),
|
||||
(f"조도 {m.group(2)}까지", R(m.group(3)), "%", {**BASE, "가감": "감"}),
|
||||
(f"조도 {m.group(4)}까지", R(m.group(5)), "%", {**BASE, "가감": "감"}),
|
||||
]
|
||||
m = re.search(r"Gas Heating의 경우 개소당 ([\d.]+)인", s)
|
||||
if m:
|
||||
out.append(("Gas Heating 개소당", R(m.group(1)), "인", {}))
|
||||
m = re.search(r"기름소모량은 (\d+)개소당 ([\d.]+)ℓ", s)
|
||||
if m:
|
||||
out.append((f"기름소모량 {m.group(1)}개소당", R(m.group(2)), "ℓ", {}))
|
||||
m = re.search(r"가루비누는 ㎥당 ([\d.]+)㎏", s)
|
||||
if m:
|
||||
out.append(("누설 Check용 가루비누", R(m.group(1)), "㎏/㎥", {}))
|
||||
m = re.search(r"1매를 ([\d.]+)㎡", s)
|
||||
if m:
|
||||
out.append(("3'×6' Sheet 1매", R(m.group(1)), "㎡", {}))
|
||||
m = re.search(r"Pipe길이 1m에 (\d+)회 감는", s)
|
||||
if m:
|
||||
out.append(("철선 Pipe길이 1m당 감는 횟수", R(m.group(1)), "회", {}))
|
||||
m = re.search(r"구멍지름이 (\d+)㎜이하일 때는 철골공 (\d+)인, (\d+)㎜ 이상일 때는 (\d+)인", s)
|
||||
if m:
|
||||
out += [
|
||||
(f"송곳뚫기 구멍지름 {m.group(1)}㎜이하 철골공", R(m.group(2)), "인", {}),
|
||||
(f"송곳뚫기 구멍지름 {m.group(3)}㎜ 이상 철골공", R(m.group(4)), "인", {}),
|
||||
]
|
||||
return out
|
||||
|
||||
|
||||
def clauses(s):
|
||||
"""「… N% 가산」 꼴 절마다 한 줄 — ㉮㉯㉰ 로 갈린 것은 절별."""
|
||||
out = []
|
||||
parts = re.split(r"\s*[㉮-㉳]\s*", s) if re.search(r"[㉮-㉳]", s) else [s]
|
||||
for p in parts:
|
||||
rg = re.search(r"(\d+)∼(\d+)%(?:를|까지| 범위 내에서|씩)? ?(?:을 )?(가산|감|가감|증감)", p)
|
||||
if rg:
|
||||
out.append(
|
||||
(
|
||||
re.sub(r"\s+", " ", p).strip(" ."),
|
||||
[R(rg.group(1)), R(rg.group(2))],
|
||||
"%",
|
||||
{**BASE, "가감": rg.group(3)},
|
||||
)
|
||||
)
|
||||
continue
|
||||
found = re.findall(
|
||||
r"(\d[\d.]*)%(?:를|까지| 범위 내에서|씩)? ?(?:을 )?(가산|감|가감|증감)", p
|
||||
)
|
||||
if not found:
|
||||
continue
|
||||
name = re.sub(r"\s+", " ", p).strip(" .")
|
||||
for v, sign in found[:1]:
|
||||
out.append((name, R(v), "%", {**BASE, "가감": sign}))
|
||||
return out
|
||||
|
||||
|
||||
def rows_of(line):
|
||||
"""주 한 줄 → 계수 줄들 [(구분, 값, 단위, 딸린 칸)]."""
|
||||
s = clean(line)
|
||||
out = base_rows(re.sub(r"(인력품|주재료비|재료비)의\([^)]*\) ", r"\1의 ", line))
|
||||
if out:
|
||||
return out
|
||||
out = formulas(s) + specific(s)
|
||||
if out:
|
||||
return out
|
||||
m = re.search(r"^(.+?)(?:은|는) 본 품에 " + PCT + r"를 (가산|감)", s)
|
||||
if m:
|
||||
return [(m.group(1), R(m.group(2)), "%", {"기준": "본 품", "가감": m.group(3)})]
|
||||
return [pct(m.group(1), m.group(2), m.group(3))]
|
||||
m = re.search(
|
||||
r"(\d+)본 감할 때마다 " + PCT + r"씩 감하고, (\d+)본 증할 때마다 " + PCT + r"씩 가산", s
|
||||
)
|
||||
if m:
|
||||
return [
|
||||
(
|
||||
f"튜브 {m.group(1)}본 감할 때마다",
|
||||
R(m.group(2)),
|
||||
"%",
|
||||
{"기준": "본 품", "가감": "감"},
|
||||
),
|
||||
(
|
||||
f"튜브 {m.group(3)}본 증할 때마다",
|
||||
R(m.group(4)),
|
||||
"%",
|
||||
{"기준": "본 품", "가감": "가산"},
|
||||
),
|
||||
pct(f"튜브 {m.group(1)}본 감할 때마다", m.group(2), "감"),
|
||||
pct(f"튜브 {m.group(3)}본 증할 때마다", m.group(4), "가산"),
|
||||
]
|
||||
m = re.search(r"^(.+? 3절 초과하는 경우 매 1절 증가마다) " + PCT + r"씩 가산", s)
|
||||
if m:
|
||||
return [(m.group(1), R(m.group(2)), "%", {"기준": "본 품", "가감": "가산"})]
|
||||
m = re.search(r"^(.+?(?:증가마다)) " + PCT + r"씩 가산", s)
|
||||
if m:
|
||||
return [(m.group(1), R(m.group(2)), "%", {"기준": "본 품", "가감": "가산"})]
|
||||
m = re.search(r"^(.+?구조일 경우) " + PCT + r" 가산", s)
|
||||
if m:
|
||||
return [(m.group(1), R(m.group(2)), "%", {"기준": "본 품", "가감": "가산"})]
|
||||
m = re.search(
|
||||
r"(높이 6∼9m까지는) 품을 "
|
||||
+ PCT
|
||||
@@ -55,8 +167,8 @@ def rows_of(line):
|
||||
)
|
||||
if m:
|
||||
return [
|
||||
(f"비계 사용 {m.group(1)}", R(m.group(2)), "%", {"기준": "본 품", "가감": "가산"}),
|
||||
(f"비계 사용 {m.group(3)}", R(m.group(4)), "%", {"기준": "본 품", "가감": "가산"}),
|
||||
pct(f"비계 사용 {m.group(1)}", m.group(2), "가산"),
|
||||
pct(f"비계 사용 {m.group(3)}", m.group(4), "가산"),
|
||||
]
|
||||
m = re.search(r"단독주택 (\d+)호당 1조 및 집단아파트 (\d+)호당 1조", s)
|
||||
if m:
|
||||
@@ -64,4 +176,4 @@ def rows_of(line):
|
||||
("단독주택 1조당 호수", R(m.group(1)), "호", {}),
|
||||
("집단아파트 1조당 호수", R(m.group(2)), "호", {}),
|
||||
]
|
||||
return []
|
||||
return clauses(s)
|
||||
|
||||
@@ -3,4 +3,10 @@
|
||||
|
||||
SPEC = {
|
||||
"9-5-1#0": {"L": 3},
|
||||
"13-9-2#0": {"L": 0},
|
||||
# 13-1-2 : 「구분」 「SCH No」 「직종」 은 층 이름(둘째 칸) · 오른쪽 표는 앞 표 오른쪽(구경 칸 없이 윗줄부터)
|
||||
"13-1-2#0": {"pair": True, "L": 2, "LN": 1, "NAMES": {0: "구경(㎜)"}},
|
||||
"13-1-2#2": {"L": 2, "LN": 1, "NAMES": {0: "구경(㎜)"}},
|
||||
# 13-1-1 : PDF 가 넓은 표를 왼쪽 · 오른쪽 둘로 나눠 찍음 — 줄마다 이어 한 표로
|
||||
**{f"13-1-1#{k}": {"pair": True} for k in (0, 2, 4, 6, 8)},
|
||||
}
|
||||
|
||||
@@ -94,8 +94,13 @@ def read_chapter(chdir):
|
||||
mb = BLOCK.match(s)
|
||||
if mb:
|
||||
kind, rest = mb.groups()
|
||||
mode_before = mode
|
||||
mode = "note" if kind in ("주", "계산예", "비고") else ""
|
||||
if kind in ("참고", "참고자료", "별표"):
|
||||
if "참조" in rest and tabs and tabs[-1].ident == ident:
|
||||
mode = mode_before # 딴 곳을 가리키는 글 = 앞 주 이어짐
|
||||
tabs[-1].notes.append(unesc(f"{kind} {rest}"))
|
||||
continue
|
||||
pre = [s] if not rest else [f"[{kind}] {rest}"]
|
||||
mode = ""
|
||||
continue
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
import re
|
||||
|
||||
from _md표_읽기 import N, R, join
|
||||
from _토목_표 import bigo_items, conds_out, is_unit, jn
|
||||
from _토목_표 import bigo_items, conds_out, jn
|
||||
from _토목_표 import is_unit as _is_unit
|
||||
from _토목_읽기 import cell_val, is_num
|
||||
|
||||
MEMBER = re.compile(
|
||||
@@ -24,6 +25,11 @@ VALUEISH = re.compile(r"수량|시공량|소비량|소요|인력|시간|기간|
|
||||
DASH = ("", "-")
|
||||
|
||||
|
||||
def is_unit(p):
|
||||
"""단위 글 — 「인」 「㎏」 「인/ton」 따위."""
|
||||
return bool(p) and all(_is_unit(x) for x in p.split("/"))
|
||||
|
||||
|
||||
def strip_unit(name):
|
||||
"""「배관공(인)」 → (배관공, 인)."""
|
||||
m = re.search(r"\(([^()]{1,8})\)$", name)
|
||||
@@ -79,6 +85,10 @@ def label_cols(rows, H):
|
||||
vs = [r[c] for r in body if r[c] not in DASH]
|
||||
return bool(vs) and sum(not vlike(v) or v == "〃" for v in vs) * 2 >= len(vs)
|
||||
|
||||
def numeric(c):
|
||||
vs = [r[c] for r in body if r[c] not in DASH]
|
||||
return bool(vs) and sum(vlike(v) and v != "〃" for v in vs) * 2 > len(vs)
|
||||
|
||||
L = 1
|
||||
while L < ncol - 1:
|
||||
c, top = L, jn(rows[0][L])
|
||||
@@ -91,7 +101,7 @@ def label_cols(rows, H):
|
||||
else:
|
||||
ok = textual(c) or bool(LABELNAME.match(top) and not VALUEISH.search(top))
|
||||
ok = ok and not (top in ("수량",) or MEASURE.match(top))
|
||||
ok = ok and any(not textual(k) for k in range(c + 1, ncol))
|
||||
ok = ok and any(numeric(k) for k in range(c + 1, ncol))
|
||||
if not ok:
|
||||
break
|
||||
L += 1
|
||||
@@ -102,13 +112,16 @@ def layers(rows, H, start, ncol):
|
||||
"""머리 층 H 줄 → [층][열] 글(빈 칸은 같은 윗 무리 안에서 왼쪽 값으로 채움)."""
|
||||
out = []
|
||||
for r in range(H):
|
||||
row = [jn(x) for x in rows[r]]
|
||||
row = [re.sub(r"^([^\s/]+)\s*/\s*([^\s/]+)$", r"\1/\2", jn(x)) for x in rows[r]]
|
||||
for c in range(start if r == 0 else start + 1, ncol):
|
||||
if row[c] or c == 0:
|
||||
continue
|
||||
same = all(out[q][c] == out[q][c - 1] for q in range(r))
|
||||
if row[c - 1] and same and (r == 0 or out[r - 1][c]):
|
||||
row[c] = row[c - 1]
|
||||
for c in range(1, ncol): # 「〃」 「"」 머리 = 왼쪽과 같음
|
||||
if row[c] in ("〃", '"', "”"):
|
||||
row[c] = row[c - 1]
|
||||
out.append(row)
|
||||
return out
|
||||
|
||||
@@ -131,6 +144,20 @@ def convert(t, spec=None):
|
||||
"""표 → (조건 사전, 값칸 사전, 줄 목록)."""
|
||||
spec = spec or {}
|
||||
rows, H = [list(r) for r in t.rows], spec.get("H", t.hdr)
|
||||
if ( # 둘째 머리 단이 몸 첫 줄로 찍힌 표(앞 칸이 비고 나머지가 머리 글)
|
||||
H == 1
|
||||
and "H" not in spec
|
||||
and len(rows) > 2
|
||||
and rows[1][0] == ""
|
||||
and sum(x != "" for x in rows[1]) >= 2
|
||||
and not any(is_member(x) for x in rows[1])
|
||||
or H == 1
|
||||
and "H" not in spec
|
||||
and len(rows) > 2
|
||||
and rows[1][0] in ("직종", "공종")
|
||||
and any(is_member(x) for x in rows[1][1:])
|
||||
):
|
||||
H = 2
|
||||
rows = halves(rows, H)
|
||||
ncol = max(len(r) for r in rows)
|
||||
rows = [r + [""] * (ncol - len(r)) for r in rows]
|
||||
@@ -140,7 +167,7 @@ def convert(t, spec=None):
|
||||
bigo += bigo_items(" ".join(x for x in r[1:] if x))
|
||||
rows = rows[:H] + [r for r in rows[H:] if jn(r[0]) != "비고"]
|
||||
body = rows[H:]
|
||||
L = spec.get("L") or label_cols(rows, H)
|
||||
L = spec["L"] if "L" in spec else label_cols(rows, H)
|
||||
unitc = next(
|
||||
(c for c in range(L) if jn(rows[H - 1][c]) == "단위" or jn(rows[0][c]) == "단위"), None
|
||||
)
|
||||
@@ -151,6 +178,7 @@ def convert(t, spec=None):
|
||||
c
|
||||
for c in range(1, L)
|
||||
if sum(r[c] == "〃" for r in body) * 2 >= max(len(body) - 1, 1)
|
||||
and not any(is_num(r[c]) for r in body)
|
||||
),
|
||||
None,
|
||||
)
|
||||
@@ -166,6 +194,7 @@ def convert(t, spec=None):
|
||||
names[c] = (
|
||||
f"{top}({low})" if low and is_unit(low) else (low if c == 0 and low and H > 1 else top)
|
||||
) or "구분"
|
||||
names.update(spec.get("NAMES", {}))
|
||||
if lab_unit is not None and any(
|
||||
measure_hm([jn(rows[r][c]) for c in range(L, ncol)]) for r in range(H)
|
||||
):
|
||||
@@ -177,7 +206,12 @@ def convert(t, spec=None):
|
||||
mc = spec.get("M", None)
|
||||
head_members = any(measure_hm([jn(rows[r][c]) for c in range(L, ncol)]) for r in range(H))
|
||||
if mc is None and unitc is not None and not head_members:
|
||||
mc = max(c for c in txt if c < unitc) if any(c < unitc for c in txt) else None
|
||||
cand = [c for c in txt if c < unitc]
|
||||
for c in reversed(cand): # 직종 칸 = 값 대부분이 직종 이름인 라벨 칸
|
||||
vs = [r[c] for r in body if r[c] not in DASH]
|
||||
if vs and sum(is_member(v) for v in vs) * 2 >= len(vs):
|
||||
mc = c
|
||||
break
|
||||
if mc is None and txt:
|
||||
last = txt[-1]
|
||||
vs = [r[last] for r in body if r[last] not in DASH]
|
||||
@@ -206,7 +240,9 @@ def convert(t, spec=None):
|
||||
named = H > 1 and all(corner) and len(set(corner)) == H
|
||||
if named:
|
||||
names[0] = corner[-1]
|
||||
lnames = [corner[r] if named else "" for r in range(H)]
|
||||
lnames = [corner[r] if named and r < H - 1 else "" for r in range(H)]
|
||||
if "LN" in spec: # 라벨 칸 옆 칸에 층 이름이 적힌 표
|
||||
lnames = [jn(rows[r][spec["LN"]]) if r < H - 1 else "" for r in range(H)]
|
||||
if tposed:
|
||||
lnames = [names[0]]
|
||||
mlay, ulay = None, set()
|
||||
@@ -237,19 +273,25 @@ def convert(t, spec=None):
|
||||
}
|
||||
dropped = ulay | only | ({mlay} if mlay is not None else set())
|
||||
clay = [r for r in range(H) if r not in dropped]
|
||||
# 값 열 전체가 한 무리 이름 아래(첫 층이 하나뿐) — 그 이름이 조건 이름
|
||||
top0 = {lay[clay[0]][c] for c in vcols if lay[clay[0]][c]} if clay else set()
|
||||
gtitle = next(iter(top0)) if len(top0) == 1 and len(clay) > 1 and not lnames[clay[0]] else ""
|
||||
# 몸 줄 읽기
|
||||
recs, prev, prevu = [], {}, ""
|
||||
recs, prev, prevu, sect = [], {}, "", ""
|
||||
for r in body:
|
||||
lab = {}
|
||||
for c in range(L):
|
||||
if c == unitc or c == mc:
|
||||
continue
|
||||
x = jn(r[c])
|
||||
if x in ("", "〃") and not any(r[q] for q in range(c)):
|
||||
if x == "〃" or (x == "" and not any(r[q] for q in range(c))):
|
||||
x = prev.get(c, "")
|
||||
lab[c] = x
|
||||
prev.update(lab)
|
||||
if not any(x for x in lab.values()) and not any(r[c] for c in range(L)):
|
||||
if L and not any(x for x in lab.values()) and not any(r[c] for c in range(L)):
|
||||
continue
|
||||
if r[0] and not any(x for x in r[1:]): # 첫 칸만 있는 줄 = 뒤 줄들의 소제목
|
||||
sect = jn(r[0])
|
||||
continue
|
||||
unit = ""
|
||||
if unitc is not None:
|
||||
@@ -262,26 +304,38 @@ def convert(t, spec=None):
|
||||
v = r[c].strip()
|
||||
if v in DASH:
|
||||
continue
|
||||
u2, meas = unit, "수량"
|
||||
u2, meas, skip = unit, "수량", None
|
||||
if mlay is not None:
|
||||
meas, uu = strip_unit(nm(lay[mlay][c]))
|
||||
u2 = u2 or uu
|
||||
if not meas: # 이름 없는 값 칸 — 위 층의 단위 글(「인/ton」)을 단위로
|
||||
meas = "수량"
|
||||
skip = next((q for q in range(mlay - 1, -1, -1) if lay[q][c]), None)
|
||||
if skip is not None and is_unit(lay[skip][c]):
|
||||
u2 = u2 or lay[skip][c]
|
||||
else:
|
||||
skip = None
|
||||
if member:
|
||||
meas = member
|
||||
for q in ulay:
|
||||
u2 = u2 or lay[q][c]
|
||||
cond = {}
|
||||
cond = {"구분": sect} if sect else {}
|
||||
for c0 in range(L):
|
||||
if c0 in lab and lab[c0]:
|
||||
cond[names[c0]] = lab[c0]
|
||||
path = [lay[q][c] for q in clay if lay[q][c]]
|
||||
path = [lay[q][c] for q in clay if lay[q][c] and q != skip]
|
||||
un = [q for q in clay if lnames[q] and lay[q][c]]
|
||||
if un:
|
||||
for q in un:
|
||||
cond[lnames[q]] = lay[q][c]
|
||||
path = [lay[q][c] for q in clay if lay[q][c] and not lnames[q]]
|
||||
path = [lay[q][c] for q in clay if lay[q][c] and not lnames[q] and q != skip]
|
||||
if path:
|
||||
cond["구분" if "구분" not in cond else "세구분"] = " ".join(dict.fromkeys(path))
|
||||
gname = gtitle if (gtitle and path[0] == gtitle) else ""
|
||||
if gname:
|
||||
path = path[1:]
|
||||
if path:
|
||||
key = gname or ("구분" if "구분" not in cond else "세구분")
|
||||
cond[key] = " ".join(dict.fromkeys(path))
|
||||
recs.append((cond, meas, v, u2))
|
||||
made += 1
|
||||
if not made and mc is not None and member and not is_member(member):
|
||||
@@ -297,7 +351,7 @@ def pack(recs, spec, t):
|
||||
for cond, meas, v, u in recs:
|
||||
key = tuple(cond.items())
|
||||
g = groups.setdefault(key, {})
|
||||
if meas in g:
|
||||
if meas in g or re.search(r"\d", meas):
|
||||
multi = True
|
||||
g[meas] = (v, u)
|
||||
if unit_of.setdefault(meas, u) != u:
|
||||
@@ -318,7 +372,8 @@ def pack(recs, spec, t):
|
||||
else: # 값 이름이 조건으로 — 값은 「수량」 하나 · 줄마다 단위
|
||||
for cond, meas, v, u in recs:
|
||||
d = dict(cond)
|
||||
d["항목"] = meas
|
||||
if any(m != "수량" for _, m, _, _ in recs):
|
||||
d["항목"] = meas
|
||||
val, orig = cv(v)
|
||||
d["수량"] = val
|
||||
if orig:
|
||||
|
||||
@@ -71,7 +71,8 @@ def lift(chdir, text, out, rows_fn=rows_of):
|
||||
rs = rows_fn(line)
|
||||
if not rs:
|
||||
continue
|
||||
tag = "비고" if line.startswith("비고") else "주" + re.match(r"[①-⑳]", line).group(0)
|
||||
mt = re.match(r"[①-⑳]", line)
|
||||
tag = "비고" if line.startswith("비고") else "주" + (mt.group(0) if mt else "")
|
||||
tags.setdefault(tag, []).extend(rs)
|
||||
for tag, rs in tags.items():
|
||||
cols, rows = {"값": "구분 따름", "단위": "글"}, []
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
돌리기: ./venv/Scripts/python.exe resources/master_data/scripts/build_소요량_건설품셈_기계설비.py [7 8 …]
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
import _토목_읽기 as base
|
||||
@@ -18,26 +19,32 @@ from _토목_읽기 import ROOT, Out
|
||||
base.DIV = DIV # 출처 앞말 「건설품셈 기계설비 」
|
||||
|
||||
|
||||
def label_of(t, count):
|
||||
def label_of(t):
|
||||
"""표 이름 = 항 제목 + 목 + 표 앞 짧은 글([참고] 따위 머리표 뒤 글 포함)."""
|
||||
n = f"{t.title} {t.mok}" if t.mok else t.title
|
||||
extra = " ".join(x for x in t.pre if not x.startswith("[별표]"))
|
||||
kinds = [p for p in t.pre if p.startswith("[")]
|
||||
if kinds:
|
||||
n += (
|
||||
" " + kinds[0].strip("[]").split("] ")[-1]
|
||||
if "]" in kinds[0] and not kinds[0].endswith("]")
|
||||
else ""
|
||||
)
|
||||
for p in t.pre:
|
||||
p = re.sub(r"^\[[^\]]+\]\s*", "", p).strip()
|
||||
if p and len(p) <= 24 and "참조" not in p:
|
||||
n += " " + p
|
||||
return n
|
||||
|
||||
|
||||
def build(ch, out_name):
|
||||
tabs = read_chapter(f"제{ch:02d}")
|
||||
out, seen = Out(), {}
|
||||
for t in tabs:
|
||||
skip = set()
|
||||
for i, t in enumerate(tabs):
|
||||
key = f"{t.ident}#{t.k}"
|
||||
if id(t) in skip:
|
||||
continue
|
||||
if SPEC.get(key, {}).get("pair"): # 왼쪽 표 + 오른쪽 표 = 한 표(줄마다 이어 붙임)
|
||||
r = tabs[i + 1]
|
||||
assert len(t.rows) >= len(r.rows) and t.hdr == r.hdr, key
|
||||
pad = [[""] * len(r.rows[0])] * (len(t.rows) - len(r.rows))
|
||||
t.rows = [a + b for a, b in zip(t.rows, r.rows + pad)]
|
||||
skip.add(id(r))
|
||||
cond, cols, rows, bigo = convert(t, SPEC.get(key))
|
||||
lab = label_of(t, None)
|
||||
lab = label_of(t)
|
||||
seen[(t.ident, lab)] = seen.get((t.ident, lab), 0) + 1
|
||||
if seen[(t.ident, lab)] > 1:
|
||||
lab += f" 표{seen[(t.ident, lab)]}"
|
||||
|
||||
Reference in New Issue
Block a user