Oscillations of a flexible filament under surface gravity waves