Skip to content

Instantly share code, notes, and snippets.

@MNie
Last active August 14, 2016 15:07
Show Gist options
  • Save MNie/60c0ae7de329a09a342e780af11f3d56 to your computer and use it in GitHub Desktop.
Save MNie/60c0ae7de329a09a342e780af11f3d56 to your computer and use it in GitHub Desktop.
Azure text analytics, sentiment, createjson
type requestJson =
{
documents: seq<document>
}
and document =
{
language: string
id: string
text: string
}
let createJson (data:seq<CsvProvider<"input.csv">.Row>) =
{
documents = data |> Seq.map ( fun x -> x.ToString()) |> Seq.mapi ( fun i x -> {language = "en"; id = i.ToString(); text = x})
}
let saveJson (json, fileName: string) =
use outFile = new StreamWriter(fileName)
(
outFile.Write(JsonConvert.SerializeObject json)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment