public EnglishWordSentiment(string word, string valence, string stateIntensity, string emotion, string judgment, string agreement, string intention) { Word = word; if (!Enum.TryParse(valence, out this.valence)) { this.valence = Valence.NULL; } if (!Enum.TryParse(stateIntensity, out this.stateIntensity)) { this.stateIntensity = StateIntensity.NULL; } if (!Enum.TryParse(emotion, out this.emotion)) { this.emotion = Emotion.NULL; } if (!Enum.TryParse(judgment, out this.judgment)) { this.judgment = Judgment.NULL; } if (!Enum.TryParse(agreement, out this.agreement)) { this.agreement = Agreement.NULL; } if (!Enum.TryParse(intention, out this.intention)) { this.intention = Intention.NULL; } }
public VideoFrame(DateTime time, string emotion, float emotionIntensity, string valence, float valenceIntensity) { this.time = time; this.emotion = Constants.ParseEmotion(emotion); this.emotionIntensity = emotionIntensity; this.valence = Constants.ParseValence(valence); this.valenceIntensity = valenceIntensity; }
//Deserialization constructor. public VideoFrame(SerializationInfo info, StreamingContext ctxt) { //Get the values from info and assign them to the appropriate properties time = (DateTime)info.GetValue("time", typeof(DateTime)); emotion = (Emotion)info.GetValue("emotion", typeof(Emotion)); emotionIntensity = (float)info.GetValue("emotionIntensity", typeof(float)); valence = (Valence)info.GetValue("valence", typeof(Valence)); valenceIntensity = (float)info.GetValue("valenceIntensity", typeof(float)); }
public BookItem[] AssignedBooks( Valence.Request.Parameters param, ref string message ) { var classOrgInfo = new Valence.OrgUnitInfo() {Id = param.ClassOrgId}; var result = new List<BookItem>(); result.AddRange( GetBooksForClass( param, classOrgInfo, ref message ) ); return result.ToArray(); }
public EnglishWordSentiment(string word, Valence valence, StateIntensity stateIntensity, Emotion emotion, Judgment judgment, Agreement agreement, Intention intention) { Word = word; this.valence = valence; this.stateIntensity = stateIntensity; this.emotion = emotion; this.judgment = judgment; this.agreement = agreement; this.intention = intention; }
public override string ToString() { string result = Timestamp.ToString(); result += ";" + Neutral.ToString(); result += ";" + Happy.ToString(); result += ";" + Sad.ToString(); result += ";" + Angry.ToString(); result += ";" + Surprised.ToString(); result += ";" + Scared.ToString(); result += ";" + Disgusted.ToString(); result += ";" + Contempt.ToString(); result += ";" + Valence.ToString(); result += ";" + Arousal.ToString(); return(result); }
public bool RemoveBook( Valence.Request.Parameters param, string isbn, ref string message ) { var uri = param.UserContext.CreateAuthenticatedUri( "/d2l/api/" + param.ApiVersion( "le" ) + "/" + param.ClassOrgId + "/content/isbn/" + isbn, "DELETE" ); var request = (HttpWebRequest) WebRequest.Create( uri ); request.Method = "DELETE"; var handler = new Valence.Request.ErrorHandler(); Valence.Request.Perform( request, param.UserContext, delegate( string data ) { }, handler.Process ); if( handler.IsError ) { message = "Unable to remove books from course. " + handler.Message; } return !handler.IsError; }
public bool AddBook( Valence.Request.Parameters param, string isbn, ref string message ) { Uri uri = param.UserContext.CreateAuthenticatedUri( "/d2l/api/" + param.ApiVersion( "le" ) + "/" + param.ClassOrgId + "/content/isbn/", "POST" ); var bookIsbn = new Valence.IsbnAssociation { Isbn = isbn }; var serializer = new JavaScriptSerializer(); String postData = serializer.Serialize(bookIsbn); var request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "POST"; request.ContentType = "application/json"; using( var requestWriter = new StreamWriter( request.GetRequestStream() ) ) { requestWriter.Write( postData ); } bool result = true; var handler = new Valence.Request.ErrorHandler(); Valence.Request.Perform( request, param.UserContext, delegate( string data ) { var responseSerializer = new JavaScriptSerializer(); var bookResult = responseSerializer.Deserialize<Valence.Book>( data ); if (bookResult.Isbn != isbn) { result = false; } }, handler.Process); if( handler.IsError ) { result = false; message = "Unable to add books to course. " + handler.Message; } return result; }
public string toString() { return(Symbol + " " + Id.ToString() + " " + Valence.ToString()); }
private List<BookItem> GetBooksForClass( Valence.Request.Parameters param, Valence.OrgUnitInfo course, ref string message) { Uri uri = param.UserContext.CreateAuthenticatedUri( "/d2l/api/"+ param.ApiVersion("le") + "/" + course.Id + "/content/isbn/", "GET" ); var request = (HttpWebRequest)WebRequest.Create( uri ); request.Method = "GET"; var handler = new Valence.Request.ErrorHandler(); var result = new List<BookItem>(); Valence.Request.Perform( request, param.UserContext, delegate( string data ) { var serializer = new JavaScriptSerializer(); var books = serializer.Deserialize<Valence.Book[]>( data ); if( ( books == null ) || ( books.Length <= 0 ) ) { return; } foreach( Valence.Book b in books ) { try { GoogleBook.Volume volume = GoogleBook.Api.Query( b.Isbn ); if( volume.TotalItems != 0 ) { GoogleBook.Item item = volume.items.First(); BookItem book = FromGoogleBookToBookItem( item ); result.Add( book ); } } catch( ArgumentNullException ) {} } }, handler.Process ); if( handler.IsError ) { message = "Unable to retrieve assigned books. " + handler.Message; } return result; }