-4
私はPythonが初めてです。私は項目のリストの数を得るためのコードを書くのに苦労していますPython-テキストファイル内の項目の数をカウントする
keywords = ['bed', 'slot', 'display pane', 'graph', 'bedsides', 'multiviewer display', 'bed1']
以下のサンプルテキストを含むテキストファイルにあります。
Verify that the Respiration waveform size can be modified.
Verify that changed Respiration waveform size is updated in Central Station.
Verify that the Respiration Lead Selection settings are displayed as read-only for the Telemetry Bed at the Central Station.
Verify that the NBP Auto mode settings are displayed for the Telemetry Bed at the Central Station.
Verify that the NBP cuff size settings are displayed as read-only for the Telemetry Bed at the Central Station.
Verify that the ECG lead analysis options displayed for the Telemetry Bed at the Central Station include the following:
Verify that the adjustment of the ECG Lead Analysis setting from Single-Lead and Multi-Lead is permitted for the Telemetry Bed at the Central Station.
Verify that the ECG Detect Pace settings displayed for the Telemetry Bed at the Central Station include the following:
Verify that the adjustment of the ECG Detect Pace setting from PACE1 PACE2 and OFF is permitted for the Telemetry Bed at the Central Station.
Verify that the ECG Display Lead settings displayed for the Telemetry Bed at the Central Station include the following:
Verify that the adjustment of ECG Display Lead setting from I II III V aVR aVL and aVF for the Telemetry Bed is permitted at the Central Station.
Verify that the SpO2 Waveform Size settings are displayed for the Telemetry Bed but it's read-only(grayed out).
Verify that the Central Station shall display the NIBP auto mode setting as read only.
Verify that the displayed NBP Stat mode settings are read-only for the Telemetry Bed at the Central Station.
Verify that a means to clear the NBP message is provided for the Telemetry Bed at the Central Station.
Verify that the message displayed for the Telemetry Bed in the Multiviewer slot is cleared.
Verify that the ECG Va Lead Selections displayed for the Telemetry Bed at the Central Station include the following:
Verify that the adjustment of the ECG Va Lead Selection setting from V1 V2 V3 V4 V5 and V6 is permitted for the Telemetry Bed at the Central Station except for one of the Va lead which will be greyed out based on the Vb lead selected.
Verify that the ECG Vb Lead Selections displayed for the Telemetry Bed at the Central Station include the following:
Verify that the adjustment of the ECG Vb Lead Selection setting from V2 V3 V4 V5 and V6 is permitted for the Telemetry Bed at the Central Station except for one of the Vb lead which will be greyed out based on the Va lead selected.
Verify that the NBP Stat Mode setting is displayed as a read-only value of either ON or OFF for the Telemetry Bed at the Central Station.
Verify that the message displayed for the Telemetry Bed in the Multiviewer slot is cleared.
Verify that the adjustment of the SPO2 rate setting is permitted for the Telemetry Bed at the Central Station.
注:リスト項目の数を見つける前に、上記のテキストを小文字に変換することもできます。
前に、すべてのテキストを小文字にする必要はありませんので、あなたは、ケースを無視することができます
re
でre.findall
(https://docs.python.org/3.6/library/re.html#re.findall)を見ている必要があります。 findall。テキストファイルのすべての行について、私はコードスニペットの下で実行しています。
re.findall( '|' .join(Keywords)、line、re.IGNORECASE)
私はキーワード、ベッド、スロット、グラフの出現を識別することができます。リスト内の残りの単語は識別されませんでした。正規表現で助けてください。 – Sasanka