Esempio n. 1
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="text">テキスト</param>
 public ParagraphData(string text)
 {
     Text         = text;
     TokenList    = WordLogic.GetTokenList(text);
     TokenTbl     = WordLogic.GetBasicTokenTbl(text);
     TokenTypeTbl = WordLogic.GetTokenTypeTbl(TokenList);
     InfoRate     = AnalyzeLogic.CalcInfoRate(TokenList);
 }
Esempio n. 2
0
        public TaskIconViewModel()
        {
            settingsLogic = new SettingsLogic();
            historyLogic  = new HistoryLogic();
            wordLogic     = new WordLogic();

            InitLearner();
            InitDynamic();

            LoadCommands();
        }
Esempio n. 3
0
        public void 品詞を限定したトークンリストを取得できること(string testData_type, int testData_tokenNum)
        {
            var text               = "形態素解析とは、文法的な情報の注記の無い自然言語のテキストデータから、対象言語の文法や、辞書と呼ばれる単語の品詞等の情報にもとづき、形態素の列に分割し、それぞれの形態素の品詞等を判別する作業である。";
            var tokenList          = WordLogic.GetTokenList(text);
            var extractedTokenList = AnalyzeLogic.ExtractTokenType(tokenList, testData_type);

            Assert.AreEqual(testData_tokenNum, extractedTokenList.Count);
            foreach (var token in extractedTokenList)
            {
                Assert.AreEqual(testData_type, token.Type);
            }
        }
        public async Task <IActionResult> PostParentWordFromStrings([FromRoute] string parentWord, [FromRoute] string childWord)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var wordLogic = new WordLogic();

            var foundParentWord = wordLogic.GetWordByString(parentWord);

            if (foundParentWord == null)
            {
                foundParentWord = wordLogic.CreateWord(parentWord);
            }

            var mainWordLookup = _context.Words.Where(x => x.WordId == foundParentWord.WordId).FirstOrDefault();

            mainWordLookup.Main = true;

            var foundChildWord = wordLogic.GetWordByString(childWord);

            if (foundChildWord == null)
            {
                foundChildWord = wordLogic.CreateWord(childWord);
            }

            if (mainWordLookup.Weekly < foundChildWord.Weekly)
            {
                mainWordLookup.Weekly = foundChildWord.Weekly;
            }

            if (mainWordLookup.Monthly < foundChildWord.Monthly)
            {
                mainWordLookup.Monthly = foundChildWord.Monthly;
            }

            if (mainWordLookup.Yearly < foundChildWord.Yearly)
            {
                mainWordLookup.Yearly = foundChildWord.Yearly;
            }

            var newParentWord = new ParentWords()
            {
                ParentWordId = foundParentWord.WordId,
                ChildWordId  = foundChildWord.WordId
            };

            _context.ParentWords.Add(newParentWord);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetParentWords", new { id = newParentWord.WordJoinId }, newParentWord));
        }
Esempio n. 5
0
        private async Task Init()
        {
            WordLogic = new WordLogic(new PersistentWordManager <Word>(new FileHelper().GetLocalFilePath("WordMemo.db")));

            await WordLogic.UpdateWordList();

            _mWords = WordLogic.WordList;

            _mWordsAdapter = new WordsAdapter(this, _mWords);

            _mRecyclerView.SetAdapter(_mWordsAdapter);

            _mRecyclerView.LayoutChange += (sender, args) =>
            {
                bottomPosition = args.Bottom;
            };

            var fab = FindViewById <FloatingActionButton>(Resource.Id.fab);

            fab.Click += (sender, args) =>
            {
                Word newWord = new Word();
                _mWordsAdapter.AddWord(newWord);
                _mWordsAdapter.NotifyItemInserted(_mWordsAdapter.ItemCount - 1);

                HideKeyboard();

                _mRecyclerView.SmoothScrollToPosition(bottomPosition);
            };

            _mRecyclerView.ChildViewAttachedToWindow += (sender, args) =>
            {
                View lastRow = _mRecyclerView.GetLayoutManager().GetChildAt(_mWordsAdapter.ItemCount - 1);

                if (lastRow != null && args.View == lastRow)
                {
                    lastRow.RequestFocus();
                }
            };

            _mRecyclerView.SetItemAnimator(new DefaultItemAnimator());

            ItemTouchHelper.Callback callback        = new RecyclerItemTouchHelper(this);
            ItemTouchHelper          itemTouchHelper = new ItemTouchHelper(callback);

            itemTouchHelper.AttachToRecyclerView(_mRecyclerView);

            _mRecyclerView.ClearFocus();
            HideKeyboard();
        }
Esempio n. 6
0
 public GuessLogic(Random rand, WordLogic wl, SessionStorage ss)
 {
     _rand      = rand;
     _wl        = wl;
     _ss        = ss;
     Randomized = _ss.Randomized;
     RandomizeList();
     Words = _ss.GetWordList();
     GetFirstWord();
     CurrentWord     = _ss.GetCurrentWord();
     GuessingLetters = _ss.GetGuessingLetters();
     WordCount       = _ss.GetWordCount();
     Lives           = _ss.Lives;
 }
Esempio n. 7
0
        public void トークンリストの品詞分類ができること()
        {
            var text         = "形態素解析とは、文法的な情報の注記の無い自然言語のテキストデータから、対象言語の文法や、辞書と呼ばれる単語の品詞等の情報にもとづき、形態素の列に分割し、それぞれの形態素の品詞等を判別する作業である。";
            var tokenList    = WordLogic.GetTokenList(text);
            var tokenTypeTbl = WordLogic.GetTokenTypeTbl(tokenList);

            Assert.AreEqual(7, tokenTypeTbl.Keys.Count);
            Assert.IsTrue(tokenTypeTbl.ContainsKey("名詞"));
            Assert.IsTrue(tokenTypeTbl.ContainsKey("動詞"));
            Assert.IsTrue(tokenTypeTbl.ContainsKey("助動詞"));
            Assert.IsTrue(tokenTypeTbl.ContainsKey("助詞"));
            Assert.IsTrue(tokenTypeTbl.ContainsKey("形容詞"));
            Assert.IsTrue(tokenTypeTbl.ContainsKey("記号"));
            Assert.IsTrue(tokenTypeTbl.ContainsKey("BOS/EOS"));
        }
Esempio n. 8
0
        /// <summary>
        /// 解析処理
        /// </summary>
        /// <param name="text">テキスト</param>
        public void Analyze(string text)
        {
            ParagraphList.Clear();

            var strParagraphList = ParagraphLogic.SplitParagraph(text);

            foreach (var strParagraph in strParagraphList)
            {
                ParagraphList.Add(new ParagraphData(strParagraph));
            }

            TokenList    = WordLogic.GetTokenList(text);
            TokenTbl     = WordLogic.GetBasicTokenTbl(text);
            TokenTypeTbl = WordLogic.GetTokenTypeTbl(TokenList);
            InfoRate     = AnalyzeLogic.CalcInfoRate(TokenList);
        }
Esempio n. 9
0
        /// <summary>
        /// Handle the button click event
        /// </summary>
        /// <param name="sender">The sender of the event</param>
        /// <param name="e">The event arguments</param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var wordLogic = new WordLogic();
            var word      = TextBox.Text.ToString();

            try {
                wordLogic.AddWord(new Word {
                    Term = word
                });
                MessageBox.Show(word.IsPalindrome().ToString());
            } catch (EmptyStringException ex) {
                MessageBox.Show(ex.Message);
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 10
0
        static Compiler.Variable[] validParameters(string trimmedPara, Compiler.Function calledFunction, int lineNumber, Compiler.Scope currentScope)
        {
            string[] words = Compiler.WordParser.parseWords(trimmedPara);

            if (words.Length != 0)
            {
                Compiler.Logic[] logicOrder = WordLogic.determineLogicFromWords(words, lineNumber, currentScope);

                List <List <Compiler.Logic> > packedLogics = convertIntoParameterLogic(words, logicOrder, lineNumber);

                if (packedLogics != null)
                {
                    Compiler.Variable[] inputVariables = new Compiler.Variable[packedLogics.Count];

                    for (int i = 0; i < packedLogics.Count; i++)
                    {
                        inputVariables [i] = ValidSumCheck.checkIfValidSum(packedLogics [i].ToArray(), lineNumber);
                    }


                    foreach (Compiler.Variable v in inputVariables)
                    {
                        if (v.variableType == Compiler.VariableTypes.unkown)
                        {
                            ErrorMessage.sendErrorMessage(lineNumber, "one or several of the input parameters to function: " + calledFunction.name + " are corrupt!");
                        }
                    }


                    if (calledFunction.inputParameters.Contains(inputVariables.Length))
                    {
                        return(inputVariables);
                    }
                }
            }

            if (calledFunction.inputParameters.Contains(0))
            {
                return(new Compiler.Variable[0]);
            }

            ErrorMessage.sendErrorMessage(lineNumber, "Amount of parameters does not match Expected!");
            return(new Compiler.Variable[0]);
        }
Esempio n. 11
0
        public void 文からトークンテーブルを取得できること()
        {
            var text = "形態素解析とは、文法的な情報の注記の無い自然言語のテキストデータから、対象言語の文法や、辞書と呼ばれる単語の品詞等の情報にもとづき、形態素の列に分割し、それぞれの形態素の品詞等を判別する作業である。";

            var tbl = WordLogic.GetBasicTokenTbl(text);

            Assert.AreEqual(34, tbl.Keys.Count);

            var key = tbl.Keys.ToArray().First();

            Assert.AreEqual("形態素解析", key);

            var word = tbl[key].First();

            Assert.AreEqual("形態素解析", word.Word);
            Assert.AreEqual("名詞,一般+サ変接続,*,*,*,*,形態素解析,ケイタイソカイセキ,ケイタイソカイセキ", word.Feature);

            Assert.AreEqual("名詞", word.Type);
            Assert.AreEqual("一般+サ変接続", word.DetailType1);
            Assert.AreEqual("*", word.DetailType2);
            Assert.AreEqual("*", word.DetailType3);
            Assert.AreEqual("*", word.AdaptMethod);
            Assert.AreEqual("*", word.AdaptType);
            Assert.AreEqual("形態素解析", word.BasicWord);
            Assert.AreEqual("ケイタイソカイセキ", word.WayOfRead);
            Assert.AreEqual("ケイタイソカイセキ", word.Pronunciation);

            key = tbl.Keys.ToArray()[tbl.Keys.ToArray().Count() - 2];
            Assert.AreEqual("。", key);

            word = tbl[key].Last();
            Assert.AreEqual("。", word.Word);
            Assert.AreEqual("記号,句点,*,*,*,*,。,。,。", word.Feature);

            Assert.AreEqual("記号", word.Type);
            Assert.AreEqual("句点", word.DetailType1);
            Assert.AreEqual("*", word.DetailType2);
            Assert.AreEqual("*", word.DetailType3);
            Assert.AreEqual("*", word.AdaptMethod);
            Assert.AreEqual("*", word.AdaptType);
            Assert.AreEqual("。", word.BasicWord);
            Assert.AreEqual("。", word.WayOfRead);
            Assert.AreEqual("。", word.Pronunciation);
        }
Esempio n. 12
0
		private void LoadLogic()
		{
			settingsLogic = new SettingsLogic();

			wordLogic = new WordLogic();
			WordList = wordLogic.WordList;

			historyLogic = new HistoryLogic();
			history = historyLogic.LoadHistory<string>();

			Word word;
			if (history.Count > 0)
				word = wordLogic.Search(history.Current);
			else
				word = wordLogic.Search(WordList.FirstOrDefault());

			if (word != null)
				ShowDefinition(word);

			NotifyHistoryChange();
		}
Esempio n. 13
0
        public void 文からトークンリストを取得できること()
        {
            var text = "形態素解析とは、文法的な情報の注記の無い自然言語のテキストデータから、対象言語の文法や、辞書と呼ばれる単語の品詞等の情報にもとづき、形態素の列に分割し、それぞれの形態素の品詞等を判別する作業である。";

            var tokenList = WordLogic.GetTokenList(text);

            Assert.AreEqual(53, tokenList.Count);


            var token = tokenList.First();

            Assert.AreEqual("形態素解析", token.Word);
            Assert.AreEqual("名詞,一般+サ変接続,*,*,*,*,形態素解析,ケイタイソカイセキ,ケイタイソカイセキ", token.Feature);

            Assert.AreEqual("名詞", token.Type);
            Assert.AreEqual("一般+サ変接続", token.DetailType1);
            Assert.AreEqual("*", token.DetailType2);
            Assert.AreEqual("*", token.DetailType3);
            Assert.AreEqual("*", token.AdaptMethod);
            Assert.AreEqual("*", token.AdaptType);
            Assert.AreEqual("形態素解析", token.BasicWord);
            Assert.AreEqual("ケイタイソカイセキ", token.WayOfRead);
            Assert.AreEqual("ケイタイソカイセキ", token.Pronunciation);

            token = tokenList[tokenList.Count - 2];
            Assert.AreEqual("。", token.Word);
            Assert.AreEqual("記号,句点,*,*,*,*,。,。,。", token.Feature);

            Assert.AreEqual("記号", token.Type);
            Assert.AreEqual("句点", token.DetailType1);
            Assert.AreEqual("*", token.DetailType2);
            Assert.AreEqual("*", token.DetailType3);
            Assert.AreEqual("*", token.AdaptMethod);
            Assert.AreEqual("*", token.AdaptType);
            Assert.AreEqual("。", token.BasicWord);
            Assert.AreEqual("。", token.WayOfRead);
            Assert.AreEqual("。", token.Pronunciation);
        }
Esempio n. 14
0
        public NodeReference <Word> InsertNewWord(string wrd)
        {
            WordDataWebUtility wwl = new WordDataWebUtility();
            WordLogic          wl  = new WordLogic();
            PartOfSpeechLogic  pl  = new PartOfSpeechLogic();
            var wordData           = wwl.GetWord(wrd);
            var wordSQLPOS         = pl.GetPOSbyWord(wrd);

            if (wordData != null)
            {
                foreach (var wd in wordData)
                {
                    wordSQLPOS.AddRange(wd.partOfSpeech);
                }
            }
            Word word = new Word();

            word.partOfSpeech = wordSQLPOS;
            word.word         = wrd;


            return(InsertNode(word));
        }
Esempio n. 15
0
 public async void Init()
 {
     mWordLogic = new WordLogic(new PersistentWordManager <Word>(":memory:"));
     await mWordLogic.UpdateWordList();
 }
Esempio n. 16
0
 // Use this for initialization
 void Start()
 {
     wordlogic = new WordLogic();
 }