Last active
August 14, 2016 15:08
-
-
Save MNie/98e33c95f331bd3807adf646fec81d67 to your computer and use it in GitHub Desktop.
AzureTextAnalytics, semantic, concat function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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