示例#1
0
 public void EqualsTestInequality()
 {
     NewsQuery o1 = new NewsQuery();
     o1.Interest = InterestStatus.Interesting;
     NewsQuery o2 = new NewsQuery();
     o2.Interest = InterestStatus.Uninteresting;
     Assert.IsFalse(o1.Equals(o2));
 }
示例#2
0
 public void EqualsTestEqualsOperator()
 {
     NewsQuery o1 = new NewsQuery();
     o1.Interest = InterestStatus.Interesting;
     NewsQuery o2 = new NewsQuery();
     o2.Interest = InterestStatus.Interesting;
     Assert.IsTrue(o1 == o2);
 }
示例#3
0
 public void EqualsTestGetHasCodesEquals()
 {
     NewsQuery o1 = new NewsQuery();
     o1.Interest = InterestStatus.Interesting;
     NewsQuery o2 = new NewsQuery();
     o2.Interest = InterestStatus.Interesting;
     Assert.AreEqual(o1.GetHashCode(), o2.GetHashCode());
 }
示例#4
0
        /// <summary>
        /// Curates undread news from the given <c>Archivist</c> instance based 
        /// on a maximum reading time, a maximum individual item reading time 
        /// and a limit.
        /// </summary>
        /// <param name="archivist">
        /// The <c>Archivist</c> instance giving access to the news that 
        /// should be curated.
        /// </param>
        /// <param name="limit">
        /// The maximum number of news to return.
        /// </param>
        /// <param name="maxTime">
        /// The maximum reading time for the curated news.
        /// </param>
        /// <param name="maxItemTime">
        /// The maximum reading time per news item.
        /// </param>
        /// <returns>
        /// A list of unread, curated <c>NewsItem</c>s received from the 
        /// <c>Archivist</c> instance.
        /// </returns>
        public static List<NewsItem> GetCuratedNews(Archivist archivist,
            int limit, int maxTime = -1, int maxItemTime = - 1)
        {
            // Get cached data and update if null.
            List<NewsItem> curatedNews = CachedNews;

            if (curatedNews == null)
            {
                // Update needed.

                NewsQuery query = new NewsQuery();
                // Only fetch unread news.
                query.Read = ReadStatus.Unread;
                query.OrderDateDesc = true;
                query.Limit = 100;
                curatedNews = archivist.GetNews(query);

                // If no news was found then there's no need to filter them.
                if (curatedNews.Count == 0)
                {
                    return curatedNews;
                }

                // Filter for interesting news.
                InterestFilter interestFilter = new InterestFilter();
                curatedNews = interestFilter.Filter(archivist, curatedNews);

                // Filter redundancy.
                RedundancyFilter redundancyFilter = new RedundancyFilter();
                curatedNews = redundancyFilter.Filter(archivist, curatedNews);

                // Update cache.
                CachedNews = curatedNews;
            }

            // Filter quantity.
            QuantityFilter quantityFilter = new QuantityFilter(limit,
                maxTime, maxItemTime);
            curatedNews = quantityFilter.Filter(archivist, curatedNews);

            // Return curated list.
            return curatedNews;
        }
示例#5
0
        public void ReadTest()
        {
            NewsQuery q = new NewsQuery();

            ReadStatus read = ReadStatus.Unread;
            q.Read = read;

            Assert.AreEqual(read, q.Read);
        }
示例#6
0
        public void OffsetTest()
        {
            NewsQuery q = new NewsQuery();

            int offset = 73;
            q.Offset = offset;

            Assert.AreEqual(offset, q.Offset);
        }
示例#7
0
        public void OrderDateDescTest()
        {
            NewsQuery q = new NewsQuery();

            bool orderDateDesc = false;
            q.OrderDateDesc = orderDateDesc;

            Assert.AreEqual(orderDateDesc, q.OrderDateDesc);
        }
        public void GetNewsTestLimitAndCategory()
        {
            // Add categories and news sources.
            foreach (Category c in Categories)
            {
                c.Id = Archivist.AddCategory(c.Name);
            }
            Archivist.AddNewsSources(NewsSources);

            // Add news with forced categories.
            Archivist.AddNews(NewsMaterial[0], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[1], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[2], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[3], Categories[1].Id);

            // Get all news items in the first category.
            List<NewsItem> expectedNewsItem = Archivist.GetNews(new NewsQuery()).
                FindAll(n => n.Category.Equals(Categories[0]));

            // Sort the news items descendingly and remove the last entry.
            expectedNewsItem.Sort((n1, n2) => n2.Date.CompareTo(n1.Date));
            expectedNewsItem.RemoveAt(expectedNewsItem.Count - 1);

            // Create a news query.
            NewsQuery newsQuery = new NewsQuery()
            {
                Limit = 2,
                CategoryId = Categories[0].Id
            };

            // Get the actual news items.
            List<NewsItem> actualNewsItems = Archivist.GetNews(newsQuery);

            CollectionAssert.AreEquivalent(expectedNewsItem, actualNewsItems);
        }
示例#9
0
        public void NewerThanTest()
        {
            NewsQuery q = new NewsQuery();

            DateTime newerThan = DateTime.Now;
            q.NewerThan = newerThan;

            Assert.AreEqual(newerThan, q.NewerThan);
        }
示例#10
0
        public void GetNewsTestOrderDateAscending()
        {
            // Add categories and news sources.
            foreach (Category c in Categories)
            {
                c.Id = Archivist.AddCategory(c.Name);
            }
            Archivist.AddNewsSources(NewsSources);

            // Add news with forced categories.
            Archivist.AddNews(NewsMaterial[0], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[1], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[2], Categories[1].Id);
            Archivist.AddNews(NewsMaterial[3], Categories[2].Id);

            // Create a news query.
            NewsQuery newsQuery = new NewsQuery()
            {
                OrderDateDesc = false
            };

            // Assemble the expected news items via news material.
            List<NewsMaterial> expectedNewsItems = NewsMaterial;
            // Get the actual news items.
            List<NewsItem> actualNewsItems = Archivist.GetNews(newsQuery);

            // Assert the two lists are of equal length.
            Assert.AreEqual(expectedNewsItems.Count, actualNewsItems.Count,
                "The two lists are not of equal length.");

            // Sort the expected news items ascendingly just as the actual should be.
            expectedNewsItems.Sort((n1, n2) => n1.Date.CompareTo(n2.Date));

            // Assert that the news items within the given category was gotten.
            for (int i = 0; i < actualNewsItems.Count; i++)
            {
                TestHelpers.AssertNewsMaterialEquivalent(expectedNewsItems[i],
                    actualNewsItems[i], i);
            }
        }
        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);
        }
示例#12
0
        public void GetNewsTestNoNewsItemsFetched()
        {
            // Add categories and news sources.
            foreach (Category c in Categories)
            {
                c.Id = Archivist.AddCategory(c.Name);
            }
            Archivist.AddNewsSources(NewsSources);

            // Add news with forced categories.
            Archivist.AddNews(NewsMaterial[0], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[1], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[2], Categories[1].Id);
            Archivist.AddNews(NewsMaterial[3], Categories[2].Id);

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

            // Mark some news items as interesting.
            Archivist.SetNewsInterestingStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[0].Title)), true);
            Archivist.SetNewsInterestingStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[2].Title)), true);
            Archivist.SetNewsInterestingStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[3].Title)), true);

            // Mark some news items as read.
            Archivist.SetNewsReadStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[2].Title)), true);
            Archivist.SetNewsReadStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[3].Title)), true);

            // Create a news query.
            NewsQuery newsQuery = new NewsQuery()
            {
                ExcludedNews = new List<NewsItem>()
                {
                    gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[0].Title))
                },
                Interest = InterestStatus.Interesting,
                Read = ReadStatus.Read,
                CategoryId = Categories[2].Id,
                NewerThan = new DateTime(2013, 4, 27, 13, 50, 00)
            };

            // Get the actual news items.
            List<NewsItem> actualNewsItems = Archivist.GetNews(newsQuery);

            // Assert that there are not news items in the list.
            Assert.AreEqual(0, actualNewsItems.Count,
                "The list is not empty.");
        }
示例#13
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);
        }
示例#14
0
 public void EqualsTestObjectToNullReferenceEqualsOperator()
 {
     NewsQuery o1 = new NewsQuery();
     o1.Interest = InterestStatus.Interesting;
     NewsQuery o2 = null;
     Assert.IsFalse(o1 == o2);
 }
示例#15
0
 public void EqualsTestReferenceEquals()
 {
     NewsQuery o1 = new NewsQuery();
     o1.Interest = InterestStatus.Interesting;
     NewsQuery o2 = o1;
     Assert.IsTrue(o1.Equals(o2));
 }
示例#16
0
 public void EqualsTestObjectReferenceEquality()
 {
     NewsQuery o1 = new NewsQuery();
     o1.Interest = InterestStatus.Interesting;
     NewsQuery o2 = new NewsQuery();
     o2.Interest = InterestStatus.Interesting;
     Assert.IsTrue(o1.Equals((Object) o2));
 }
示例#17
0
        public void GetTfIdfMatrixOneNewsItemInDatabase()
        {
            // Add categories and news sources.
            foreach (Category c in Categories)
            {
                c.Id = Archivist.AddCategory(c.Name);
            }
            Archivist.AddNewsSources(NewsSources);

            Dictionary<string, List<int>> terms = new Dictionary<string, List<int>>();

            // Add some news material.
            NewsMaterial n = NewsMaterial[0];
            // Generate vector for index #1.
            Dictionary<string, int> termsInText =
                TermUtils.CalculateTermFrequency(n.Content);
            // Find all unique terms in news, and increase counts.
            foreach (KeyValuePair<string, int> term in termsInText)
            {
                if (!terms.ContainsKey(term.Key))
                {
                    terms.Add(term.Key, new List<int>());

                    // Add for all news material items.
                    for (int j = 0; j < NewsMaterial.Count; j++)
                    {
                        terms[term.Key].Add(0);
                    }
                }

                terms[term.Key][0] += term.Value;
            }

            // Add to database.
            Archivist.AddNews(n);

            // Update idf values.
            Archivist.UpdateIdfValues();

            // Create expected vector.
            SparseMatrix expected = new SparseMatrix(terms.Count, 1);
            int index = 0;
            foreach (KeyValuePair<string, List<int>> termCount in terms)
            {
                // Calculate idf.
                int docCount = 0;
                termCount.Value.ForEach((p) => docCount += p > 0 ? 1 : 0);
                double idf = TermUtils.CalculateInverseDocumentFrequency(
                    NewsMaterial.Count,
                    docCount);

                // Calculate tf.
                int tf = termCount.Value[2];
                // Set value in vector.
                expected[index, 0] = (float)(tf * idf);

                index++;
            }

            // Get matrix.
            NewsQuery query = new NewsQuery();
            query.Limit = 1;
            SparseMatrix matrix = Archivist.GetTfIdfMatrix(query);
            double sum1 = 0;
            double sum2 = 0;
            for (int i = 0; i < expected.Columns; i++)
            {
                sum1 += expected.ColumnVector(i).Length();
                sum2 += matrix.ColumnVector(i).Length();
            }

            Assert.AreEqual(sum1, sum2, 0.001d);
        }
示例#18
0
        public void GetNewsTestRead()
        {
            // Add categories and news sources.
            foreach (Category c in Categories)
            {
                c.Id = Archivist.AddCategory(c.Name);
            }
            Archivist.AddNewsSources(NewsSources);

            // Add news with forced categories.
            Archivist.AddNews(NewsMaterial[0], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[1], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[2], Categories[1].Id);
            Archivist.AddNews(NewsMaterial[3], Categories[2].Id);

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

            // Mark some news items as read.
            Archivist.SetNewsReadStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[2].Title)), true);
            Archivist.SetNewsReadStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[3].Title)), true);

            // Create a news query.
            NewsQuery newsQuery = new NewsQuery()
            {
                Read = ReadStatus.Read
            };

            // Assemble the expected news items via news material.
            List<NewsMaterial> expectedNewsItems = new List<NewsMaterial>()
            {
                NewsMaterial[2],
                NewsMaterial[3]
            };
            // Get the actual news items.
            List<NewsItem> actualNewsItems = Archivist.GetNews(newsQuery);

            // Assert the two lists are of equal length.
            Assert.AreEqual(expectedNewsItems.Count, actualNewsItems.Count,
                "The two lists are not of equal length.");

            // Sort the two lists equivalently.
            expectedNewsItems.Sort((n1, n2) => n2.Date.CompareTo(n1.Date));
            actualNewsItems.Sort((n1, n2) => n2.Date.CompareTo(n1.Date));

            // Assert that the news items within the given category was gotten.
            for (int i = 0; i < actualNewsItems.Count; i++)
            {
                TestHelpers.AssertNewsMaterialEquivalent(expectedNewsItems[i],
                    actualNewsItems[i], i);

                // Check if the news item was actually set as read.
                Assert.AreEqual(true, actualNewsItems[i].IsRead,
                    "NewsItem at index " + i + " was not found read.");
            }
        }
示例#19
0
        public void GetNewsTestMisc()
        {
            // Add categories and news sources.
            foreach (Category c in Categories)
            {
                c.Id = Archivist.AddCategory(c.Name);
            }
            Archivist.AddNewsSources(NewsSources);

            // Add news with forced categories.
            Archivist.AddNews(NewsMaterial[0], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[1], Categories[1].Id);
            Archivist.AddNews(NewsMaterial[2], Categories[2].Id);
            Archivist.AddNews(NewsMaterial[3], Categories[2].Id);

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

            // Mark some news items as interesting.
            Archivist.SetNewsInterestingStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[0].Title)), true);
            Archivist.SetNewsInterestingStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[2].Title)), true);
            Archivist.SetNewsInterestingStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[3].Title)), true);

            // Mark some news items as read.
            Archivist.SetNewsReadStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[2].Title)), true);
            Archivist.SetNewsReadStatus(
                gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[3].Title)), true);

            // Create a news query.
            NewsQuery newsQuery = new NewsQuery()
            {
                ExcludedNews = new List<NewsItem>()
                {
                    gottenNewsItems.Find(n => n.Title.Equals(NewsMaterial[0].Title))
                },
                Interest = InterestStatus.Interesting,
                Read = ReadStatus.Read,
                CategoryId = Categories[2].Id,
                NewerThan = new DateTime(2013, 4, 27, 10, 50, 00),
            };

            // Assemble the expected news items via news material.
            List<NewsMaterial> expectedNewsItems = new List<NewsMaterial>()
            {
                NewsMaterial[2]
            };
            // Get the actual news items.
            List<NewsItem> actualNewsItems = Archivist.GetNews(newsQuery);

            // Assert the two lists are of equal length.
            Assert.AreEqual(expectedNewsItems.Count, actualNewsItems.Count,
                "The two lists are not of equal length.");

            // Assert that the news items within the given category was gotten.
            for (int i = 0; i < actualNewsItems.Count; i++)
            {
                TestHelpers.AssertNewsMaterialEquivalent(expectedNewsItems[i],
                    actualNewsItems[i], i);
            }
        }
示例#20
0
 /// <summary>
 /// Gets a tf-idf matrix of the <c>NewsItem</c>s matching the details
 /// as specified by the <c>NewsQuery</c>.
 /// </summary>
 /// <param name="newsQuery">
 /// Contains details of what <c>NewsItem</c>s to create 
 /// a tf-idf matrix of.
 /// </param>
 /// <returns>
 /// An m x n <c>SparseMatrix</c> where m is the number of terms in
 /// the storage device, with the tf-idf value's index in the vector 
 /// corresponding to the index of the respective term in 
 /// the storage device. n is the number of matrices that matches
 /// the specified <c>NewsQuery</c>.
 /// </returns>
 public abstract SparseMatrix GetTfIdfMatrix(NewsQuery newsQuery);
示例#21
0
        public void ExcludedNewsTest()
        {
            NewsQuery q = new NewsQuery();

            NewsItem item1 = new NewsItem("d", new Category(1, "d"), "d", "d",
                new Uri("http://www.d.com/"),
                new NewsSource("d", new Uri("http://www.d.com/")));

            q.ExcludedNews = new List<NewsItem>() { item1 };

            List<NewsItem> expected = new List<NewsItem>() { item1 };

            CollectionAssert.AreEqual(expected, q.ExcludedNews);
        }
示例#22
0
        public void GetNewsTestOffset()
        {
            // Add categories and news sources.
            foreach (Category c in Categories)
            {
                c.Id = Archivist.AddCategory(c.Name);
            }
            Archivist.AddNewsSources(NewsSources);

            // Add news with forced categories.
            Archivist.AddNews(NewsMaterial[0], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[1], Categories[0].Id);
            Archivist.AddNews(NewsMaterial[2], Categories[1].Id);
            Archivist.AddNews(NewsMaterial[3], Categories[2].Id);

            // Create a news query.
            NewsQuery newsQuery = new NewsQuery()
            {
                Offset = 2
            };

            // Assemble the expected news items via news material.
            List<NewsMaterial> expectedNewsItems = NewsMaterial;
            // Get the actual news items.
            List<NewsItem> actualNewsItems = Archivist.GetNews(newsQuery);

            // Sort the two lists equivalently.
            expectedNewsItems.Sort((n1, n2) => n2.Date.CompareTo(n1.Date));
            actualNewsItems.Sort((n1, n2) => n2.Date.CompareTo(n1.Date));

            // Remove the first two news material of the expected list.
            expectedNewsItems.RemoveAt(0);
            expectedNewsItems.RemoveAt(0);

            // Assert the two lists are of equal length.
            Assert.AreEqual(expectedNewsItems.Count, actualNewsItems.Count,
                "The two lists are not of equal length.");

            // Assert that the news items within the given category was gotten.
            for (int i = 0; i < actualNewsItems.Count; i++)
            {
                TestHelpers.AssertNewsMaterialEquivalent(expectedNewsItems[i],
                    actualNewsItems[i], i);
            }
        }
示例#23
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);
        }
示例#24
0
        public void ExcludedNewsTestConstructor()
        {
            NewsQuery q = new NewsQuery();

            Assert.IsNotNull(q.ExcludedNews);
        }
示例#25
0
 /// <summary>
 /// Gets news as specified by a <c>NewsQuery</c> instance.
 /// </summary>
 /// <param name="newsQuery">
 /// The <c>NewsQuery</c> from which to pick <c>NewsItem</c> to get.
 /// </param>
 /// <returns>
 /// The <c>NewsItem</c>s that meets the demands as specified by 
 /// the given<c>NewsQuery</c>.
 /// </returns>
 public abstract List<NewsItem> GetNews(NewsQuery newsQuery);
示例#26
0
        public void HasDefaultValues()
        {
            NewsQuery q = new NewsQuery();

            // Expected values.
            int limit = 100000;
            int offset = 0;
            bool orderDateDesc = true;
            InterestStatus interest = InterestStatus.Any;
            ReadStatus read = ReadStatus.Any;

            // Check for default values.
            Assert.AreEqual(orderDateDesc, q.OrderDateDesc,
                "OrderDateDesc default is not correct. Expected " +
                orderDateDesc + " but got " + q.OrderDateDesc);
            Assert.AreEqual(limit, q.Limit, "Limit default is not correct.");
            Assert.AreEqual(offset, q.Offset, "Offset default is not correct.");
            Assert.AreEqual(interest, q.Interest,
                "Interest default is not correct. Expected " + interest +
                " but got" + q.Interest + ".");
            Assert.AreEqual(read, q.Read,
                "Read default is not correct. Expected " + read + " but got " +
                q.Read + ".");

            // Hard to test as the DateTime for the creation of q cannot
            // be determined. Therefor the type is checked.
            Assert.IsInstanceOfType(q.NewerThan, typeof(DateTime),
                "NewerThan is not a DateTime.");
        }
        /// <summary>
        /// The main test method.
        /// </summary>
        public static void Test()
        {
            SqlCeArchivist archivist = new SqlCeArchivist("db.sdf");
            archivist.Open();
            archivist.TruncateData();
            string dataDir = @"C:\Users\mads\Desktop\data";
            DBSeeder.SeedDatabaseWithNews(archivist, dataDir, 500);

            // Mark sports category as interesting, business as uninteresting.
            List<Category> categories = archivist.GetCategories();
            archivist.MarkCategoryInteresting(categories.First(p => p.Name.Equals("sports")), true);
            archivist.MarkCategoryInteresting(categories.First(p => p.Name.Equals("business")), false);

            _random = new Random(42);

            // Generate lists of news items.
            List<NewsMaterial> interestingNews = new List<NewsMaterial>();
            for (int i = 0; i < 500; i++)
            {
                interestingNews.Add(GenerateNewsMaterial(true));
            }
            List<NewsMaterial> uninterestingNews = new List<NewsMaterial>();
            for (int i = 0; i < 500; i++)
            {
                uninterestingNews.Add(GenerateNewsMaterial(false));
            }
            // Add news to db and save ids.
            List<int> interestingNewsIds = archivist.AddNews(interestingNews);
            List<int> uninterestingNewsIds = archivist.AddNews(uninterestingNews);

            List<int> allNewsIds = new List<int>(interestingNewsIds);
            allNewsIds.AddRange(uninterestingNewsIds);

            // Get news to filter.
            NewsQuery query = new NewsQuery();
            query.Read = ReadStatus.Unread;
            List<NewsItem> news = archivist.GetNews(query);
            // Filter news.
            InterestFilter filter = new InterestFilter();
            news = filter.Filter(archivist, news);

            int correctCount = 0;
            int falseCount = 0;
            // Compare ids and count number of correct values.
            foreach (NewsItem item in news)
            {
                if (interestingNewsIds.Contains(item.Id))
                {
                    correctCount++;
                }
                else if (uninterestingNewsIds.Contains(item.Id))
                {
                    falseCount++;
                }
            }

            Console.WriteLine("Through filter: {0}", news.Count);
            Console.WriteLine("False positive count: {0}", falseCount);
            // Print result in console.
            Console.WriteLine("{0}/{1}={2}%", correctCount,
                interestingNews.Count,
                (double) correctCount / (interestingNews.Count) * 100.0);
            Console.ReadLine();
        }
示例#28
0
        public void InterestTest()
        {
            NewsQuery q = new NewsQuery();

            InterestStatus interest = InterestStatus.Interesting;
            q.Interest = interest;

            Assert.AreEqual(interest, q.Interest);
        }
        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);
        }
示例#30
0
        public void LimitTest()
        {
            NewsQuery q = new NewsQuery();

            int limit = 52;
            q.Limit = limit;

            Assert.AreEqual(limit, q.Limit);
        }