Files
2nd/10_Wiki/Topics/AI_and_ML/Figurative-Language.md
T
Antigravity Agent f8b21af4be Wiki cleanup: error-doc removal, dedup merge, link normalization
10_Wiki/Topics 대규모 정리:
- 오류 캡처/미완성 stub 문서 227개 제거
- 교차폴더 중복 43클러스터 병합 (63파일 → redirect)
- 링크명 정규화: 깨진 링크 수정·redirect 직결·개념 매핑 ~2,400건
- 카테고리 MOC 6개 신규 생성
- Graph 섹션 미해결 related-keyword 링크 10,058건 제거

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 23:52:15 +09:00

6.7 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-figurative-language Figurative Language 10_Wiki/Topics verified self
figurative language
metaphor
simile
idiom
sarcasm
NLP figurative
none A 0.88 applied
linguistics
nlp
figurative
metaphor
simile
idiom
sarcasm
2026-05-10 pending
language framework
NLP / Python 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)

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)

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

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

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)

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)

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)

def adjusted_sentiment(text, sarcasm_score, sentiment_score):
    """매 sarcastic → 매 flip sentiment."""
    if sarcasm_score > 0.7:
        return -sentiment_score
    return sentiment_score

Hyperbole detection

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

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

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

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

🤖 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