Dependency detection with similarity constraints