Exemplo n.º 1
0
    public IEnumerator LoadData()
    {
        yield return(LoadRadicals());

        yield return(LoadSentences());

        yield return(LoadKanji());

        yield return(LoadKanjiList());

        yield return(LoadKanaList());

        yield return(LoadVerbList());

        yield return(LoadConjugations());

        yield return(LoadKanjiToRadicals());

        yield return(LoadLearningSets());

        extendedSet = learningSets.Select(kv => kv.Value).Where(s => s.name == "extended").FirstOrDefault();

        EventBus.Instance.Raise(new DataProxyEvent(DataProxyEventType.Ready));
        EventBus.Instance.AddListener <DataProxyEvent> (DisplayFirst);

        OVRManager.HMDUnmounted += HandleHMDUnmounted;
    }
Exemplo n.º 2
0
        private LearningSet SplitOnTrainAndTest(InputsOutputsData inputOutputsData)
        {
            var allSamplesCount   = inputOutputsData.Count;
            var trainSamplesCount = GetTrainSampleCount(allSamplesCount);

            var rand         = new Random();
            var learningSet  = new LearningSet();
            var trainingData = learningSet.TrainingData;
            var testData     = learningSet.TestData;

            for (int i = 0, trainSamplesLeft = trainSamplesCount, samplesLeft = allSamplesCount;
                 i < allSamplesCount;
                 ++i, --samplesLeft)
            {
                bool shouldTakeNextTrainSample = rand.Next(1, samplesLeft) <= trainSamplesLeft;
                if (shouldTakeNextTrainSample)
                {
                    trainingData.AddData(inputOutputsData.Inputs[i], inputOutputsData.Outputs[i]);
                    --trainSamplesLeft;
                }
                else
                {
                    testData.AddData(inputOutputsData.Inputs[i], inputOutputsData.Outputs[i]);
                }
            }

            return(learningSet);
        }
Exemplo n.º 3
0
        public async Task <string> BackupAllCourses(long userId)
        {
            var courses           = new List <LearningSet>();
            var usersLearningSets = await GetUserLearningSets(userId);

            foreach (var c in usersLearningSets)
            {
                var itms = await _contentRepository.GetItemsForCourse(userId, c.Id, 10000, 0, 10000);

                var set = new LearningSet()
                {
                    Name = c.Name, Description = c.Description
                };
                set.LearningItems = new List <LearningItem>();
                foreach (var i in itms.items)
                {
                    set.LearningItems.Add(new LearningItem()
                    {
                        CorrectSentence  = i.CorrectSentence,
                        SentenceWithGaps = i.SentenceWithGaps,
                        Item             = i.Item,
                        Description      = i.Description
                    });
                }

                courses.Add(set);
            }

            return(JsonSerializer.Serialize(courses));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> EditPost()
        {
            LearningSet set = new LearningSet();

            if (await TryUpdateModelAsync(set))
            {
                try
                {
                    LearningSet oldSet = _context.LearningSets.Single(x => x.LearningSetID == set.LearningSetID);
                    oldSet.Name        = set.Name;
                    oldSet.Description = set.Description;
                    oldSet.Class       = set.Class;
                    await _context.SaveChangesAsync();
                }
                catch (ArgumentException)
                {
                    return(NotFound());
                }
            }
            return(RedirectToAction("Edit",
                                    routeValues: new
            {
                set.LearningSetID
            }));
        }
Exemplo n.º 5
0
 public static bool Validate(LearningSet set, LearningSetItem item)
 {
     if (item.Class > set.Class)
     {
         return(false);
     }
     if (set.OccurenceCR != OccurenceCREnum.neuvedeno && item.OccurenceCR != set.OccurenceCR)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
        public async Task <IActionResult> CreateCourse(long userId, LearningSet course)
        {
            var result = await _repository.CreateCourse(course, userId);

            if (result)
            {
                return(Ok());
            }
            else
            {
                return(NoContent());
            }
        }
Exemplo n.º 7
0
// course repository

        public async Task <bool> CreateCourse(LearningSet course, long UserId)
        {
            var user = await _context.Users.FirstOrDefaultAsync(u => u.Id == UserId);

            await _context.LearningSets.AddAsync(new LearningSet()
            {
                Name = course.Name, Description = course.Description, Author = user, IsPrivate = false
            });

            await _context.SaveChangesAsync();

            return(true);
        }
Exemplo n.º 8
0
        public LearningSet GetLearningSetForCategories(Category[] categories)
        {
            var learningSet = new LearningSet();

            foreach (var category in categories)
            {
                var categoryInputsOutputs = GetCategoryLearningSet(category, categories.Length);
                learningSet.AddData(categoryInputsOutputs);
            }

            learningSet.Shuffle();
            return(learningSet);
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(width, height);
            Console.SetBufferSize(width, height + 500);
            Design.Headline(Application.ProductName.Replace('_', ' '));

            int inputSize = 10;

            BaseTrans[]   inputs = new BaseTrans[inputSize];
            NeuralNetwork nn     = new NeuralNetwork();
            Random        r      = new Random();

            for (int i = 0; i < inputSize; i++)
            {
                inputs[i]       = new BaseTrans();
                inputs[i].Value = r.Next(100);
                nn.AddInput(inputs[i]);
            }
            BaseRec r1 = new BaseRec();

            //BaseReciever r2 = new BaseReciever
            nn.AddOutput(r1);
            nn.AddOutput(r1);
            //nn.AddOutput(r2);

            //int iterationNum = 10000;
            //double sum = 0
            nn.Build();

            LearningSet ls = nn.GenerateLearningSet();

            foreach (BaseTrans input in inputs)
            {
                ls.GiveInput(input, r.Next(100));
            }
            ls.ExpectOutput(r1, 100);

            nn.Practice(ls);

            nn.Activate();

            //Console.WriteLine(r1.Value);

            //sum += r1.Value;
            //Console.WriteLine(r1.Value);


            //Console.WriteLine(sum / iterationNum);

            //Design.End();
        }
Exemplo n.º 10
0
        public IActionResult Slide(int learningSetID, int item)
        {
            ViewBag.item = item;
            LearningSet set = _context.LearningSets.Include(x => x.Items)
                              .Single(x => x.LearningSetID == learningSetID);

            item = item >= set.NumberOfItems ? set.NumberOfItems - 1 : item;
            item = item < 0 ? 0 : item;

            LearningSetItem currentItem = set.Items.ElementAt(item);

            ViewBag.item = item;
            return(View(currentItem));
        }
Exemplo n.º 11
0
 public AddFromLearningSetFlow(
     ChatRoom chat,
     LocalDictionaryService localDictionaryService,
     LearningSet set,
     UserService userService,
     UsersWordsService usersWordsService,
     AddWordService addWordService)
 {
     Chat = chat;
     _localDictionaryService = localDictionaryService;
     _set               = set;
     _userService       = userService;
     _usersWordsService = usersWordsService;
     _addWordService    = addWordService;
 }
Exemplo n.º 12
0
        public async Task <bool> ImportAllCourses(long userId, List <LearningSet> courses)
        {
            var user = await _context.Users.FirstOrDefaultAsync(u => u.Id == userId);

            foreach (var c in courses)
            {
                var set = new LearningSet()
                {
                    Name = c.Name + "test", Description = c.Description, LearningItems = c.LearningItems.ToList(), Author = user
                };
                _context.LearningSets.Add(set);
                _context.SaveChanges();
            }

            return(true);
        }
Exemplo n.º 13
0
        // GET: Learning/Details/5
        public async Task <IActionResult> Details(int?LearningSetID)
        {
            if (LearningSetID == null)
            {
                return(NotFound());
            }

            LearningSet learningSet = await _context.LearningSets
                                      .FirstOrDefaultAsync(m => m.LearningSetID == LearningSetID);

            if (learningSet == null)
            {
                return(NotFound());
            }

            return(View(learningSet));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> CreatePost()
        {
            LearningSet newSet = new LearningSet();

            if (await TryUpdateModelAsync(newSet))
            {
                _context.LearningSets.Add(newSet);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Edit",
                                        routeValues: new
                {
                    newSet.LearningSetID
                }));
            }
            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 15
0
        // GET: Learning/AddSource/5
        public async Task <IActionResult> AddSource()
        {
            SourceModel source = new SourceModel();

            if (await TryUpdateModelAsync(source))
            {
                await source.GetItems(_context);

                LearningSet set = _context.LearningSets.Single(x => x.LearningSetID == source.LearningSetID);
                set.NumberOfItems = set.Items.Count();
                await _context.SaveChangesAsync();
            }

            return(RedirectToAction("Edit", "LearningSets",
                                    routeValues: new
            {
                source.LearningSetID
            }));
        }
Exemplo n.º 16
0
        public async Task GetItems(OrganismDbContext _context)
        {
            List <LearningSetItem> setItems = await new ItemsLoader().LoadItems(this, _context);

            LearningSet set = _context.LearningSets.Include(x => x.Items)
                              .Single(x => x.LearningSetID == LearningSetID);

            foreach (LearningSetItem item in setItems)
            {
                if (set.Items.Where(x => x.ImgPath == item.ImgPath).Count() != 0)
                {
                    continue;
                }
                if (ItemValidator.Validate(set, item))
                {
                    set.Items.Add(item);
                }
            }
            await _context.SaveChangesAsync();
        }
Exemplo n.º 17
0
 protected abstract void PerformEvaluation(ref double finalScore, LearningSet set);
        protected override void PerformEvaluation(ref double finalScore, LearningSet set)
        {
            double tmpScore = PerformRoundTrip(set.Entity, set.Language);

            finalScore += tmpScore;
        }
Exemplo n.º 19
0
 public void AddData(LearningSet categoryInputsOutputs)
 {
     TrainingData.AddData(categoryInputsOutputs.TrainingData);
     TestData.AddData(categoryInputsOutputs.TestData);
 }
Exemplo n.º 20
0
        public void SeedLearningSet()
        {
            if (_context.LearningSets.Any())
            {
                return;
            }

            string              data  = System.IO.File.ReadAllText("data.txt");
            List <string>       rec   = data.Split('\r').ToList();
            List <LearningItem> items = new List <LearningItem>();

            for (int i = 0; i < rec.Count - 1; i++)
            {
                string[] record = rec[i].Split('\t');
                record.ToList().ForEach(x => x.Replace("\n", ""));
                items.Add(new LearningItem()
                {
                    Item = record[0], Description = record[1], SentenceWithGaps = record[2], CorrectSentence = record[3]
                });
            }

            var set = new LearningSet()
            {
                Name = "200 common PhrasalVerbs", Description = "Most useful 200 phrasal verbs. This course will help you to improve your english really fast, it's free so add it to your learning board and practice every day!", LearningItems = items
            };

            _context.LearningSets.Add(set);
            _context.SaveChanges();

            items = new List <LearningItem>();
            for (int i = 0; i < rec.Count - 1; i++)
            {
                string[] record = rec[i].Split('\t');
                record.ToList().ForEach(x => x.Replace("\n", ""));
                items.Add(new LearningItem()
                {
                    Item = record[0], Description = record[1], SentenceWithGaps = record[2], CorrectSentence = record[3]
                });
            }

            set = new LearningSet()
            {
                Name = "150 common PhrasalVerbs", Description = "Some usefull phrasals", LearningItems = items
            };
            _context.LearningSets.Add(set);
            _context.SaveChanges();

            items = new List <LearningItem>();
            for (int i = 0; i < rec.Count - 1; i++)
            {
                string[] record = rec[i].Split('\t');
                record.ToList().ForEach(x => x.Replace("\n", ""));
                items.Add(new LearningItem()
                {
                    Item = record[0], Description = record[1], SentenceWithGaps = record[2], CorrectSentence = record[3]
                });
            }
            set = new LearningSet()
            {
                Name = "150 fake  PhrasalVerbs", Description = "For tests only", LearningItems = items
            };
            _context.LearningSets.Add(set);
            _context.SaveChanges();
        }