Constructing linear equations from context