Learning relationship types and rules