Creates a new NLPDocument from a string

Property definitions

nlp $ NLPProcessor :: process
	# Creates a new NLPDocument from a string
	fun process(string: String): NLPDocument is abstract
lib/nlp/stanford.nit:31,2--32,53

nlp $ NLPJavaProcessor :: process
	# Process a string and return a new NLPDocument from this.
	redef fun process(string) do
		var tmp_file = ".nlp.in"
		var file = new FileWriter.open(tmp_file)
		file.write string
		file.close
		var doc = process_file(tmp_file)
		tmp_file.file_delete
		return doc
	end
lib/nlp/stanford.nit:64,2--73,4

nlp $ NLPClient :: process
	redef fun process(string) do
		var request = new CurlHTTPRequest(post_uri)
		request.body = string
		var response = request.execute
		if response isa CurlResponseSuccess then
			if response.status_code != 200 then
				print "Error: {response.body_str}"
				return new NLPDocument
			end
			var xml = response.body_str.to_xml
			if xml isa XMLError then
				print xml
			end
			return new NLPDocument.from_xml(response.body_str.to_xml.as(XMLDocument))
		else if response isa CurlResponseFailed then
			print "Error: {response.error_msg}"
			return new NLPDocument
		end
		return new NLPDocument
	end
lib/nlp/stanford.nit:357,2--376,4