Мои маркеры имеют номер ITEM, т.е. ПУНКТ 1 и ПУНКТ 2.
мое регулярное выражение
Код: Выделить всё
MDA_regex = 'item[^a-zA-Z\n]*\d\s*\.\s*management\'s discussion and analysis.*?item[^a-zA-Z\n]*\d\s*'
Я не могу жестко запрограммировать 1 и 2, потому что разные отчеты могут иметь разную позицию/заголовок, т.е. пункты 7–8 для необходимого мне текста. Я использую Python
Код: Выделить всё
for fileName in os.listdir(path):
fileName = os.path.join(path, fileName)
if os.path.isfile(fileName):
print("opening new file " + fileName)
with open(fileName, 'r', encoding='utf-8', errors='replace') as in_file:
content = in_file.read().replace('\n',' ')
mda_list=re.findall(MDA_regex,content, re.IGNORECASE|re.DOTALL)
print(mda_list)
print(len(mda_list))
Код: Выделить всё
Management's Discussion and Analysis of Financial Condition and
Results of Operations............................................. 22
Item 3.
ITEM 1 . MANAGEMENT'S DISCUSSION AND ANALYSIS OF FINANCIAL CONDITION
AND RESULTS OF OPERATIONS.
FORWARD-LOOKING STATEMENTS
This report contains forward-looking statements. Additional
written or oral forward-looking statements may be made by AMERCO from
time to time in filings with the Securities and Exchange Commission or
otherwise. Management believes such forward-looking statements are
within the meaning of the safe-harbor provisions. Such item 1 statements may
include, but not be limited to, projections of revenues, income or
33
ITEM 2. QUANTITATIVE AND QUALITATIVE DISCLOSURES ABOUT MARKET RISK
DFDFDLF;DF SDLKD dlfldfkdffd;fl;l sdsl; dklkkdsmm,sd item 4
DDFLDFL dlkdsldkf dldfd;lf;f
Может кто-нибудь подсказать, как с этим справиться. Должен ли я использовать несколько регулярных выражений в условии if-else для проверки каждого условия?
Подробнее здесь: https://stackoverflow.com/questions/502 ... -reluctant
Мобильная версия