After military service as commander of the Motor Torpedo Boats PT-109 and PT-59 during World War II in the South Pacific , Kennedy represented Massachusetts' 11th congressional district in the U.S. House of Representatives from 1947 to 1953 as a Democrat .