Exemple #1
0
        public ActionResult Index(int userId, int pageIndex = 1)
        {
            var wordsData = new WordsManager().GetAllUserWords(userId);
            var pageList  = new PagedList <Words>(wordsData == null ? new List <Words>():wordsData, pageIndex, pageSize);

            return(View(pageList));
        }
 public MainModel(MainWindow mainWindow)
 {
     this.mainWindow = mainWindow;
     wordsManager    = WordsManager.Instance;
     config          = wordsManager.GetConfig();
     RunTask();
     GoogleTranslator googleTranslator = new GoogleTranslator();
 }
Exemple #3
0
        public ActionResult GetWord(string wordId)
        {
            var    manager = new WordsManager();
            Words  word    = manager.GetWord(wordId);
            string result  = word == null ? "" : word.Answer;

            return(Content(result));
        }
        public WordsManagerTests()
        {
            _mock                  = new Mock <IArgumentVerifier>();
            _wordsLoaderMock       = new Mock <IWordsLoader>();
            _subwordsProcessorMock = new Mock <ISubwordsProcessor>();

            Instance = new WordsManager(_mock.Object, _subwordsProcessorMock.Object);
        }
Exemple #5
0
        public ActionResult Edit(string wordId, string reply)
        {
            var manager = new WordsManager();
            int ret     = manager.UpdateReply(wordId, reply);

            string msg = ret == 1 ? "编辑成功!" : "编辑失败!";

            return(Content(msg));
            //return Content("<script>alert('" + msg + "');location.href='/Admin?userId=" + (Session["admin"] as User).LoginId + "';</script>");
        }
Exemple #6
0
    private void Awake()
    {
        if (Instance != null)
        {
            Debug.LogError("WordsManger is existing!");
            return;
        }

        Instance = this;
    }
Exemple #7
0
        static List <int> GetRawSearchResult(WordsManager wordsManager, List <string> words)
        {
            HashSet <int> pages = new HashSet <int>();

            foreach (string word in words)
            {
                pages.UnionWith(wordsManager.QueryAllPages(word).Keys);
            }

            return(pages.ToList());
        }
Exemple #8
0
    private void Awake()
    {
        // if the singleton hasn't been initialized yet
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }

        instance = this;
        DontDestroyOnLoad(this.gameObject);
    }
Exemple #9
0
        void LoadWordManager()
        {
            wordsManager = new WordsManager();
            wordsManager.LoadFromLocal();
            WordsManagerLoaded = true;


            if (DataLoaded)
            {
                MessageBox.Show(String.Format("初始化完成,用时 {0:F3} s", GetTimeElapsed()));
            }
        }
Exemple #10
0
        public ActionResult Detail(int houseId)
        {
            House          houseInfo = new HouseManager().GetHouse(houseId);
            List <Words>   words     = new WordsManager().GetAllWordsByHouseId(houseId);
            List <Comment> comments  = new CommentManager().GetAllCommentByHouseId(houseId);

            var result = new DetailItem {
                HouseInfo = houseInfo,
                Words     = words,
                Comments  = comments
            };

            return(View(result));
            //return Json(result, JsonRequestBehavior.AllowGet);
        }
Exemple #11
0
        /// <summary>
        /// 计算出相关参数并且保存到本地
        ///// 参数包括 词的倒排表、页面RP
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="idx">要求的页面idx列表</param>
        static void CalculateArgument(DBReader reader, List <int> idx = null)
        {
            Console.WriteLine("start arguments calculating.");

            CalculatePageRank(reader, idx, epsilon: 0.000001);

            Console.WriteLine("page rank calculated.");

            Rank.SaveToLocal();

            WordsManager wordsManager = CalculateWords(reader, idx);

            Console.WriteLine("words calculated.");

            wordsManager.SaveToLocal();
        }
Exemple #12
0
        public ActionResult AddWords(string content, int userid, int houseid)
        {
            Words words = new Words()
            {
                Id          = Guid.NewGuid(),
                Name        = "",
                Theme       = "",
                Content     = content,
                PublishTime = DateTime.Now,
                UserId      = userid,
                HouseId     = houseid
            };
            int result = new WordsManager().Add(words);

            return(Content(result.ToString()));
        }
Exemple #13
0
        static WordsManager CalculateWords(DBReader reader, List <int> idxs = null)
        {
            if (idxs == null)
            {
                idxs = reader.GetAllIndex();
            }

            WordsManager wordsManager = new WordsManager();

            foreach (int idx in idxs)
            {
                string content = reader.GetPageByIndex(idx).raw_source;

                string text = htmlParser.Html2PlainText(content);

                wordsManager.Add(idx, Splitter.GetWords(text));
            }

            return(wordsManager);
        }
Exemple #14
0
        static void Main(string[] args)
        {
            //LaunchSpider("http://www.nwpu.edu.cn");

            DBReader reader = new DBReader();

            reader.ReadDBIndex();

            reader.ReadDBContent();

            //CalculateArgument(reader);

            WordsManager wordsManager = new WordsManager();

            wordsManager.LoadFromLocal();

            Rank.LoadFromLocal();

            Console.WriteLine("初始化完成");

            while (true)
            {
                string text = Console.ReadLine();
                if (text.ToLower() == "exit")
                {
                    break;
                }

                List <string> words = Splitter.GetWords(text);

                List <int> results  = GetRawSearchResult(wordsManager, words);
                List <int> wordidxs = wordsManager.GetWordsIndex(words);

                results = Rank.SortResult(wordsManager, results, wordidxs, 0.001);

                Console.WriteLine(String.Join("\n", reader.PageIdx2Description(results)));
            }
        }
 // Use this for initialization
 void Start()
 {
     wordsManager = GameObject.Find("_GameManager").GetComponent<WordsManager>();
 }