Skip to content

Instantly share code, notes, and snippets.

@MNie
Last active August 14, 2016 15:08
Show Gist options
  • Save MNie/98e33c95f331bd3807adf646fec81d67 to your computer and use it in GitHub Desktop.
Save MNie/98e33c95f331bd3807adf646fec81d67 to your computer and use it in GitHub Desktop.
AzureTextAnalytics, semantic, concat function
type responseJson =
{
documents: seq<responseDoc>
errors: string list
}
and responseDoc =
{
score: double
id: string
}
type results =
{
sentiments: estimatedDoc list
}
and estimatedDoc =
{
Id: string
Text: string
Score: double
}
let concatSentimentAndInput =
let json = createJson (commentaries.Load("input.csv").Rows)
let estimate = getSentimentScore json
let parsedSentiment = JsonConvert.DeserializeObject<responseJson>(estimate)
parsedSentiment.documents
|> Seq.map (fun x ->
{
Id = x.id;
Text = json.documents
|> Seq.where (fun y -> y.id.Equals x.id)
|> Seq.head
|> (fun y -> y.text);
Score = x.score
}
)
|> Seq.sortBy (fun x -> x.Score)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment