Upload saju_pillars.js with huggingface_hub
Browse files- saju_pillars.js +97 -0
saju_pillars.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/**
|
| 2 |
+
* Saju 4.0: Core Astrological Pillars Engine (JavaScript Port)
|
| 3 |
+
* This library duplicates the Python Saju logic for 100% Client-Side execution.
|
| 4 |
+
*/
|
| 5 |
+
|
| 6 |
+
const STEMS = ["甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"];
|
| 7 |
+
const BRANCHES = ["子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"];
|
| 8 |
+
|
| 9 |
+
const SAJU_DESCRIPTIONS = {
|
| 10 |
+
"甲": "Yang Wood Element: executive leadership, CEO, managing director, political pioneer, independent entrepreneur, authoritative figure.",
|
| 11 |
+
"乙": "Yin Wood Element: diplomat, negotiator, counselor, therapist, public relations, networking, educator, social worker.",
|
| 12 |
+
"丙": "Yang Fire Element: charismatic speaker, television presenter, actor, motivational speaker, marketing manager, public sales, public figure.",
|
| 13 |
+
"丁": "Yin Fire Element: precise detail-oriented, researcher, data analyst, software engineer, academic scholar, scientific inspector.",
|
| 14 |
+
"戊": "Yang Earth Element: solid reliable, real estate, construction, banker, wealth management, traditional conservator, agriculture magnate.",
|
| 15 |
+
"己": "Yin Earth Element: nurturing services, human resources, nursing care, hospitality, customer service, administrator, productive organizer.",
|
| 16 |
+
"庚": "Yang Metal Element: justice enforcer, military officer, litigation lawyer, judge, surgeon, martial arts, security, police executive.",
|
| 17 |
+
"辛": "Yin Metal Element: elegant luxury, jewelry design, high fashion, fine arts, aesthetic precision, literary critic, plastic surgeon, brilliant singer.",
|
| 18 |
+
"壬": "Yang Water Element: dynamic international trade, logistics, global traveler, international diplomat, strategist, global CEO, maritime business.",
|
| 19 |
+
"癸": "Yin Water Element: intuitive psychologist, occultist, profound deep writer, silent strategy, undercover analyst, philosophical wise private investigator.",
|
| 20 |
+
"子": "Rat: astute ambitious, business intelligence, finance accounting, analytical observer, strategic sociability.",
|
| 21 |
+
"丑": "Ox: hardworking methodical, manufacturing, systematic operations, reliable rigorous execution, routine manager.",
|
| 22 |
+
"寅": "Tiger: brave competitive, risk-taking entrepreneur, venture capitalist, competitive sports, disruptive impulse creator.",
|
| 23 |
+
"卯": "Rabbit: peaceful literary, design fine arts, soft diplomacy, sensitive therapist, evasive pacifist aesthetics.",
|
| 24 |
+
"辰": "Dragon: proud visionary, technology dreamer, eccentric leadership, radical innovation, tech entrepreneur, bold inventor.",
|
| 25 |
+
"巳": "Snake: philosophical enigmatic, occult psychology, complex market analysis, political strategy, calculating wisdom.",
|
| 26 |
+
"午": "Horse: adventurous traveling sales, foreign relations, journalism, independent franchises, assertive frankness explorer.",
|
| 27 |
+
"未": "Goat: creative healer, medical doctor, alternative medicine, empathetic design, social caregiver, holistic ecology artisan.",
|
| 28 |
+
"申": "Monkey: resourceful agile programmer, software engineering, ethical hacking, comedian, fun inventive opportunistic seeker.",
|
| 29 |
+
"酉": "Rooster: perfectionist auditing, quality control, text editing writing, forensic analysis, critical eloquence.",
|
| 30 |
+
"戌": "Dog: loyal honest, civil protection, civil rights advocacy, activist, bodyguard, institutional loyalty anxious welfare.",
|
| 31 |
+
"亥": "Pig: generous tolerant, food industry, leisure hospitality luxury, philanthropy donations, sensual peaceful enjoyment."
|
| 32 |
+
};
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* Calculates the 4 Saju Pillars for a given date.
|
| 36 |
+
* @param {Date} date - The birth date object.
|
| 37 |
+
* @returns {Object} { baseTexts, timeTexts, rawBase, rawTime }
|
| 38 |
+
*/
|
| 39 |
+
function getSajuPillars(date) {
|
| 40 |
+
const year = date.getFullYear();
|
| 41 |
+
const month = date.getMonth() + 1;
|
| 42 |
+
const day = date.getDate();
|
| 43 |
+
|
| 44 |
+
// 1. Year Pillar
|
| 45 |
+
const yearStemIdx = (year - 4) % 10;
|
| 46 |
+
const yearBranchIdx = (year - 4) % 12;
|
| 47 |
+
const yearPillar = STEMS[yearStemIdx] + BRANCHES[yearBranchIdx];
|
| 48 |
+
|
| 49 |
+
// 2. Month Pillar
|
| 50 |
+
let calcMonth = month;
|
| 51 |
+
if (month < 2) calcMonth += 12;
|
| 52 |
+
const firstMonthStemIdx = ((yearStemIdx % 5) * 2 + 2) % 10;
|
| 53 |
+
const monthOffset = calcMonth - 2;
|
| 54 |
+
const monthStemIdx = (firstMonthStemIdx + monthOffset) % 10;
|
| 55 |
+
const monthBranchIdx = (2 + monthOffset) % 12;
|
| 56 |
+
const monthPillar = STEMS[monthStemIdx] + BRANCHES[monthBranchIdx];
|
| 57 |
+
|
| 58 |
+
// 3. Day Pillar (Simplified Algorithm)
|
| 59 |
+
const baseDate = new Date(1900, 0, 1);
|
| 60 |
+
const deltaDays = Math.floor((date - baseDate) / (1000 * 60 * 60 * 24));
|
| 61 |
+
const dayStemIdx = (0 + deltaDays) % 10;
|
| 62 |
+
const dayBranchIdx = (10 + deltaDays) % 12;
|
| 63 |
+
const dayPillar = STEMS[dayStemIdx] + BRANCHES[dayBranchIdx];
|
| 64 |
+
|
| 65 |
+
const prefix = "Professional career profile based on astrology: ";
|
| 66 |
+
const pillars = [yearPillar, monthPillar, dayPillar];
|
| 67 |
+
const names = ["Year", "Month", "Day"];
|
| 68 |
+
|
| 69 |
+
let baseTexts = [];
|
| 70 |
+
let rawBase = pillars;
|
| 71 |
+
|
| 72 |
+
for (let i = 0; i < 3; i++) {
|
| 73 |
+
const pillar = pillars[i];
|
| 74 |
+
const desc = SAJU_DESCRIPTIONS[pillar[0]] + " " + SAJU_DESCRIPTIONS[pillar[1]];
|
| 75 |
+
baseTexts.push(`${prefix} ${names[i]} Pillar: ${desc}`.trim());
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
// 4. Time Pillars (The 12 variations for MIL)
|
| 79 |
+
let timeTexts = [];
|
| 80 |
+
let rawTime = [];
|
| 81 |
+
const firstHourStemIdx = ((dayStemIdx % 5) * 2) % 10;
|
| 82 |
+
|
| 83 |
+
for (let hIdx = 0; hIdx < 12; hIdx++) {
|
| 84 |
+
const hStemIdx = (firstHourStemIdx + hIdx) % 10;
|
| 85 |
+
const hPillar = STEMS[hStemIdx] + BRANCHES[hIdx];
|
| 86 |
+
const desc = SAJU_DESCRIPTIONS[hPillar[0]] + " " + SAJU_DESCRIPTIONS[hPillar[1]];
|
| 87 |
+
timeTexts.push(`${prefix} Time Pillar: ${desc}`.trim());
|
| 88 |
+
rawTime.push(hPillar);
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
return { baseTexts, timeTexts, rawBase, rawTime };
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
// Export for Node or keep global for Browser
|
| 95 |
+
if (typeof module !== 'undefined' && module.exports) {
|
| 96 |
+
module.exports = { getSajuPillars, STEMS, BRANCHES, SAJU_DESCRIPTIONS };
|
| 97 |
+
}
|