File: greetingInKorean.py

package info (click to toggle)
pyparsing 3.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,928 kB
  • sloc: python: 25,633; ansic: 422; makefile: 22
file content (20 lines) | stat: -rw-r--r-- 495 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# greetingInKorean.py
#
# Demonstration of the parsing module, on the prototypical "Hello, World!" example
#
# Copyright 2004-2016, by Paul McGuire
#
from pyparsing import Word, pyparsing_unicode as ppu

korean_chars = ppu.한국어.alphas
korean_word = Word(korean_chars, min=2)

# define grammar
greet = korean_word + "," + korean_word + "!"

# input string
hello = "안녕, 여러분!"  # "Hello, World!" in Korean

# parse input string
print(greet.parse_string(hello))