A General Framework for Learning from Weak Supervision