Exemplo n.º 1
0
import re
from nlp20 import extract_json

if __name__ == '__main__':
    lines = extract_json('イギリス').split('\n')

    # pattern = r"Category"
    # repatter = re.compile(pattern)

    for line in lines:
        if "Category" in line:
            print(line)
Exemplo n.º 2
0
import re
from nlp20 import extract_json

if __name__ == '__main__':
    lines = extract_json("イギリス").split('\n')

    for line in lines:
        category = re.search("^\[\[Category:(.*?)(\|.*)*\]\]$", line)
        if category is not None:
            print(category.group(1))
Exemplo n.º 3
0
import re
from nlp20 import extract_json

dict = {}
lines = re.split(r"\n[\|}]", extract_json('イギリス'))

for line in lines:
    field = re.search("^(.*?)\s=\s(.*)", line, re.S)
    if field is not None:
        dict[field.group(1)] = field.group(2)

for key, value in sorted(dict.items(), key=lambda x: x[1]):
    print(key, value)