public void TestDateMapping_LastTuesdayLowerCase() { var atr = new AnnotateTextResponse(); atr.Sentences.Add(new Sentence() { Text = new TextSpan() { Content = "Last tuesday I went to the shops" } }); var claim = new ClaimPopulator().PopulateClaim(atr); Assert.IsNull(claim.DamagedItem); Assert.IsNull(claim.DamageLocation); Assert.IsNull(claim.TypeOfDamage); //Look for last Wednesday var comparisonDate = DateTime.Today.AddDays(-1); while (comparisonDate.DayOfWeek != DayOfWeek.Tuesday) { comparisonDate = comparisonDate.AddDays(-1); } Assert.AreEqual(comparisonDate, claim.DateOfDamage); }
public void TestDateMapping_specificWithBackslashesAndSingleDigitDayAndMonthDoubleDigitYear() { var atr = new AnnotateTextResponse(); atr.Sentences.Add(new Sentence() { Text = new TextSpan() { Content = "On 6\\4\\16 I went to the shops" } }); var claim = new ClaimPopulator().PopulateClaim(atr); Assert.IsNull(claim.DamagedItem); Assert.IsNull(claim.DamageLocation); Assert.IsNull(claim.TypeOfDamage); Assert.AreEqual(new DateTime(2016, 4, 6), claim.DateOfDamage); }
public void TestDateMapping_specificWithSlashes() { var atr = new AnnotateTextResponse(); atr.Sentences.Add(new Sentence() { Text = new TextSpan() { Content = "On 11/04/2016 I went to the shops" } }); var claim = new ClaimPopulator().PopulateClaim(atr); Assert.IsNull(claim.DamagedItem); Assert.IsNull(claim.DamageLocation); Assert.IsNull(claim.TypeOfDamage); Assert.AreEqual(new DateTime(2016, 4, 11), claim.DateOfDamage); }
public void TestDamageMapping_StolenTokenPresent() { var atr = new AnnotateTextResponse(); atr.Tokens.Add(new Token() { Lemma = "steal", PartOfSpeech = new PartOfSpeech() { Tag = PartOfSpeech.Types.Tag.Verb } }); var claim = new ClaimPopulator().PopulateClaim(atr); Assert.IsNull(claim.DamagedItem); Assert.IsNull(claim.DamageLocation); Assert.AreEqual(Claim.DamageType.Stolen, claim.TypeOfDamage); Assert.IsNull(claim.DateOfDamage); }
public void TestDateMapping_dayOfMonth() { for (var i = 1; i < 12; i++) { var atr = new AnnotateTextResponse(); atr.Sentences.Add(new Sentence() { Text = new TextSpan() { Content = "On the 6th of " + getMonth(i) + " I went to the shops" } }); var claim = new ClaimPopulator().PopulateClaim(atr); Assert.IsNull(claim.DamagedItem); Assert.IsNull(claim.DamageLocation); Assert.IsNull(claim.TypeOfDamage); Assert.AreEqual(new DateTime(DateTime.Now.Year, i, 6), claim.DateOfDamage); } }
public void TestEntityMapping_EntitiesOnly_NoDamage() { var atr = new AnnotateTextResponse(); atr.Entities.Add(new Entity() { Name = "iPhone", Type = Entity.Types.Type.ConsumerGood }); atr.Entities.Add(new Entity() { Name = "beach", Type = Entity.Types.Type.Location }); var claim = new ClaimPopulator().PopulateClaim(atr); Assert.AreEqual("iPhone", claim.DamagedItem); Assert.AreEqual("beach", claim.DamageLocation); Assert.IsNull(claim.TypeOfDamage); Assert.IsNull(claim.DateOfDamage); }
public void TestDateMapping_Yesterday() { var atr = new AnnotateTextResponse(); atr.Tokens.Add(new Token() { Text = new TextSpan() { Content = "Yesterday", }, PartOfSpeech = new PartOfSpeech() { Tag = PartOfSpeech.Types.Tag.Noun } }); var claim = new ClaimPopulator().PopulateClaim(atr); Assert.IsNull(claim.DamagedItem); Assert.IsNull(claim.DamageLocation); Assert.IsNull(claim.TypeOfDamage); Assert.AreEqual(DateTime.Today.AddDays(-1), claim.DateOfDamage); }
public Claim GetAnnotatedText(string text) { var claim = new ClaimPopulator(); return(claim.PopulateClaim(NaturalLanguage.AnalyzeEverything(text))); }