A federal judge has ruled in favor of artificial intelligence company Anthropic in its legal battle against the Pentagon.