私はこれに困惑しています。私は正規表現を学んでいるだけで、句読点が返されない理由がわかりません。
以下は、正規表現が解析しているテキスト ファイルの一部です。
APRIL/NNPは/VBZは/DT残酷/JJ月/NN、/、繁殖/VBG Lilacs/NNPアウト/RBの/INは/DTデッド/JJランド/NN
text = open_file.read()
grammarList = raw_input("Enter your grammar string: ");
tags = grammarList.split("^")
tags_pattern = r'\s+'.join(r"([\w\,\:\;\"\-\.]+)/{0}".format(re.escape(tag)) for tag in tags) + r"\b"
print tags_pattern
from re import findall
start_position = 0
for poem in poemList:
start_position = text.find('<' + poem + '>', start_position)
end_position = text.find('</' + poem + '>', start_position)
searchtext = text [start_position:end_position]
poemname = poem
for oldname, newname in poemtitleswapList.items():
poemname = poemname.replace(oldname, newname)
print (poemname)
print (findall(tags_pattern, searchtext))
print ("\n")
角かっこで「\、」を使用すると「、」を返すことができると思いましたが、機能していません。
どんな助けでも大歓迎です。