FACTORIE: Probabilistic Programming via Imperatively Defined Factor Graphs