То же, что и @ zx81's (*SKIP)(*F)
, но с использованием отрицательного утверждения lookahead.
(?m)(?:if\(.*?\/\/endif|\([^()]*\))(*SKIP)(*F)|\b\d+\b(?!.*\.$)
В python я бы сделал легко например,
import re
string = """cat 123 sat.
I like 000 not (456) though 111 is fine
222 if( //endif if(cat==789 stuff //endif 333"""
for line in string.split('\n'): # Split the input according to the `\n` character and then iterate over the parts.
if not line.endswith('.'): # Don't consider the part which ends with a dot.
for i in re.split(r'\([^()]*\)|if\(.*?//endif', line): # Again split the part by brackets or if condition which endswith `//endif` and then iterate over the inner parts.
for j in re.findall(r'\b\d+\b', i): # Then find all the numbers which are present inside the inner parts and then loop through the fetched numbers.
print(j) # Prints the number one ny one.
Выход:
000
111
222
333
Либо вы должны усечь / заполнить файлы так, чтобы все они были одинакового размера (скажем, 5 секунд), либо объединить функции для файла в вектор фиксированной длины, который не зависит от длины клипа (средняя / мин / макс) или вы заставляете классификатор работать с потоком окон объектов фиксированной длины (скажем, 1 секунда).