--- id: wiki-2026-0508-figurative-language title: Figurative Language category: 10_Wiki/Topics status: verified canonical_id: self aliases: [figurative language, metaphor, simile, idiom, sarcasm, NLP figurative] duplicate_of: none source_trust_level: A confidence_score: 0.88 verification_status: applied tags: [linguistics, nlp, figurative, metaphor, simile, idiom, sarcasm] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: NLP / Python framework: Transformers / spaCy --- # Figurative Language ## 매 한 줄 > **"매 literal meaning 의 X — 매 implied meaning"**. 매 metaphor, simile, idiom, sarcasm, irony, hyperbole, personification. 매 NLP 의 challenge — 매 LLM 의 의 의 better. 매 Lakoff conceptual metaphor → 매 modern transformer. ## 매 핵심 ### 매 type - **Metaphor**: "Time is money". - **Simile**: "Brave as a lion". - **Idiom**: "Kick the bucket". - **Sarcasm / Irony**: 매 opposite literal. - **Hyperbole**: "I died laughing". - **Personification**: "The wind whispered". - **Metonymy**: "The crown" (= king). ### 매 NLP challenge - 매 literal interpreter 의 fail. - 매 cross-cultural varies. - 매 context-dependent. - 매 sarcasm 의 매 hardest (no surface marker). ### 매 modern method - **LLM** (GPT, Claude): 매 zero-shot decent. - **Sentence embedding** + classifier. - **Conceptual metaphor identification**. - **Multi-task** (sentiment + sarcasm). ### 매 응용 1. **Sentiment analysis**: 매 sarcasm 의 detect. 2. **Translation**: 매 idiom localize. 3. **Content moderation**. 4. **Search / IR**. 5. **Education**: 매 figurative interpretation teaching. ## 💻 패턴 ### Detect sarcasm (transformer) ```python from transformers import pipeline sarcasm_clf = pipeline('text-classification', model='helinivan/english-sarcasm-detector') result = sarcasm_clf("Oh great, another Monday!") # 매 [{'label': 'sarcastic', 'score': 0.92}] ``` ### Detect metaphor (with LLM) ```python def detect_metaphor(sentence, llm): prompt = f"""Is the following sentence metaphorical? If yes, identify the metaphor. Sentence: "{sentence}" Output JSON: - is_metaphor: bool - source_domain: ... - target_domain: ... - explanation: ...""" return json.loads(llm.generate(prompt)) detect_metaphor("Her career took off after that promotion.", llm) # 매 source: flight, target: career ``` ### Idiom translation ```python IDIOM_DB = { 'kick the bucket': {'en': 'die', 'ko': '죽다', 'fr': 'mourir'}, 'break a leg': {'en': 'good luck', 'ko': '행운을 빌다'}, 'piece of cake': {'en': 'easy', 'ko': '식은 죽 먹기'}, } def translate_idiom(text, target_lang): for idiom, trans in IDIOM_DB.items(): if idiom in text.lower(): return text.replace(idiom, trans[target_lang]) return text ``` ### LLM idiom-aware translation ```python def smart_translate(text, target_lang, llm): prompt = f"""Translate to {target_lang}, preserving figurative meaning. If an idiom exists, use the equivalent target idiom rather than literal translation. Source: "{text}" Output: translation only.""" return llm.generate(prompt) ``` ### Conceptual metaphor (Lakoff) ```python CONCEPTUAL_METAPHORS = { 'TIME_IS_MONEY': ['save time', 'spend time', 'waste time', 'invest time'], 'ARGUMENT_IS_WAR': ['attack', 'defend', 'win', 'lose'], 'IDEAS_ARE_OBJECTS': ['grasp', 'hold', 'pass on'], 'LOVE_IS_JOURNEY': ['go separate ways', 'crossroads'], 'UP_IS_GOOD': ['high spirits', 'rise', 'top'], } def detect_conceptual(text): found = [] for cm, markers in CONCEPTUAL_METAPHORS.items(): if any(m in text.lower() for m in markers): found.append(cm) return found ``` ### Multi-task (sentiment + sarcasm) ```python class MultiTaskModel(torch.nn.Module): def __init__(self, base): super().__init__() self.base = base self.sentiment_head = torch.nn.Linear(768, 3) self.sarcasm_head = torch.nn.Linear(768, 2) def forward(self, x): feat = self.base(x).pooler_output return { 'sentiment': self.sentiment_head(feat), 'sarcasm': self.sarcasm_head(feat), } ``` ### Eval (with figurative) ```python def adjusted_sentiment(text, sarcasm_score, sentiment_score): """매 sarcastic → 매 flip sentiment.""" if sarcasm_score > 0.7: return -sentiment_score return sentiment_score ``` ### Hyperbole detection ```python HYPERBOLE_MARKERS = ['always', 'never', 'died', 'a million', 'the worst', 'the best ever'] def has_hyperbole(text): return any(m in text.lower() for m in HYPERBOLE_MARKERS) ``` ### Cross-cultural figurative test ```python def cultural_metaphor_test(metaphor, languages, llm): results = {} for lang in languages: prompt = f"In {lang}, how is the metaphor '{metaphor}' typically expressed? If different, give the cultural equivalent." results[lang] = llm.generate(prompt) return results ``` ### Personification detector ```python def detect_personification(text, llm): prompt = f"""Identify personification (giving human traits to non-human). Text: "{text}" Output: list of personifications + the human trait + the entity.""" return llm.generate(prompt) ``` ### Figurative-aware embedding ```python from sentence_transformers import SentenceTransformer m = SentenceTransformer('all-mpnet-base-v2') # 매 idiom and literal 의 should be different emb1 = m.encode("It's raining cats and dogs.") # 매 idiom emb2 = m.encode("It is raining heavily.") # 매 literal emb3 = m.encode("Cats and dogs are falling from the sky.") # 매 absurd literal # 매 1-2 close, 1-3 distant (good model) ``` ## 매 결정 기준 | 상황 | Approach | |---|---| | Sentiment / sarcasm | Multi-task transformer | | Translation | LLM idiom-aware | | Linguistics research | Conceptual metaphor | | Search | Idiom DB + paraphrase | | Education | LLM explainer | **기본값**: 매 modern LLM 의 default + 매 sarcasm 의 specialized + 매 idiom DB + 매 cultural awareness. ## 🔗 Graph - 부모: [[NLP]] - 변형: [[Metaphor]] · [[Idiom]] - 응용: [[Sentiment-Analysis]] - Adjacent: [[Embodied Cognition]] · [[Pragmatics]] ## 🤖 LLM 활용 **언제**: 매 sentiment. 매 translation. 매 educational. **언제 X**: 매 strict literal task. ## ❌ 안티패턴 - **Literal-only NLP**: 매 sarcasm miss. - **Word-by-word translate**: 매 idiom break. - **No cultural check**: 매 offense / confusion. - **Single language assumption**: 매 i18n fail. ## 🧪 검증 / 중복 - Verified (Lakoff & Johnson, NLP figurative literature). - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-04-20 | Auto-reinforced | | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — types + 매 sarcasm / metaphor / idiom / multi-task code |