Exemplo n.º 1
0
        /// <summary>
        /// Converts a given JSON-string to a <c>NewsMaterial</c> instance.
        /// </summary>
        /// <param name="json">
        /// The JSON-string.
        /// </param>
        /// <returns>
        /// A <c>NewsMaterial</c> instance with values defined in the JSON-string.
        /// </returns>
        public static NewsMaterial ParseJson(string json)
        {
            NewsMaterial news = new NewsMaterial();

            try
            {
                // Parse JSON and assign various values.
                var values = JObject.Parse(json);
                news.Author = values["author"].ToString();
                news.Content = values["content"].ToString();

                DateTime date;
                if (DateTime.TryParse(values["published"].ToString(), out date))
                {
                    news.Date = date;
                }

                news.Summary = values["rss_summary"].ToString();
                news.Title = values["title"].ToString();
                news.Url = new Uri(values["url"].ToString());

                // Generate random GUID because it is not included in the training
                // data.
                news.Guid = Guid.NewGuid().ToString();
                news.Publisher = "Unknown";

                return news;
            }
            catch(Newtonsoft.Json.JsonReaderException)
            {
                // Some error occured. Return null.
                return null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Asserts the given <c>NewsMaterial</c> is equivalent to the given
        /// <c>NewsItem</c>.
        /// </summary>
        /// <param name="newsMaterial">
        /// The <c>NewsMaterial</c> to check against.
        /// </param>
        /// <param name="newsItem">
        /// The <c>NewsItem</c> to check against.
        /// </param>
        /// <param name="index">
        /// An index printed when an assert fails.
        /// </param>
        public static void AssertNewsMaterialEquivalent(NewsMaterial newsMaterial,
            NewsItem newsItem, int index = 0)
        {
            // Check if the news item matches the news material.
            Assert.AreEqual(newsMaterial.Title, newsItem.Title,
                " Index: " + index + ": The titles were not equal.");
            Assert.AreEqual(newsMaterial.Author, newsItem.Author,
                " Index: " + index + ": The titles were not equal.");
            Assert.AreEqual(newsMaterial.Source == null ? null : newsMaterial.Source.Name,
            newsItem.Source == null ? null : newsItem.Source.Name,
                " Index: " + index + ": The sources were not equal.");
            Assert.AreEqual(newsMaterial.Url.OriginalString, newsItem.Url.OriginalString,
                " Index: " + index + ": The urls were not equal.");
            Assert.AreEqual(newsMaterial.Date, newsItem.Date,
                " Index: " + index + ": The dates were not equal.");

            // Get the expectedTerms of the news material.
            Dictionary<string, int> tf =
                TermUtils.CalculateTermFrequency(newsMaterial.Content);
            // Convert to a list.
            List<string> expectedTerms = tf.Keys.ToList();

            // Convert the actual terms to a list.
            List<string> actualTerms = new List<string>();
            foreach (Term term in newsItem.Terms)
            {
                actualTerms.Add(term.TermName);
            }

            // Assert the expectedTerms are equal.
            CollectionAssert.AreEquivalent(expectedTerms, actualTerms,
                " Index: " + index + ": The terms where not equivalent.");
        }
Exemplo n.º 3
0
        public void AuthorTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Author = "foo";

            Assert.AreEqual("foo", m.Author);
        }
Exemplo n.º 4
0
        public void ContentTestInvalidInput()
        {
            bool exceptionThrown = false;

            try
            {
                NewsMaterial n = new NewsMaterial();
                n.Content = null;
            }
            catch (ArgumentNullException)
            {
                exceptionThrown = true;
            }

            Assert.IsTrue(exceptionThrown,
                "No ArgumentNullException was thrown.");
        }
Exemplo n.º 5
0
        public void UrlTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Url = new Uri("http://www.foo.bar");

            Assert.AreEqual(new Uri("http://www.foo.bar"), m.Url);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Stores a news item and returns it id.
        /// The <c>DatabaseConnection</c> must be open prior to calling 
        /// this method.
        /// </summary>
        /// <param name="newsMaterial">
        /// The <c>NewsMaterial</c> to create the news item from.
        /// </param>
        /// <param name="newsId">
        /// The id of the news item. -1 if it does not already exist.
        /// </param>
        /// <param name="categoryId">
        /// The id of the category of the news item.
        /// </param>
        /// <param name="newsSourceId">
        /// The <c>NewsSource</c> id of the news item to store.
        /// </param>
        /// <param name="termCount">
        /// The number of terms in this news item.
        /// </param>
        /// <param name="isRead">
        /// Indicates whether the news item should be marked as read.
        /// </param>
        /// <returns>
        /// The id of the newly inserted news item.
        /// </returns>
        private int StoreNewsItem(NewsMaterial newsMaterial, int newsId,
            int categoryId, int newsSourceId, int termCount, bool isRead)
        {
            // Save the news item.
            if (newsId != -1)
            {
                // Add the values.
                StoreNewsItemCmd1.Parameters["p1"].Value = newsMaterial.Guid;
                StoreNewsItemCmd1.Parameters["p2"].Value = newsMaterial.Title;
                StoreNewsItemCmd1.Parameters["p3"].Value = newsMaterial.Summary;
                StoreNewsItemCmd1.Parameters["p4"].Value = newsMaterial.Author;
                StoreNewsItemCmd1.Parameters["p5"].Value = newsMaterial.Publisher;
                StoreNewsItemCmd1.Parameters["p6"].Value = newsMaterial.Date;
                StoreNewsItemCmd1.Parameters["p7"].Value = newsMaterial.Url.OriginalString;
                StoreNewsItemCmd1.Parameters["p8"].Value = categoryId;
                StoreNewsItemCmd1.Parameters["p10"].Value = termCount;
                StoreNewsItemCmd1.Parameters["p11"].Value = DateTime.Now;
                StoreNewsItemCmd1.Parameters["p12"].Value = newsId;

                // Add the news source depending on whether or not it exists.
                if (newsSourceId == -1)
                {
                    StoreNewsItemCmd1.Parameters["p9"].Value = DBNull.Value;
                }
                else
                {
                    StoreNewsItemCmd1.Parameters["p9"].Value = newsSourceId;
                }

                StoreNewsItemCmd1.ExecuteNonQuery();
            }
            else
            {
                // Add the values.
                StoreNewsItemCmd2.Parameters["p1"].Value = newsMaterial.Guid;
                StoreNewsItemCmd2.Parameters["p2"].Value = newsMaterial.Title;
                StoreNewsItemCmd2.Parameters["p3"].Value = newsMaterial.Summary;
                StoreNewsItemCmd2.Parameters["p4"].Value = newsMaterial.Author;
                StoreNewsItemCmd2.Parameters["p5"].Value = newsMaterial.Publisher;
                StoreNewsItemCmd2.Parameters["p6"].Value = newsMaterial.Date;
                StoreNewsItemCmd2.Parameters["p7"].Value = isRead;
                StoreNewsItemCmd2.Parameters["p8"].Value = newsMaterial.Url.OriginalString;
                StoreNewsItemCmd2.Parameters["p9"].Value = categoryId;
                StoreNewsItemCmd2.Parameters["p11"].Value = termCount;
                StoreNewsItemCmd2.Parameters["p12"].Value = DateTime.Now;
                StoreNewsItemCmd2.Parameters["p13"].Value = DateTime.Now;

                // Add the news source depending on whether or not it exists.
                if (newsSourceId == -1)
                {
                    StoreNewsItemCmd2.Parameters["p10"].Value = DBNull.Value;
                }
                else
                {
                    StoreNewsItemCmd2.Parameters["p10"].Value = newsSourceId;
                }

                StoreNewsItemCmd2.ExecuteNonQuery();
            }

            // Get the id of the newly inserted news item.
            StoreNewsItemCmd3.Parameters["p1"].Value = newsMaterial.Guid;

            // Read the id.
            SqlCeDataReader rdr = StoreNewsItemCmd3.ExecuteReader();
            if (rdr.Read())
            {
                newsId = rdr.GetInt32(0);
            }

            rdr.Close();

            return newsId;
        }
Exemplo n.º 7
0
        public void RedundancyFilterRedundantNotRedundant()
        {
            NewsMaterial news1 = new NewsMaterial();
            news1.Author = "author";
            news1.Content = "Ohio Cleveland abductions: three women missing for a decade found alive in Ohio Amanda Berry, Gina DeJesus and Michelle Knight, as well as a six-year-old, found in a house a few miles from where they disappeared Link to video: Amanda Berry and two other missing women found alive Three women who went missing separately about a decade ago in Cleveland, Ohio , have been found alive in a house a few miles away from where they disappeared. A neighbour said he let one of the women out of the house just south of downtown after he heard her screaming on Monday. In a recorded emergency call, the freed woman told the dispatcher: \"I'm Amanda Berry. I've been on the news for the last 10 years.\" Amanda Berry (right) reunited with her sister after being found in Cleveland, Ohio. Photograph: AFP/Getty Images She said the person who had taken her had gone out. \"I've been kidnapped, and I've been missing for 10 years,\" she said. \"And I'm here. I'm free now.\" Police found two other missing women in the house – Gina DeJesus and Michelle Knight – as well as a six-year-old child. They have not revealed the child's identity or relationship to anyone in the house. The women appeared to be in good health and were taken to a hospital to be assessed and to be reunited with relatives. Three brothers have been arrested. House in Seymour Avenue, Cleveland, where Amanda Berry, Gina DeJesus and Michelle Knight were found. Photograph: Scott Shaw/AP Berry was 16 when she disappeared on 21 April 2003 after calling her sister to say she was getting a ride home from the Burger King fast-food restaurant where she worked. DeJesus was 14 when she went missing on her way home from school about a year later. Police said Knight went missing in 2002 and is now 32. The three women had probably been tied up while in captivity, police said. Crowds gathered on Monday night near the home where the city's police chief said the women had been held since they went missing. Link to video: Charles Ramsey describes Amanda Berry rescue Police said one of the brothers arrested, a 52-year-old, lived at the house, while the others, aged 50 and 54, lived elsewhere. They did not release any names. Julio Castro, who runs a store half a block from where the women were found, said the arrested homeowner was his nephew, Ariel Castro, who had worked as a school bus driver. Berry also identified Ariel Castro by name in her emergency call, according to  Associated Press. The women's friends and relatives said they had not given up hope of seeing them again. A childhood friend of DeJesus, Kayla Rogers, told the Plain Dealer newspaper: \"I've been praying, never forgot about her, ever.\" Berry's cousin Tasheena Mitchell told the newspaper she could not wait to have her in her arms. \"I'm going to hold her, and I'm going to squeeze her, and I probably won't let her go,\" she said. Amanda Berry and Gina DeJesus are pictured in this combination photograph in undated handout photos released by the FBI. Photograph: Reuters Berry's mother, Louwana Miller, who had been in hospital for months with pancreatitis and other ailments, died in March 2006. She had spent the previous three years looking for her daughter, whose disappearance took a toll as her health steadily deteriorated, family and friends said. City councillor Dona Brady said she had spent many hours with Miller, who never gave up hope that her daughter was alive. \"She literally died of a broken heart,\" Brady said.";
            news1.Date = DateTime.Now;
            news1.Guid = "guid1";
            news1.Publisher = "publisher";
            news1.Url = new Uri("http://www.foo.bar");
            news1.Summary = "summary";
            news1.Title = "Ohio Cleveland abductions: three women missing for a decade found alive in Ohio";
            Archivist.AddNews(news1);

            // Get all news.
            NewsQuery query = new NewsQuery();
            query.NewerThan = DateTime.Now.Subtract(new TimeSpan(1, 0, 0));
            query.Limit = 1;
            List<NewsItem> news = Archivist.GetNews(query);

            // Filter.
            List<NewsItem> result = Filter.Filter(Archivist, news);
            // Expect the same list.
            List<NewsItem> expected = new List<NewsItem> { result[0] };

            CollectionAssert.AreEquivalent(expected, result);
        }
        /// <summary>
        /// Generates <c>NewsMaterial</c> for the test.
        /// </summary>
        /// <param name="sports">
        /// <c>true</c> if the generated news should be sports, <c>false</c>
        /// if business.
        /// </param>
        /// <returns>
        /// Some procedurally generated <c>NewsMaterial</c>.
        /// </returns>
        private static NewsMaterial GenerateNewsMaterial(bool sports)
        {
            // Create dummy NewsMaterial
            NewsMaterial material = new NewsMaterial();
            material.Author = "foo";
            material.Date = DateTime.Now;
            material.Guid = Guid.NewGuid().ToString();
            material.Publisher = "test";
            material.Source = new NewsSource("test", new Uri("http://www.foo.bar"));
            material.Summary = "";
            material.Title = "title";
            material.Url = new Uri("http://www.foo.bar");
            material.Content = GenerateRandomContent(sports);

            return material;
        }
Exemplo n.º 9
0
        public void CuratorTestInterestAndRedundancyAndQuantityFilter()
        {
            // Mark football interesting, tennis uninteresting.
            List<Category> categories = Archivist.GetCategories();
            int sportsId = categories.First(p => p.Name.Equals("sports")).Id;
            int politicsId = categories.First(p => p.Name.Equals("politics")).Id;

            Archivist.MarkCategoryInteresting(
                categories.First(p => p.Name.Equals("sports")), false);
            Archivist.MarkCategoryInteresting(
                categories.First(p => p.Name.Equals("politics")), true);

            // Add news to list.
            NewsMaterial news1 = new NewsMaterial();
            news1.Author = "author";
            news1.Content = "Manchester United manager Sir Alex Ferguson says David Luiz deliberately got Rafael sent off in Chelsea's 1-0 win at Old Trafford on Sunday. Rafael was sent off for a kick at his Brazil team-mate, but Ferguson feels Luiz engineered the dismissal. “He then rolls about like a dying swan, and that convinces the referee” Sir Alex Ferguson on David Luiz's reaction to Rafael's kick \" [Rafael] retaliates but [Luiz] quite clearly elbows him twice,\"  Ferguson told BBC's MOTD2 programme. \" He then rolls about like a dying swan, and that convinces the referee. He was smiling. That is bad.\"  Ferguson added: \" What kind of professional is that?\"  Chelsea interim manager Rafael Benitez said he did not see either Luiz's elbow or Rafael's retaliatory kick, but insisted such incidents were not unusual in football. \" I am not very interested,\"  he said. \" I have seen 200 incidents in the Premier League this year and it will change nothing.\"  A Phil Jones own goal in the 87th minute from a deflected Juan Mata shot gave Chelsea a victory that lifts them to third in the Premier League table, but Ferguson was disappointed by the lacklustre performance of his team. Why David Luiz is the long-pass master \" There is always an expectation that we should do better. We expected a better performance. After the goal we had no time to get back in the game,\"  he said. Ferguson made five changes to the side that drew 1-1 with Arsenal at Emirates Stadium last week, with Ryan Giggs, Anderson and Tom Cleverley all starting and Wayne Rooney dropping to the bench. However, the United manager said the changes were no excuse for such a below-par performance against highly motivated opponents hoping to secure a Champions League place. \" It was difficult for players coming in. Chelsea had everything to play for. They [some of our players] haven't played for quite a while, but that being said, we should be doing better,\"  he said. Also related to this story";
            news1.Date = DateTime.Now;
            news1.Guid = "guid1";
            news1.Publisher = "publisher";
            news1.Url = new Uri("http://www.foo.bar");
            news1.Summary = "summary";
            news1.Title = "Sir Alex Ferguson accuses David Luiz of getting Rafael sent off";
            Archivist.AddNews(news1, sportsId);

            NewsMaterial news2 = new NewsMaterial();
            news2.Author = "author";
            news2.Content = "Robin van Persie is April's Premier League Player of the Month Robin van Persie, recently overlooked for two major awards, has been named as Barclays Player of the Month for April. Bale also fought off Van Persie to land the PFA Player of the Year award. The Dutchman's six goals in April helped United to secure their 20th league title with four games to spare. Van Persie, 29, has hit 25 league goals since moving from Arsenal for £24m last August. His hat-trick in the 3-0 win against Aston Villa on 22 April saw United clinch the title ahead of Manchester City, who tried to sign Van Persie last summer. Earlier this season, City boss Roberto Mancini said his failure to land Van Persie was the difference between the two teams in the title race. United boss Sir Alex Ferguson said: \"I remember Arsenal manager Arsene Wenger saying to me 'he's better than you think' when we concluded the deal. He was right.\" Also related to this story";
            news2.Date = DateTime.Now;
            news2.Guid = "guid2";
            news2.Publisher = "publisher";
            news2.Url = new Uri("http://www.foo.bar");
            news2.Summary = "summary";
            news2.Title = "Robin van Persie is April's Premier League Player of the Month";
            Archivist.AddNews(news2, sportsId);

            NewsMaterial news3 = new NewsMaterial();
            news3.Author = "author";
            news3.Content = "Former Tory chancellor Lord Lawson calls for UK to exit EU   The former chancellor of the exchequer, Lord Lawson, has called for the UK to leave the European Union. Writing in the Times, he said British economic gains from an exit \"would substantially outweigh the costs\". He predicted any changes achieved by David Cameron's attempts to renegotiate the terms of the UK's relations with the EU would be \"inconsequential\". But Downing Street said the prime minister remained \"confident\" that his strategy \"will deliver results\". Mr Cameron is facing calls to bring forward a promised referendum on the UK's EU membership. He says he will hold a vote early in the next parliament - should the Conservatives win the next general election - but only after renegotiating the terms of the UK's relationship with the EU. However, Lord Lawson said any such renegotiations would be \"inconsequential\" as \"any powers ceded by the member states to the EU are ceded irrevocably\". The BBC's political editor Nick Robinson said Lord Lawson's intervention was a \"big moment\" in the EU debate. Regulatory 'frenzy' The peer - who was Margaret Thatcher's chancellor for six years - voted to stay in the European Common Market, as the EU was known in 1975, but said: \"I shall be voting 'out' in 2017.\" He said he \"strongly\" suspected there would be a \"positive economic advantage to the UK in leaving the single market\". Continue reading the main story “Start Quote You do not need to be within the single market to be able to export to the European Union, as we see from the wide range of goods on our shelves every day” End Quote Lord Lawson Far from hitting business hard, it would instead be a wake-up call for those who had been too content in \"the warm embrace of the European single market\" when the great export opportunities lay in the developing world, particularly Asia. \"Over the past decade, UK exports to the EU have risen in cash terms by some 40%. Over the same period, exports to the EU from those outside it have risen by 75%,\" he added. Withdrawing from the EU would also save the City of London from a \"frenzy of regulatory activism\", such as the financial transactions tax that Brussels is seeking to impose. Lord Lawson said his argument had \"nothing to do with being anti-European\". \"The heart of the matter is that the very nature of the European Union, and of this country's relationship with it, has fundamentally changed after the coming into being of the European monetary union and the creation of the eurozone, of which - quite rightly - we are not a part. \"Not only do our interests increasingly differ from those of the eurozone members but, while never 'at the heart of Europe' (as our political leaders have from time to time foolishly claimed), we are now becoming increasingly marginalised as we are doomed to being consistently outvoted by the eurozone bloc.\" 'Clear timetable' At the local elections last week, the UK Independence Party - which campaigns for the UK to leave the EU - made substantial gains, while the Conservatives lost control of 10 councils. The UKIP surge prompted a call from senior Tory MP David Davis to bring forward the planned referendum - while other Conservatives, including former chairman Lord Tebbit, urged Mr Cameron to take steps to give the public more confidence that a referendum would indeed take place if he wins the next general election. Reacting to Lord Lawson's comments, a Downing Street spokesman said: \"The PM has always been clear: we need a Europe that is more open, more competitive, and more flexible; a Europe that wakes up to the modern world of competition. In short, Europe has to reform. \"But our continued membership must have the consent of the British people, which is why the PM has set out a clear timetable on this issue.\" Deputy Prime Minister Nick Clegg said that leaving the European Union would \"make us less safe because we cooperate in the European Union to go after criminal gangs that cross borders\". He said it could put 3m jobs at risk and made it difficult to deal with cross border threats like climate change and would also see Britain \"taken less seriously in Washington, Beijing, Tokyo\". Political commentator and Times' comment editor Tim Montgomerie told BBC Radio 4's Today programme the article would add fuel to the debate on Europe within the Conservative Party that Mr Cameron had hoped could wait until further down the line. \"Lord Lawson will give much more confidence to those people who do want to leave the EU to go public with those views,\" he added.  ";
            news3.Date = DateTime.Now;
            news3.Guid = "guid3";
            news3.Publisher = "publisher";
            news3.Url = new Uri("http://www.foo.bar");
            news3.Summary = "summary";
            news3.Title = "Former Tory chancellor Lord Lawson calls for UK to exit EU";
            Archivist.AddNews(news3, politicsId);

            NewsMaterial news4 = new NewsMaterial();
            news4.Author = "author";
            news4.Content = "David Cameron to host Somalia conference Suicide bombs remain a constant threat in Somalia Connecting capital UK Prime Minister David Cameron is to host an international conference in London to help Somalia end more than two decades of conflict. The conference will focus on rebuilding its security forces and tackling rape - a largely taboo subject in Somalia. Somalia is widely regarded as a failed state, hit by an Islamist insurgency, piracy and a famine from 2010 to 2012. At least seven people were killed in a car bomb attack in the capital, Mogadishu, on Sunday. Al-Shabab, which is part of al-Qaeda, said it carried out the attack. Tuesday's meeting - which Mr Cameron will co-host with Somalia's President Hassan Sheikh Mohamud - follows similar conferences in London and the Turkish city of  Istanbul last year, amid growing international concern that Somalia has turned into a haven for al-Qaeda-linked militants. 'Dramatic change' \"I hope we can all get behind a long-term security plan - one that ends the Shabab's reign of terror forever,\" Mr Cameron said. Analysis Andrew Harding Africa correspondent A year ago, Afgoye was under the control of Somalia's Islamist militant group, al-Shabab, which held most of the countryside beyond Mogadishu. But if they have lost control of many key towns these days, al-Shabab can still cause trouble. Minutes after I'd flown into Mogadishu, a car bomb exploded up the road at a busy roundabout, killing or injuring more than 30 people. Read more from Andrew \"I also hope we can improve transparency and accountability so people know where resources are going. We also need to continue the process of rebuilding the Somali state, with all the regions of Somalia around the table and the neighbouring countries too.\" BBC Somalia analyst Mary Harper says there has been a dramatic change in the country in the past year. There is a new government - the first one in more than two decades to be recognised by the United States, the International Monetary Fund (IMF) and other key players, she says. Al-Shabab has lost control of the major towns, pirate attacks off the Somali coast have fallen dramatically and the famine, which the United Nations estimates claimed nearly 260,000 lives, is over, she adds. However, massive challenges remain, as al-Shabab still has the capacity to carry out attacks and the government depends on about 18,000 African Union (AU) troops for its security, our correspondent says. Somalia is also divided into a patchwork of self-governing regions, many of them hostile to the central government. The breakaway state of Somaliland and the semi-autonomous region of Puntland say they will boycott the conference. The conference will address an issue that was until recently completely taboo in Somalia - rape, especially of women living in camps for displaced people, our correspondent says. Somali aid worker Halima Ali Adan told the BBC the decision to tackle the issue at the conference was a big step forward. \"Sexual violence is something that was not ever spoken about in Somalia,\" she said. \"The international community themselves have seen the importance of this issue to be addressed as soon as possible because it is actually overwhelming.\" Delegates from more than 50 countries and organisations are expected to attend the meeting. On Monday, Qatar said Sunday's suicide attack in Mogadishu had targeted its officials, Qatar's official QNA news agency reported. The four officials were travelling in armoured vehicles belonging to the Somali government when the convoy was attacked, it said. None of the Qatari nationals were injured, QNA reported. However,  10 other people were wounded in the attack, according to a BBC correspondent in Mogadishu. More on This Story";
            news4.Date = DateTime.Now;
            news4.Guid = "guid4";
            news4.Publisher = "publisher";
            news4.Url = new Uri("http://www.foo.bar");
            news4.Summary = "summary";
            news4.Title = "David Cameron to host Somalia conference";
            Archivist.AddNews(news4, politicsId);

            // Add redundant news items to db.
            NewsMaterial news5 = new NewsMaterial();
            news5.Author = "author";
            news5.Content = "Ohio Cleveland abductions: three women missing for a decade found alive in Ohio Amanda Berry, Gina DeJesus and Michelle Knight, as well as a six-year-old, found in a house a few miles from where they disappeared Link to video: Amanda Berry and two other missing women found alive Three women who went missing separately about a decade ago in Cleveland, Ohio , have been found alive in a house a few miles away from where they disappeared. A neighbour said he let one of the women out of the house just south of downtown after he heard her screaming on Monday. In a recorded emergency call, the freed woman told the dispatcher: \"I'm Amanda Berry. I've been on the news for the last 10 years.\" Amanda Berry (right) reunited with her sister after being found in Cleveland, Ohio. Photograph: AFP/Getty Images She said the person who had taken her had gone out. \"I've been kidnapped, and I've been missing for 10 years,\" she said. \"And I'm here. I'm free now.\" Police found two other missing women in the house – Gina DeJesus and Michelle Knight – as well as a six-year-old child. They have not revealed the child's identity or relationship to anyone in the house. The women appeared to be in good health and were taken to a hospital to be assessed and to be reunited with relatives. Three brothers have been arrested. House in Seymour Avenue, Cleveland, where Amanda Berry, Gina DeJesus and Michelle Knight were found. Photograph: Scott Shaw/AP Berry was 16 when she disappeared on 21 April 2003 after calling her sister to say she was getting a ride home from the Burger King fast-food restaurant where she worked. DeJesus was 14 when she went missing on her way home from school about a year later. Police said Knight went missing in 2002 and is now 32. The three women had probably been tied up while in captivity, police said. Crowds gathered on Monday night near the home where the city's police chief said the women had been held since they went missing. Link to video: Charles Ramsey describes Amanda Berry rescue Police said one of the brothers arrested, a 52-year-old, lived at the house, while the others, aged 50 and 54, lived elsewhere. They did not release any names. Julio Castro, who runs a store half a block from where the women were found, said the arrested homeowner was his nephew, Ariel Castro, who had worked as a school bus driver. Berry also identified Ariel Castro by name in her emergency call, according to  Associated Press. The women's friends and relatives said they had not given up hope of seeing them again. A childhood friend of DeJesus, Kayla Rogers, told the Plain Dealer newspaper: \"I've been praying, never forgot about her, ever.\" Berry's cousin Tasheena Mitchell told the newspaper she could not wait to have her in her arms. \"I'm going to hold her, and I'm going to squeeze her, and I probably won't let her go,\" she said. Amanda Berry and Gina DeJesus are pictured in this combination photograph in undated handout photos released by the FBI. Photograph: Reuters Berry's mother, Louwana Miller, who had been in hospital for months with pancreatitis and other ailments, died in March 2006. She had spent the previous three years looking for her daughter, whose disappearance took a toll as her health steadily deteriorated, family and friends said. City councillor Dona Brady said she had spent many hours with Miller, who never gave up hope that her daughter was alive. \"She literally died of a broken heart,\" Brady said.";
            news5.Date = DateTime.Now;
            news5.Guid = "guid1";
            news5.Publisher = "publisher";
            news5.Url = new Uri("http://www.foo.bar");
            news5.Summary = "summary";
            news5.Title = "Ohio Cleveland abductions: three women missing for a decade found alive in Ohio";
            Archivist.AddNews(news5, politicsId, false);

            NewsMaterial news6 = new NewsMaterial();
            news6.Author = "author";
            news6.Content = "Three US women missing for years rescued in Ohio A neighbour, Charles Ramsey, tells reporters: \"We had to kick open the bottom of the door\" Police: 'It's a great day' Watch Three young women who vanished in separate incidents about a decade ago in the US state of Ohio have been found alive in a house in Cleveland. Amanda Berry disappeared aged 16 in 2003, Gina DeJesus went missing aged 14 a year later, and Michelle Knight disappeared in 2002 aged around 19. Their discovery followed a dramatic bid for freedom by Amanda Berry on Monday, helped by a neighbour. Three brothers have been arrested in connection with the case. Cleveland police said the suspects are Hispanic, aged 50, 52 and 54, and one of them had lived at the house on Seymour Avenue. One was named as Ariel Castro, who has worked as a school bus driver. Police have said a six-year-old was also found at the home. They have not revealed any further details, although a relative of Amanda Berry said she told him she had a daughter. The women's families reacted with shock and delight at news of their discovery, and many people gathered outside the home where they had allegedly been imprisoned. \"It's been a whirlwind kind of day. It's surreal,\" said Gina DeJesus' relative, Sylvia Colon. She said the family had never given up hope, holding vigils every year and keeping memorials outside the house. \"We were living every day in the hope she would come home - and she did,\" she told the BBC. Ms Colon said the women would now \"need to be given some space. They have been away from us for a very long time.\" A doctor said the three women were in a fair condition and were being kept in hospital for observation. To cheers from spectators, Dr Gerald Maloney told reporters outside Metro Health hospital in Cleveland that the women were able to speak to hospital staff, but he declined to give further details. The disappearances of Amanda Berry and Gina DeJesus had been big news in Cleveland, and many had assumed them to be dead. Little was made of the disappearance of Michelle Knight, who was older than the other two girls. Gina DeJesus' aunt Sandra Ruiz: \"She knew we were looking for her\" Her grandmother, Deborah Knight, was quoted by the Cleveland Plain Dealer newspaper on Monday as saying that the authorities concluded she had run away. 'Here a long time' The dramatic events unfolded after Amanda Berry attempted to flee the house when her alleged captor went out. Neighbour Charles Ramsey said he heard screaming. \"I see this girl going nuts trying to get outside,\" he told reporters. He said he suggested the woman open the door and exit, but she told him it was locked. \"We had to kick open the bottom,\" he said. \"Lucky on that door it was aluminium. It was cheap. She climbed out with her daughter.\" Both Mr Ramsey and Ms Berry called 911. In her frantic call, released to the news media, Ms Berry told the operator: \"I'm Amanda Berry. I've been kidnapped. I've been missing for 10 years. I'm free. I'm here now.\" She identified her kidnapper as Ariel Castro and said other women were in the house. Anthony confirmed to a journalist that he had written about the neighbourhood's heightened concern for safety in the Cleveland Plain Press , and told her that Monday's developments were \"beyond comprehension\". Charles Ramsey's 911 call after he helped free Amanda Berry \"He was stunned that something like this could possible happen,\" WKYC reporter Sara Shookman told CNN. Cleveland Mayor Frank Jackson has said an investigation into the \"many unanswered questions regarding this case\" will be held. High-profile cases Ms Berry was last heard from when she called her sister on 21 April 2003 to say she would get a lift home from work at a Burger King restaurant. In 2004, Ms DeJesus was said to be on her way home from school when she went missing. Their cases were re-opened last year when a prison inmate tipped off authorities that Ms Berry may have been buried in Cleveland. He received a four-and-a-half-year sentence in prison for the false information. Amanda Berry's mother, Louwana, died in March 2006, three years after her daughter's disappearance. Although much is still not yet known about this case, it recalled a series of recent high-profile child abduction cases. Jaycee Lee Dugard was 11 years old when she was dragged into a car as she walked to a bus stop near her home in South Lake Tahoe, California in 1991. Photos of Berry (left) and DeJesus were distributed widely after they went missing She was discovered in August 2009, having spent 18 years held captive in the backyard of  Phillip and Nancy Garrido in Antioch, some 170 miles from South Lake Tahoe. She had two children. In Austria, Natascha Kampusch was abducted on her way to school at the age of 10. She was held for eight years by Wolfgang Priklopil in the windowless basement of a house in a quiet suburb of Vienna. She managed to escape in 2006 while Priklopil was making a phone call. He committed suicide hours after she had fled. Elizabeth Smart was 14 when she was taken from the bedroom of her Utah home in June 2002 and repeatedly raped during nine months of captivity. She was rescued in March 2003 less than 20 miles from her home. Her abductor, Brian David Mitchell, was jailed for life in 2011. Are you from the Cleveland area? Do you know any of the people involved in this story? Please leave your comments using the form below (Required) Name";
            news6.Date = DateTime.Now;
            news6.Guid = "guid2";
            news6.Publisher = "publisher";
            news6.Url = new Uri("http://www.foo.bar");
            news6.Summary = "summary";
            news6.Title = "Three US women missing for years rescued in Ohio";
            int redundantId = Archivist.AddNews(news6, politicsId, false);

            // Get expected inserted news items.
            NewsQuery query = new NewsQuery();
            query.Read = ReadStatus.Unread;
            query.CategoryId = politicsId;
            List<NewsItem> expected = Archivist.GetNews(query);
            // Remove redundant news item.
            expected.Remove(expected.First(p => p.Id == redundantId));

            List<NewsItem> result = Curator.GetCuratedNews(Archivist, 100, 6, 3);

            // Expect a list of size two because of quantity filtering.
            Assert.AreEqual(2, result.Count);
        }
Exemplo n.º 10
0
        public void CuratorTestInterestFilter()
        {
            // Mark football interesting, tennis uninteresting.
            List<Category> categories = Archivist.GetCategories();
            int sportsId = categories.First(p => p.Name.Equals("sports")).Id;
            int politicsId = categories.First(p => p.Name.Equals("politics")).Id;

            Archivist.MarkCategoryInteresting(
                categories.First(p => p.Name.Equals("sports")), true);
            Archivist.MarkCategoryInteresting(
                categories.First(p => p.Name.Equals("politics")), false);

            // Add news to list.
            NewsMaterial news1 = new NewsMaterial();
            news1.Author = "author";
            news1.Content = "Manchester United manager Sir Alex Ferguson says David Luiz deliberately got Rafael sent off in Chelsea's 1-0 win at Old Trafford on Sunday. Rafael was sent off for a kick at his Brazil team-mate, but Ferguson feels Luiz engineered the dismissal. “He then rolls about like a dying swan, and that convinces the referee” Sir Alex Ferguson on David Luiz's reaction to Rafael's kick \" [Rafael] retaliates but [Luiz] quite clearly elbows him twice,\"  Ferguson told BBC's MOTD2 programme. \" He then rolls about like a dying swan, and that convinces the referee. He was smiling. That is bad.\"  Ferguson added: \" What kind of professional is that?\"  Chelsea interim manager Rafael Benitez said he did not see either Luiz's elbow or Rafael's retaliatory kick, but insisted such incidents were not unusual in football. \" I am not very interested,\"  he said. \" I have seen 200 incidents in the Premier League this year and it will change nothing.\"  A Phil Jones own goal in the 87th minute from a deflected Juan Mata shot gave Chelsea a victory that lifts them to third in the Premier League table, but Ferguson was disappointed by the lacklustre performance of his team. Why David Luiz is the long-pass master \" There is always an expectation that we should do better. We expected a better performance. After the goal we had no time to get back in the game,\"  he said. Ferguson made five changes to the side that drew 1-1 with Arsenal at Emirates Stadium last week, with Ryan Giggs, Anderson and Tom Cleverley all starting and Wayne Rooney dropping to the bench. However, the United manager said the changes were no excuse for such a below-par performance against highly motivated opponents hoping to secure a Champions League place. \" It was difficult for players coming in. Chelsea had everything to play for. They [some of our players] haven't played for quite a while, but that being said, we should be doing better,\"  he said. Also related to this story";
            news1.Date = DateTime.Now;
            news1.Guid = "guid1";
            news1.Publisher = "publisher";
            news1.Url = new Uri("http://www.foo.bar");
            news1.Summary = "summary";
            news1.Title = "Sir Alex Ferguson accuses David Luiz of getting Rafael sent off";
            Archivist.AddNews(news1, sportsId);

            NewsMaterial news2 = new NewsMaterial();
            news2.Author = "author";
            news2.Content = "Robin van Persie is April's Premier League Player of the Month Robin van Persie, recently overlooked for two major awards, has been named as Barclays Player of the Month for April. Bale also fought off Van Persie to land the PFA Player of the Year award. The Dutchman's six goals in April helped United to secure their 20th league title with four games to spare. Van Persie, 29, has hit 25 league goals since moving from Arsenal for £24m last August. His hat-trick in the 3-0 win against Aston Villa on 22 April saw United clinch the title ahead of Manchester City, who tried to sign Van Persie last summer. Earlier this season, City boss Roberto Mancini said his failure to land Van Persie was the difference between the two teams in the title race. United boss Sir Alex Ferguson said: \"I remember Arsenal manager Arsene Wenger saying to me 'he's better than you think' when we concluded the deal. He was right.\" Also related to this story";
            news2.Date = DateTime.Now;
            news2.Guid = "guid2";
            news2.Publisher = "publisher";
            news2.Url = new Uri("http://www.foo.bar");
            news2.Summary = "summary";
            news2.Title = "Robin van Persie is April's Premier League Player of the Month";
            Archivist.AddNews(news2, sportsId);

            NewsMaterial news3 = new NewsMaterial();
            news3.Author = "author";
            news3.Content = "Former Tory chancellor Lord Lawson calls for UK to exit EU   The former chancellor of the exchequer, Lord Lawson, has called for the UK to leave the European Union. Writing in the Times, he said British economic gains from an exit \"would substantially outweigh the costs\". He predicted any changes achieved by David Cameron's attempts to renegotiate the terms of the UK's relations with the EU would be \"inconsequential\". But Downing Street said the prime minister remained \"confident\" that his strategy \"will deliver results\". Mr Cameron is facing calls to bring forward a promised referendum on the UK's EU membership. He says he will hold a vote early in the next parliament - should the Conservatives win the next general election - but only after renegotiating the terms of the UK's relationship with the EU. However, Lord Lawson said any such renegotiations would be \"inconsequential\" as \"any powers ceded by the member states to the EU are ceded irrevocably\". The BBC's political editor Nick Robinson said Lord Lawson's intervention was a \"big moment\" in the EU debate. Regulatory 'frenzy' The peer - who was Margaret Thatcher's chancellor for six years - voted to stay in the European Common Market, as the EU was known in 1975, but said: \"I shall be voting 'out' in 2017.\" He said he \"strongly\" suspected there would be a \"positive economic advantage to the UK in leaving the single market\". Continue reading the main story “Start Quote You do not need to be within the single market to be able to export to the European Union, as we see from the wide range of goods on our shelves every day” End Quote Lord Lawson Far from hitting business hard, it would instead be a wake-up call for those who had been too content in \"the warm embrace of the European single market\" when the great export opportunities lay in the developing world, particularly Asia. \"Over the past decade, UK exports to the EU have risen in cash terms by some 40%. Over the same period, exports to the EU from those outside it have risen by 75%,\" he added. Withdrawing from the EU would also save the City of London from a \"frenzy of regulatory activism\", such as the financial transactions tax that Brussels is seeking to impose. Lord Lawson said his argument had \"nothing to do with being anti-European\". \"The heart of the matter is that the very nature of the European Union, and of this country's relationship with it, has fundamentally changed after the coming into being of the European monetary union and the creation of the eurozone, of which - quite rightly - we are not a part. \"Not only do our interests increasingly differ from those of the eurozone members but, while never 'at the heart of Europe' (as our political leaders have from time to time foolishly claimed), we are now becoming increasingly marginalised as we are doomed to being consistently outvoted by the eurozone bloc.\" 'Clear timetable' At the local elections last week, the UK Independence Party - which campaigns for the UK to leave the EU - made substantial gains, while the Conservatives lost control of 10 councils. The UKIP surge prompted a call from senior Tory MP David Davis to bring forward the planned referendum - while other Conservatives, including former chairman Lord Tebbit, urged Mr Cameron to take steps to give the public more confidence that a referendum would indeed take place if he wins the next general election. Reacting to Lord Lawson's comments, a Downing Street spokesman said: \"The PM has always been clear: we need a Europe that is more open, more competitive, and more flexible; a Europe that wakes up to the modern world of competition. In short, Europe has to reform. \"But our continued membership must have the consent of the British people, which is why the PM has set out a clear timetable on this issue.\" Deputy Prime Minister Nick Clegg said that leaving the European Union would \"make us less safe because we cooperate in the European Union to go after criminal gangs that cross borders\". He said it could put 3m jobs at risk and made it difficult to deal with cross border threats like climate change and would also see Britain \"taken less seriously in Washington, Beijing, Tokyo\". Political commentator and Times' comment editor Tim Montgomerie told BBC Radio 4's Today programme the article would add fuel to the debate on Europe within the Conservative Party that Mr Cameron had hoped could wait until further down the line. \"Lord Lawson will give much more confidence to those people who do want to leave the EU to go public with those views,\" he added.  ";
            news3.Date = DateTime.Now;
            news3.Guid = "guid3";
            news3.Publisher = "publisher";
            news3.Url = new Uri("http://www.foo.bar");
            news3.Summary = "summary";
            news3.Title = "Former Tory chancellor Lord Lawson calls for UK to exit EU";
            Archivist.AddNews(news3, politicsId);

            NewsMaterial news4 = new NewsMaterial();
            news4.Author = "author";
            news4.Content = "David Cameron to host Somalia conference Suicide bombs remain a constant threat in Somalia Connecting capital UK Prime Minister David Cameron is to host an international conference in London to help Somalia end more than two decades of conflict. The conference will focus on rebuilding its security forces and tackling rape - a largely taboo subject in Somalia. Somalia is widely regarded as a failed state, hit by an Islamist insurgency, piracy and a famine from 2010 to 2012. At least seven people were killed in a car bomb attack in the capital, Mogadishu, on Sunday. Al-Shabab, which is part of al-Qaeda, said it carried out the attack. Tuesday's meeting - which Mr Cameron will co-host with Somalia's President Hassan Sheikh Mohamud - follows similar conferences in London and the Turkish city of  Istanbul last year, amid growing international concern that Somalia has turned into a haven for al-Qaeda-linked militants. 'Dramatic change' \"I hope we can all get behind a long-term security plan - one that ends the Shabab's reign of terror forever,\" Mr Cameron said. Analysis Andrew Harding Africa correspondent A year ago, Afgoye was under the control of Somalia's Islamist militant group, al-Shabab, which held most of the countryside beyond Mogadishu. But if they have lost control of many key towns these days, al-Shabab can still cause trouble. Minutes after I'd flown into Mogadishu, a car bomb exploded up the road at a busy roundabout, killing or injuring more than 30 people. Read more from Andrew \"I also hope we can improve transparency and accountability so people know where resources are going. We also need to continue the process of rebuilding the Somali state, with all the regions of Somalia around the table and the neighbouring countries too.\" BBC Somalia analyst Mary Harper says there has been a dramatic change in the country in the past year. There is a new government - the first one in more than two decades to be recognised by the United States, the International Monetary Fund (IMF) and other key players, she says. Al-Shabab has lost control of the major towns, pirate attacks off the Somali coast have fallen dramatically and the famine, which the United Nations estimates claimed nearly 260,000 lives, is over, she adds. However, massive challenges remain, as al-Shabab still has the capacity to carry out attacks and the government depends on about 18,000 African Union (AU) troops for its security, our correspondent says. Somalia is also divided into a patchwork of self-governing regions, many of them hostile to the central government. The breakaway state of Somaliland and the semi-autonomous region of Puntland say they will boycott the conference. The conference will address an issue that was until recently completely taboo in Somalia - rape, especially of women living in camps for displaced people, our correspondent says. Somali aid worker Halima Ali Adan told the BBC the decision to tackle the issue at the conference was a big step forward. \"Sexual violence is something that was not ever spoken about in Somalia,\" she said. \"The international community themselves have seen the importance of this issue to be addressed as soon as possible because it is actually overwhelming.\" Delegates from more than 50 countries and organisations are expected to attend the meeting. On Monday, Qatar said Sunday's suicide attack in Mogadishu had targeted its officials, Qatar's official QNA news agency reported. The four officials were travelling in armoured vehicles belonging to the Somali government when the convoy was attacked, it said. None of the Qatari nationals were injured, QNA reported. However,  10 other people were wounded in the attack, according to a BBC correspondent in Mogadishu. More on This Story";
            news4.Date = DateTime.Now;
            news4.Guid = "guid4";
            news4.Publisher = "publisher";
            news4.Url = new Uri("http://www.foo.bar");
            news4.Summary = "summary";
            news4.Title = "David Cameron to host Somalia conference";
            Archivist.AddNews(news4, politicsId);

            // Get expected inserted news items.
            NewsQuery query = new NewsQuery();
            query.Read = ReadStatus.Unread;
            query.CategoryId = sportsId;
            List<NewsItem> expected = Archivist.GetNews(query);

            List<NewsItem> result = Curator.GetCuratedNews(Archivist, 100);

            CollectionAssert.AreEqual(expected, result);
        }
Exemplo n.º 11
0
        public void ContentTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Content = "foo";

            Assert.AreEqual("foo", m.Content);
        }
Exemplo n.º 12
0
 public void EqualsTestObjectToNullReferenceEqualsOperator()
 {
     NewsMaterial o1 = new NewsMaterial();
     o1.Title = "foo";
     NewsMaterial o2 = null;
     Assert.IsFalse(o1 == o2);
 }
Exemplo n.º 13
0
        public void EqualsTestObjectReferenceEquality()
        {
            NewsMaterial o1 = new NewsMaterial();
            o1.Title = "foo";

            NewsMaterial o2 = new NewsMaterial();
            o2.Title = "foo";
            Assert.IsTrue(o1.Equals((Object) o2));
        }
Exemplo n.º 14
0
 public void EqualsTestNotEqualsOperator()
 {
     NewsMaterial o1 = new NewsMaterial();
     o1.Title = "foo";
     NewsMaterial o2 = new NewsMaterial();
     o2.Title = "bar"; ;
     Assert.IsTrue(o1 != o2);
 }
Exemplo n.º 15
0
 public void EqualsTestInequality()
 {
     NewsMaterial o1 = new NewsMaterial();
     o1.Title = "foo";
     NewsMaterial o2 = new NewsMaterial();
     o2.Title = "bar";
     Assert.IsFalse(o1.Equals(o2));
 }
Exemplo n.º 16
0
 public void EqualsTestGetHasCodesEquals()
 {
     NewsMaterial o1 = new NewsMaterial();
     o1.Title = "foo";
     NewsMaterial o2 = new NewsMaterial();
     o2.Title = "foo";
     Assert.AreEqual(o1.GetHashCode(), o2.GetHashCode());
 }
Exemplo n.º 17
0
        public void DateTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Date = DateTime.MaxValue;

            Assert.AreEqual(DateTime.MaxValue, m.Date);
        }
Exemplo n.º 18
0
        /// <summary>
        /// Adds a piece of news to the database using the details of the
        /// specified <c>NewsMaterial</c>.
        /// </summary>
        /// <param name="newsMaterial">
        /// The <c>NewsMaterial</c> from which to add the news to the database.
        /// </param>
        /// <param name="categoryId">
        /// The id of the category to add this news item to. -1 if the category
        /// is not known. Thus one will be determined for the news item.
        /// </param>
        /// <param name="isRead">
        /// Whether the news item should be marked as read or not.
        /// </param>
        /// <exception cref="ArgumentException">
        /// When the given <c>NewsMaterial</c> has null properties or when
        /// the url is larger than <c>NEWS_URL_SIZE</c>.
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// Thrown when the <c>Archivist</c> is not open upon 
        /// calling this method.
        /// </exception>
        /// <returns>
        /// The id of the newly inserted item.
        /// </returns>
        public override int AddNews(NewsMaterial newsMaterial, int categoryId = -1,
            bool isRead = false)
        {
            // Check that the database is open.
            if (!DatabaseConnection.State.Equals(ConnectionState.Open))
            {
                throw new InvalidOperationException(
                    "The Archivist must be open before calling this method. " +
                    "Call the Open() method.");
            }

            // Check input validity.
            if (newsMaterial.Url == null || newsMaterial.Date == null)
            {
                throw new ArgumentException(
                    "newsMaterial must have all properties that may be null set.",
                    "newsMaterial");
            }

            // Check if the url is too long.
            if (newsMaterial.Url.OriginalString.Length > NEWS_URL_SIZE)
            {
                throw new ArgumentException(
                    "The url of newsMaterial cannot be more than " +
                    NEWS_URL_SIZE + " chars long",
                    "newsMaterial");
            }

            // Insert the news material.
            int newsId = InsertNewsMaterial(newsMaterial, categoryId, isRead);

            // Update the idf values for all the terms in the database.
            UpdateIdfValues();

            return newsId;
        }
Exemplo n.º 19
0
 public void EqualsTestReferenceEquals()
 {
     NewsMaterial o1 = new NewsMaterial();
     o1.Title = "foo";
     NewsMaterial o2 = o1;
     Assert.IsTrue(o1.Equals(o2));
 }
Exemplo n.º 20
0
        public void GuidTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Guid = "foo";

            Assert.AreEqual("foo", m.Guid);
        }
Exemplo n.º 21
0
        public void AddNewsTestWithLongGuid()
        {
            // Add categories and news sources.
            foreach (Category c in Categories)
            {
                c.Id = Archivist.AddCategory(c.Name);
            }
            Archivist.AddNewsSources(NewsSources);

            // Create the news material.
            NewsMaterial n = new NewsMaterial()
            {
                Title = "Title",
                Summary = "Summary",
                Content = "Content",
                Author = "Author",
                Publisher = "Publisher",
                Url = new Uri("http://www.test.com/"),
                Date = new DateTime(2013, 4, 23, 12, 05, 00),
                Guid = TestHelpers.
                    GenerateLoremIpsum(SqlCeArchivist.NEWS_GUID_SIZE + 1)
            };

            // Add it.
            Archivist.AddNews(n);

            // Get all news items.
            List<NewsItem> gottenNewsItems = Archivist.GetNews(new NewsQuery());

            // Check that the news material was stored correctly.
            TestHelpers.AssertNewsMaterialEquivalent(n, gottenNewsItems.First());
        }
Exemplo n.º 22
0
        public void PublisherTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Publisher = "bar";

            Assert.AreEqual("bar", m.Publisher);
        }
Exemplo n.º 23
0
        public void CuratorTestQuantityFilterMaxTime()
        {
            // Add lots of news items to db.
            NewsMaterial news1 = new NewsMaterial();
            news1.Author = "author";
            news1.Content = "Cleveland 'kidnapper' Ariel Castro due in court Footage shows Ariel Castro being led away by police, as Paul Adams reports The man suspected of imprisoning three women for several years in the US city of Cleveland is due to make his first court appearance. Ariel Castro, 52, has been charged with kidnap and rape. The women were abducted at different times and held in a house in a suburban street for about a decade. One woman escaped on Monday and raised the alarm. The police detained two of Mr Castro's brothers, but later said they appeared to have no involvement in the crime. Ariel Castro owned the house from which Amanda Berry, 27, Gina DeJesus, 23, and Michelle Knight, 32, were rescued. Police said the women could only remember being outside twice during their time in captivity, and were then only allowed into the garage. Deputy police chief Ed Tomba said the women were not held in one room \"but they did know each other and they did know each other was there\". Emotional homecoming Ms Berry escaped on Monday along with her six-year-old daughter Jocelyn, who was born in captivity. A source told the BBC that one of the women was forced to help Ms Berry deliver her daughter, and was threatened with death if the child did not survive. In a news conference late on Wednesday, authorities said Mr Castro would be charged with four counts of kidnapping. The charges covered the three initial abduction victims and Jocelyn. Listen to the moment an officer radioed \"we found them, we found them\" from the house in Cleveland Mr Castro was also charged with three counts of rape, one against each woman. Police said more than 200 pieces of evidence had been taken from the home where the three women were held captive. They said interviews with the women had yielded enough information to charge Ariel Castro, and that further charges could be added. Police say Mr Castro has been co-operating with them, waiving his right to silence and agreeing to a test to establish Jocelyn's paternity. Ms Knight remains in hospital, while the other two women have been released to their families. On Wednesday hundreds of people gathered around the DeJesus family home, cheering as Gina DeJesus was brought from hospital. Ms DeJesus, wearing a bright yellow hooded shirt, was escorted into her home by a woman with her arm around her, giving the well-wishers a brief wave. Ms Berry and her daughter arrived at her sister's home shortly before midday on Wednesday. She disappeared in 2003 aged 16, but escaped on Monday with the help of a neighbour who heard her screaming and kicking a door while her alleged captor was out of the house. When police arrived, they also found Ms DeJesus and Ms Knight in the house. Ms DeJesus had gone missing aged 14 in 2004, while Ms Knight had disappeared in 2002, aged 20. Ariel Castro reportedly fled the neighbourhood and was arrested at a nearby McDonald's restaurant, according to local media. More on This Story Nasa's Curiosity rover to return to some classic sites Most Popular BBC Travel goes on the hunt for authentic Russian cuisine in Ulan-Ude Programmes";
            news1.Date = DateTime.Now;
            news1.Guid = "guid1";
            news1.Publisher = "publisher";
            news1.Url = new Uri("http://www.foo.bar");
            news1.Summary = "summary";
            news1.Title = "Cleveland 'kidnapper' Ariel Castro due in court";
            Archivist.AddNews(news1);

            NewsMaterial news2 = new NewsMaterial();
            news2.Author = "author";
            news2.Content = "Pakistan election: Sharif 'would end' war on terror role The BBC's Orla Guerin: \"Nawaz Sharif now confident of a comeback\" Secularists face militant threat The man tipped to be Pakistan's next prime minister, Nawaz Sharif, has said he would end the country's involvement in the US-led war on terror if elected. Mr Sharif told the BBC that the move was necessary for there to be peace in Pakistan and elsewhere in the world. Pakistan has been part of the US-led fight against Islamist militancy in the region since the 9/11 attacks. Voters in Pakistan are due to go to the polls on 11 May following an election run-up marred by violence. It is the first time in the country's history that an elected government will hand over power to another elected government. 'Lasting peace' The remarks by Mr Sharif, leader of the Pakistan Muslim League-N (PML-N), may cause concern among Western leaders, the BBC's Orla Guerin reports from Islamabad. Supporters of the PML-N have been attending election campaign rallies \"It's a matter of detail,\" he added. They fear it could lead to militants having greater freedom to operate in Pakistan, as foreign troops prepare to leave Afghanistan in 2014. One of the key questions for the West is how Pakistan's next prime minister will tackle militants on home soil, our correspondent says. Asked whether he would take Pakistan out of the war on terror, Mr Sharif said: \"Yes, we have to.\" But he declined to say whether he would stop military operations against the Taliban and al-Qaeda. The business magnate, who served as Pakistan's prime minister twice in the 1990s, said he wanted to work with other countries to find a lasting peace in the region. Meanwhile, there was further violence on Wednesday ahead of the elections. At least three people were killed and about 25 injured - including six policemen - in a suicide bombing outside a police station in the Bannu region of north-western Pakistan on Wednesday. Police said that it was not clear if the target was the police station itself or a nearby rally being held by the Awami National Party (ANP). The Pakistani Taliban have threatened to prevent the ANP, as well the Pakistan People's Party (PPP) and the MQM party, from conducting their election campaigns because they are considered by the militants to be too liberal. Meanwhile, doctors said on Wednesday that they expected Pakistani politician Imran Khan to make a full recovery despite fracturing his spine falling off a makeshift lift at a campaign rally. Are you in Pakistan? Who will you vote for? Send us your comments using the form below. (Required) Name";
            news2.Date = DateTime.Now;
            news2.Guid = "guid2";
            news2.Publisher = "publisher";
            news2.Url = new Uri("http://www.foo.bar");
            news2.Summary = "summary";
            news2.Title = "Three US women missing for years rescued in Ohio";
            Archivist.AddNews(news2);

            NewsMaterial news3 = new NewsMaterial();
            news3.Author = "author";
            news3.Content = "Elderly nun convicted in US nuclear site break-in Sister Megan, centre, said the site made \"that which can only cause death\" An elderly Catholic nun and two peace activists have been convicted for damage they caused while breaking into a US nuclear defence site. Sister Megan Rice, 83, Michael Walli, 64, and Greg Boertje-Obed, 56, admitted to cutting fences and entering the Y-12 site in Oak Ridge, Tennessee, which processes and stores uranium. The July 2012 incident prompted security changes. Sister Megan said she regretted only having waited 70 years to take action. A jury deliberated for two and a half hours before handing down its verdict. The three face up to 20 years in prison following their conviction for sabotaging the plant, which was first constructed during the Manhattan Project that developed the first nuclear bomb. The three, who belong to the group Transform Now Plowshares, were also found guilty of causing more than $1,000 (£643) of damage to government property, for which they could face up to 10 years in prison. Walli and Boertje-Obed, a house painter, testified in their own defence, telling jurors they had no remorse for their actions. Sister Megan stood and smiled as the verdict was read out at a court in Knoxville, Tennessee. Supporters in the courtroom gasped and wept and sang a hymn as the judge left. The break-in disrupted operations there, and reportedly caused more than $8,500 of damage. Our actions were providing real security and exposing false security” End Quote Greg Boertje-Obed \"We are a nation of laws,\" prosecutor Jeffrey Theodore said during closing arguments. \"You can't take the law into your own hands and force your views on other people.\" But defence lawyers said the break-in was symbolic and was not intended to hurt the facility, and officials have acknowledged the protesters never neared the nuclear material. \"The shortcomings in security at one of the most dangerous places on the planet have embarrassed a lot of people,\" said lawyer Francis Lloyd. \"You're looking at three scapegoats behind me.\" 'Ineptitude' Sister Megan said her only regret was waiting so long to stage her protest. \"It is manufacturing that which can only cause death,\" she said. In a statement to the court, Boertje-Obed said: \"Nuclear weapons do not provide security. Our actions were providing real security and exposing false security.\" The three activists admitted to cutting the fence to get into the site, walking around, spray-painting words, stringing crime scene tape and chipping a wall with hammers. They spent two hours inside. They also sprayed the exterior of the complex with baby bottles containing human blood. When a guard approached, they offered him food and started singing. In the wake of the episode, Congress and the energy department investigated the facility and found \"troubling displays of ineptitude\" there. Top officials were reassigned, including at the National Nuclear Security Agency. WSI, the company providing security at the site, was dismissed and other officers were sacked, demoted or suspended. More on This Story";
            news3.Date = DateTime.Now;
            news3.Guid = "guid2";
            news3.Publisher = "publisher";
            news3.Url = new Uri("http://www.foo.bar");
            news3.Summary = "summary";
            news3.Title = "Three US women missing for years rescued in Ohio";
            Archivist.AddNews(news3);

            List<NewsItem> result = Curator.GetCuratedNews(Archivist, 100, 6);

            // Expect only 2 items in result.
            Assert.AreEqual(2, result.Count);
        }
Exemplo n.º 24
0
        public void SourceTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Source = new NewsSource("foo", new Uri("http://www.test.com/"));

            Assert.AreEqual(new NewsSource("foo", new Uri("http://www.test.com/")),
                m.Source);
        }
Exemplo n.º 25
0
 /// <summary>
 /// Adds a piece of news to the storage device using the details of the
 /// specified <c>NewsMaterial</c>.
 /// </summary>
 /// <param name="newsMaterial">
 /// The <c>NewsMaterial</c> from which to add the piece of news to the
 /// storage device.
 /// </param>
 /// <param name="categoryId">
 /// The id of the category to add this news item to.
 /// </param>
 /// <param name="isRead">
 /// Indicates whether the news items should be marked as read or not.
 /// </param>
 /// <returns>
 /// The id of the newly inserted news item.
 /// </returns>
 public abstract int AddNews(NewsMaterial newsMaterial, 
     int categoryId = -1, bool isRead = false);
Exemplo n.º 26
0
        /// <summary>
        /// Converts a <c>SyndicationItem</c> object to a <c>NewsMaterial</c> 
        /// object.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        private static NewsMaterial ConvertSyndicationItemToNewsMaterial(
            NewsSource source, SyndicationItem item)
        {
            // Create a new NewsMaterial.
            NewsMaterial newsMaterial = new NewsMaterial();

            // Populate the new NewsMaterial.
            newsMaterial.Title = item.Title.Text;

            if (item.Summary == null)
            {
                newsMaterial.Summary = item.Content is TextSyndicationContent ?
                    ((TextSyndicationContent)item.Content).Text : "";
            }
            else
            {
                newsMaterial.Summary = item.Summary.Text;
            }

            newsMaterial.Content = GetStrippedHtmlContent(item.Links[0].Uri);

            newsMaterial.Publisher = source.Name;
            newsMaterial.Author = GetFormattedSyndicationPersonNames(item.Authors);

            if (newsMaterial.Author == null)
            {
                newsMaterial.Author = newsMaterial.Publisher;
            }

            newsMaterial.Date = item.PublishDate.UtcDateTime;
            newsMaterial.Source = source;
            newsMaterial.Url = item.Links[0].Uri;

            // If to GUID was given use the url for this newsMaterial.
            if (item.Id != null)
            {
                newsMaterial.Guid = item.Id;
            }
            else if (newsMaterial.Url != null)
            {
                newsMaterial.Guid = newsMaterial.Url.AbsoluteUri;
            }
            else
            {
                return null;
            }

            if (newsMaterial.Url == null)
            {
                if (newsMaterial.Guid != null)
                {
                    Uri url;
                    if ((Uri.TryCreate(newsMaterial.Guid, UriKind.Absolute,
                        out url) && url.Scheme == Uri.UriSchemeHttp))
                    {
                        newsMaterial.Url = url;
                    }
                }
            }

            if (newsMaterial.Url == null)
            {
                return null;
            }

            return newsMaterial;
        }
Exemplo n.º 27
0
        public void RedundancyFilterRedundantInList()
        {
            NewsMaterial news1 = new NewsMaterial();
            news1.Author = "author";
            news1.Content = "Ohio Cleveland abductions: three women missing for a decade found alive in Ohio Amanda Berry, Gina DeJesus and Michelle Knight, as well as a six-year-old, found in a house a few miles from where they disappeared Link to video: Amanda Berry and two other missing women found alive Three women who went missing separately about a decade ago in Cleveland, Ohio , have been found alive in a house a few miles away from where they disappeared. A neighbour said he let one of the women out of the house just south of downtown after he heard her screaming on Monday. In a recorded emergency call, the freed woman told the dispatcher: \"I'm Amanda Berry. I've been on the news for the last 10 years.\" Amanda Berry (right) reunited with her sister after being found in Cleveland, Ohio. Photograph: AFP/Getty Images She said the person who had taken her had gone out. \"I've been kidnapped, and I've been missing for 10 years,\" she said. \"And I'm here. I'm free now.\" Police found two other missing women in the house – Gina DeJesus and Michelle Knight – as well as a six-year-old child. They have not revealed the child's identity or relationship to anyone in the house. The women appeared to be in good health and were taken to a hospital to be assessed and to be reunited with relatives. Three brothers have been arrested. House in Seymour Avenue, Cleveland, where Amanda Berry, Gina DeJesus and Michelle Knight were found. Photograph: Scott Shaw/AP Berry was 16 when she disappeared on 21 April 2003 after calling her sister to say she was getting a ride home from the Burger King fast-food restaurant where she worked. DeJesus was 14 when she went missing on her way home from school about a year later. Police said Knight went missing in 2002 and is now 32. The three women had probably been tied up while in captivity, police said. Crowds gathered on Monday night near the home where the city's police chief said the women had been held since they went missing. Link to video: Charles Ramsey describes Amanda Berry rescue Police said one of the brothers arrested, a 52-year-old, lived at the house, while the others, aged 50 and 54, lived elsewhere. They did not release any names. Julio Castro, who runs a store half a block from where the women were found, said the arrested homeowner was his nephew, Ariel Castro, who had worked as a school bus driver. Berry also identified Ariel Castro by name in her emergency call, according to  Associated Press. The women's friends and relatives said they had not given up hope of seeing them again. A childhood friend of DeJesus, Kayla Rogers, told the Plain Dealer newspaper: \"I've been praying, never forgot about her, ever.\" Berry's cousin Tasheena Mitchell told the newspaper she could not wait to have her in her arms. \"I'm going to hold her, and I'm going to squeeze her, and I probably won't let her go,\" she said. Amanda Berry and Gina DeJesus are pictured in this combination photograph in undated handout photos released by the FBI. Photograph: Reuters Berry's mother, Louwana Miller, who had been in hospital for months with pancreatitis and other ailments, died in March 2006. She had spent the previous three years looking for her daughter, whose disappearance took a toll as her health steadily deteriorated, family and friends said. City councillor Dona Brady said she had spent many hours with Miller, who never gave up hope that her daughter was alive. \"She literally died of a broken heart,\" Brady said.";
            news1.Date = DateTime.Now;
            news1.Guid = "guid1";
            news1.Publisher = "publisher";
            news1.Url = new Uri("http://www.foo.bar");
            news1.Summary = "summary";
            news1.Title = "Ohio Cleveland abductions: three women missing for a decade found alive in Ohio";
            Archivist.AddNews(news1);

            NewsMaterial news2 = new NewsMaterial();
            news2.Author = "author";
            news2.Content = "Three US women missing for years rescued in Ohio A neighbour, Charles Ramsey, tells reporters: \"We had to kick open the bottom of the door\" Police: 'It's a great day' Watch Three young women who vanished in separate incidents about a decade ago in the US state of Ohio have been found alive in a house in Cleveland. Amanda Berry disappeared aged 16 in 2003, Gina DeJesus went missing aged 14 a year later, and Michelle Knight disappeared in 2002 aged around 19. Their discovery followed a dramatic bid for freedom by Amanda Berry on Monday, helped by a neighbour. Three brothers have been arrested in connection with the case. Cleveland police said the suspects are Hispanic, aged 50, 52 and 54, and one of them had lived at the house on Seymour Avenue. One was named as Ariel Castro, who has worked as a school bus driver. Police have said a six-year-old was also found at the home. They have not revealed any further details, although a relative of Amanda Berry said she told him she had a daughter. The women's families reacted with shock and delight at news of their discovery, and many people gathered outside the home where they had allegedly been imprisoned. \"It's been a whirlwind kind of day. It's surreal,\" said Gina DeJesus' relative, Sylvia Colon. She said the family had never given up hope, holding vigils every year and keeping memorials outside the house. \"We were living every day in the hope she would come home - and she did,\" she told the BBC. Ms Colon said the women would now \"need to be given some space. They have been away from us for a very long time.\" A doctor said the three women were in a fair condition and were being kept in hospital for observation. To cheers from spectators, Dr Gerald Maloney told reporters outside Metro Health hospital in Cleveland that the women were able to speak to hospital staff, but he declined to give further details. The disappearances of Amanda Berry and Gina DeJesus had been big news in Cleveland, and many had assumed them to be dead. Little was made of the disappearance of Michelle Knight, who was older than the other two girls. Gina DeJesus' aunt Sandra Ruiz: \"She knew we were looking for her\" Her grandmother, Deborah Knight, was quoted by the Cleveland Plain Dealer newspaper on Monday as saying that the authorities concluded she had run away. 'Here a long time' The dramatic events unfolded after Amanda Berry attempted to flee the house when her alleged captor went out. Neighbour Charles Ramsey said he heard screaming. \"I see this girl going nuts trying to get outside,\" he told reporters. He said he suggested the woman open the door and exit, but she told him it was locked. \"We had to kick open the bottom,\" he said. \"Lucky on that door it was aluminium. It was cheap. She climbed out with her daughter.\" Both Mr Ramsey and Ms Berry called 911. In her frantic call, released to the news media, Ms Berry told the operator: \"I'm Amanda Berry. I've been kidnapped. I've been missing for 10 years. I'm free. I'm here now.\" She identified her kidnapper as Ariel Castro and said other women were in the house. Anthony confirmed to a journalist that he had written about the neighbourhood's heightened concern for safety in the Cleveland Plain Press , and told her that Monday's developments were \"beyond comprehension\". Charles Ramsey's 911 call after he helped free Amanda Berry \"He was stunned that something like this could possible happen,\" WKYC reporter Sara Shookman told CNN. Cleveland Mayor Frank Jackson has said an investigation into the \"many unanswered questions regarding this case\" will be held. High-profile cases Ms Berry was last heard from when she called her sister on 21 April 2003 to say she would get a lift home from work at a Burger King restaurant. In 2004, Ms DeJesus was said to be on her way home from school when she went missing. Their cases were re-opened last year when a prison inmate tipped off authorities that Ms Berry may have been buried in Cleveland. He received a four-and-a-half-year sentence in prison for the false information. Amanda Berry's mother, Louwana, died in March 2006, three years after her daughter's disappearance. Although much is still not yet known about this case, it recalled a series of recent high-profile child abduction cases. Jaycee Lee Dugard was 11 years old when she was dragged into a car as she walked to a bus stop near her home in South Lake Tahoe, California in 1991. Photos of Berry (left) and DeJesus were distributed widely after they went missing She was discovered in August 2009, having spent 18 years held captive in the backyard of  Phillip and Nancy Garrido in Antioch, some 170 miles from South Lake Tahoe. She had two children. In Austria, Natascha Kampusch was abducted on her way to school at the age of 10. She was held for eight years by Wolfgang Priklopil in the windowless basement of a house in a quiet suburb of Vienna. She managed to escape in 2006 while Priklopil was making a phone call. He committed suicide hours after she had fled. Elizabeth Smart was 14 when she was taken from the bedroom of her Utah home in June 2002 and repeatedly raped during nine months of captivity. She was rescued in March 2003 less than 20 miles from her home. Her abductor, Brian David Mitchell, was jailed for life in 2011. Are you from the Cleveland area? Do you know any of the people involved in this story? Please leave your comments using the form below (Required) Name";
            news2.Date = DateTime.Now;
            news2.Guid = "guid2";
            news2.Publisher = "publisher";
            news2.Url = new Uri("http://www.foo.bar");
            news2.Summary = "summary";
            news2.Title = "Three US women missing for years rescued in Ohio";
            Archivist.AddNews(news2);

            // Get all news.
            NewsQuery query = new NewsQuery();
            query.NewerThan = DateTime.Now.Subtract(new TimeSpan(1, 0, 0));
            query.Limit = 2;
            List<NewsItem> news = Archivist.GetNews(query);

            // Filter.
            List<NewsItem> result = Filter.Filter(Archivist, news);

            // Expect only one item.
            List<NewsItem> expected = new List<NewsItem> { result[0] };

            CollectionAssert.AreEquivalent(expected, result);
        }
Exemplo n.º 28
0
        public void TitleTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Title = "foo";

            Assert.AreEqual("foo", m.Title);
        }
Exemplo n.º 29
0
        public void SummaryTestProperty()
        {
            NewsMaterial m = new NewsMaterial();
            m.Summary = "foo";

            Assert.AreEqual("foo", m.Summary);
        }
Exemplo n.º 30
0
        /// <summary>
        /// Inserts a <c>NewsMaterial</c> into the database by converting
        /// it to a <c>NewsItem</c>.
        /// The <c>DatabaseConnection</c> must be open prior to calling 
        /// this method.
        /// </summary>
        /// <param name="newsMaterial">
        /// The <c>NewsMaterial</c> to add.
        /// </param>
        /// <param name="categoryId">
        /// The id of the possible forced category of the <c>NewsMaterial</c>.
        /// -1 if no category is being forced (one will be determined).
        /// </param>
        /// <param name="isRead">
        /// Indicates whether the news item should be marked as read or not.
        /// </param>
        /// <returns>
        /// The id of the newly inserted news item.
        /// </returns>
        private int InsertNewsMaterial(NewsMaterial newsMaterial, int categoryId,
            bool isRead)
        {
            int newsId;

            SqlCeCommand cmd = DatabaseConnection.CreateCommand();

            // Check if the news item already exists.
            newsId = DoesNewsItemExist(newsMaterial.Guid, true);

            // Calculate the term frequency.
            Dictionary<string, int> tf = TermUtils.CalculateTermFrequency(
                newsMaterial.Content);

            // Get the median index of all the terms.
            Dictionary<string, int> termMedianIndex =
                TermUtils.CalculateTermMedianIndex(newsMaterial.Content);

            // Assemble the terms to store.
            Dictionary<string, double> termsToStoreWithIdf =
                new Dictionary<string, double>();

            foreach (KeyValuePair<string, int> term in tf)
            {
                termsToStoreWithIdf.Add(term.Key, 1.0);
            }

            // Store the terms.
            StoreTerms(termsToStoreWithIdf);

            // Find the news item's category.
            List<string> termsInNews = new List<string>();

            // Assemble a list of terms to send to FindCategory.
            // The list may contain duplicate entries.
            foreach (KeyValuePair<string, int> term in tf)
            {
                for (int i = 0; i < term.Value; i++)
                {
                    termsInNews.Add(term.Key);
                }
            }

            if (categoryId == -1)
            {
                categoryId = FindCategory(termsInNews).Id;
            }

            // Get news source id.
            int newsSourceId = GetNewsSourceId(newsMaterial.Source, cmd);

            // Store news item and get its id.
            newsId = StoreNewsItem(newsMaterial, newsId, categoryId,
                newsSourceId, tf.Sum(p => p.Value), isRead);
            // Get the newly inserted terms's ids.
            Dictionary<string, int> termIds = GetTermIds(termsToStoreWithIdf.Keys.ToList(), cmd);

            // Save the term ids, tf and median index (in that order).
            List<Tuple<int, int, int>> termIdsAndTfAndMedianIndex =
                new List<Tuple<int, int, int>>();

            // Assemble the term ids.
            foreach (KeyValuePair<string, int> term in termIds)
            {
                // Check that the term exists in tf and termMedianIndex.
                // It may not be contained due to encoding conversion between
                // the database and .NET string (UTF-16 to UTF-8 and back again).
                if (tf.ContainsKey(term.Key) && termMedianIndex.ContainsKey(term.Key))
                {
                    termIdsAndTfAndMedianIndex.Add(new Tuple<int, int, int>(
                        term.Value,
                        tf[term.Key],
                        termMedianIndex[term.Key]));
                }
            }

            // Store the term frequency.
            StoreTfValues(termIdsAndTfAndMedianIndex, newsId);

            return newsId;
        }