File size: 586 Bytes
0154ae7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
def contains_polite_word(text: str) -> bool:
    """Return True if the Vietnamese text looks explicitly polite.

    We check for common polite patterns like 'vui lòng', 'làm ơn', 'giúp', 'được không', 'nhé'.
    """
    t = text.lower()
    patterns = ["vui lòng", "làm ơn", "giúp", "được không", "nhé"]
    return any(p in t for p in patterns)

if __name__ == "__main__":
    tests = [
        "Robot ơi, bật đèn phòng khách",
        "Vui lòng hút bụi phòng ngủ nhé",
    ]
    for t in tests:
        print(repr(t), "->", contains_polite_word(t))