| name | cwicr-multilingual |
| description | Work with CWICR database across 26 languages. Cross-language matching, translation, and regional pricing. |
| homepage | https://datadrivenconstruction.io |
| metadata | {"openclaw":{"emoji":"🗄️","os":["darwin","linux","win32"],"homepage":"https://datadrivenconstruction.io","requires":{"bins":["python3"]}}} |
CWICR Multilingual Support
Overview
CWICR database supports 26 languages with consistent work item codes. This skill enables cross-language work item matching, translation, and regional price comparison.
Supported Languages
| Code | Language | Region | Currency |
|---|
| AR | Arabic | Dubai | AED |
| DE | German | Berlin | EUR |
| EN | English | Toronto | CAD |
| ES | Spanish | Barcelona | EUR |
| FR | French | Paris | EUR |
| HI | Hindi | Mumbai | INR |
| PT | Portuguese | São Paulo | BRL |
| RU | Russian | St. Petersburg | RUB |
| ZH | Chinese | Shanghai | CNY |
Python Implementation
import pandas as pd
from typing import Dict, Any, List, Optional, Tuple
from dataclasses import dataclass
from enum import Enum
class CWICRLanguage(Enum):
"""Supported CWICR languages."""
ARABIC = ("ar", "Arabic", "AED", "Dubai")
GERMAN = ("de", "German", "EUR", "Berlin")
ENGLISH = ("en", "English", "CAD", "Toronto")
SPANISH = ("es", "Spanish", "EUR", "Barcelona")
FRENCH = ("fr", "French", "EUR", "Paris")
HINDI = ("hi", "Hindi", "INR", "Mumbai")
PORTUGUESE = ("pt", "Portuguese", "BRL", "São Paulo")
RUSSIAN = ("ru", "Russian", "RUB", "St. Petersburg")
CHINESE = ("zh", "Chinese", "CNY", "Shanghai")
() -> :
.value[]
() -> :
.value[]
() -> :
.value[]
() -> :
.value[]
:
work_item_code:
translations: [, ]
prices: [, ]
unit:
:
EXCHANGE_RATES = {
: ,
: ,
: ,
: ,
: ,
: ,
: ,
:
}
():
.databases = databases {}
._index_databases()
():
.indexes = {}
lang, df .databases.items():
df.columns:
.indexes[lang] = df.set_index()
():
file_path.endswith():
df = pd.read_parquet(file_path)
file_path.endswith():
df = pd.read_excel(file_path)
file_path.endswith():
df = pd.read_csv(file_path)
:
ValueError()
.databases[language.code] = df
df.columns:
.indexes[language.code] = df.set_index()
() -> MultilingualWorkItem:
translations = {}
prices = {}
unit =
lang, index .indexes.items():
work_item_code index.index:
row = index.loc[work_item_code]
translations[lang] = (row.get(, ))
prices[lang] = (row.get(, ))
unit:
unit = (row.get(, ))
MultilingualWorkItem(
work_item_code=work_item_code,
translations=translations,
prices=prices,
unit=unit
)
() -> []:
to_lang .indexes:
work_item_code .indexes[to_lang].index:
(.indexes[to_lang].loc[work_item_code].get(, ))
() -> [, ]:
prices = {}
lang, index .indexes.items():
work_item_code index.index:
price = (index.loc[work_item_code].get(, ))
normalize_to_usd:
currency = ._get_currency(lang)
rate = .EXCHANGE_RATES.get(currency, )
price = price * rate
prices[lang] = (price, )
prices
() -> :
lang CWICRLanguage:
lang.code == lang_code:
lang.currency
() -> [, ]:
prices = .compare_prices(work_item_code, normalize_to_usd=)
prices:
(, )
cheapest = (prices.items(), key= x: x[])
cheapest
() -> [, ]:
prices = .compare_prices(work_item_code, normalize_to_usd=)
prices:
(, )
expensive = (prices.items(), key= x: x[])
expensive
() -> [, []]:
source_lang .databases:
{}
source_df = .databases[source_lang]
matches = source_df[
source_df[]..contains(query, =, na=)
][].tolist()
results = {}
code matches[:]:
item = .get_item_translations(code)
results[code] = item.translations
results
() -> pd.DataFrame:
rows = []
code work_item_codes:
item = .get_item_translations(code)
prices_usd = .compare_prices(code, normalize_to_usd=)
row = {
: code,
: item.translations.get(, (item.translations.values())[] item.translations ),
: item.unit
}
lang, price prices_usd.items():
row[] = price
prices_usd:
row[] = (prices_usd.values())
row[] = (prices_usd.values())
row[] = row[] - row[]
rows.append(row)
pd.DataFrame(rows)
:
KEYWORDS = {
: [, , , , , , ],
: [, , , , , , ],
: [, , , , , , ],
: [, , , , , , ],
: [, , , , , , ],
: [, , , , , , ],
: [, , , , , , ],
: [, , , , , , ],
: [, , , , , , ]
}
() -> :
text_lower = text.lower()
scores = {}
lang, keywords LanguageDetector.KEYWORDS.items():
score = ( kw keywords kw text_lower)
score > :
scores[lang] = score
scores:
(scores.items(), key= x: x[])[]
Quick Start
multi = CWICRMultilingual()
multi.load_database(CWICRLanguage.ENGLISH, "cwicr_en.parquet")
multi.load_database(CWICRLanguage.GERMAN, "cwicr_de.parquet")
multi.load_database(CWICRLanguage.SPANISH, "cwicr_es.parquet")
item = multi.get_item_translations("CONC-001")
print(f"EN: {item.translations.get('en')}")
print(f"DE: {item.translations.get('de')}")
Price Comparison
prices = multi.compare_prices("CONC-001", normalize_to_usd=True)
print(prices)
region, price = multi.find_cheapest_region("CONC-001")
print(f"Cheapest: {region} at ${price}")
Resources
- DDC Book: Chapter 2.2 - Open Data Integration
- CWICR Database: 26 languages, 8 national bases + 30 markets