コード例 #1
0
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (e.Parameter.GetType().Equals(typeof(word)))
     {
         word = (word)e.Parameter;
     }
     if (word.Sf_rate < 0)
     {
         for (int i = word.Sf_rate; i < 0; i++)
         {
             SymbolIcon star = new SymbolIcon()
             {
                 Symbol = Symbol.OutlineStar, Foreground = new SolidColorBrush(Windows.UI.Colors.Red), HorizontalAlignment = HorizontalAlignment.Center
             };
             starStackPanel.Children.Add(star);
         }
     }
     else
     {
         if (word.Sf_rate == 0)
         {
             return;
         }
         for (int i = 0; i < word.Sf_rate; i++)
         {
             SymbolIcon star = new SymbolIcon()
             {
                 Symbol = Symbol.SolidStar, Foreground = new SolidColorBrush(Windows.UI.Colors.Blue), HorizontalAlignment = HorizontalAlignment.Center
             };
             starStackPanel.Children.Add(star);
         }
     }
 }
コード例 #2
0
        private void recursiveBuild(List <string> words, int count, word wordHash)
        {
            if (count >= words.Count)
            {
                return;
            }

            if (!wordHash.hasValue)
            {
                wordHash.hasValue = true;
                wordHash.nextWord = new Dictionary <string, word>();
            }

            if (!wordHash.nextWord.ContainsKey(words[count]))
            {
                wordHash.nextWord.Add(words[count], new word()
                {
                    nextWord = new Dictionary <string, word>(), hasValue = false
                });
            }

            wordHash = wordHash.nextWord[words[count]];

            recursiveBuild(words, count + 1, wordHash);
        }
コード例 #3
0
ファイル: Query.cs プロジェクト: TkRsln/Wats-1.0
    public word startQuary(string msg)
    {
        word w     = new word();
        int  start = 0;

        w.main = msg.Substring(0, msg.IndexOf("	", start));
        Debug.Log(w.main + " | " + start);
        start     = msg.IndexOf("	", start) + 1;
        w.explain = msg.Substring(start, msg.IndexOf("	", start) - start);
        Debug.Log(w.explain + " | " + start);
        start   = msg.IndexOf("	", start) + 1;
        w.words = separate(msg.Substring(start, msg.IndexOf("	", start) - start));
        Debug.Log(msg.Substring(start, msg.IndexOf("	", start) - start) + " | " + start);
        start      = msg.IndexOf("	", start) + 1;
        w.sentence = msg.Substring(start, msg.Length - start);
        Debug.Log(w.sentence + " | " + start);

        return(w);


        /*  //Reader 1.0
         * int mode = 0; //0:main / 1:exp / 2:words / 3:sentence
         * word w = new word();
         * w.main = msg.Substring(msg.IndexOf("m:")+2, msg.IndexOf(" ", msg.IndexOf("m:"))- msg.IndexOf("m:")-2);
         * w.explain = msg.Substring(msg.IndexOf("exp:")+4, msg.IndexOf("word:")- msg.IndexOf("exp:")-4);
         * w.words = separate(msg.Substring(msg.IndexOf("word:") + 5, msg.IndexOf("sen:") - 5 - msg.IndexOf("word:")));
         * w.sentence = msg.Substring(msg.IndexOf("sen:")+4,msg.Length- msg.IndexOf("sen:")-4);
         * return w;
         */
    }
コード例 #4
0
ファイル: controller.cs プロジェクト: judyTia/MVC_unity_UI
    // Use this for initialization
    void Start()
    {
        myword  = allWords.Instance;
        myview  = myView.Instance;
        oneword = null;

        /*
         * word AngryWord = new word("Angry", "En colère", "enojado", VersionOfWord.English);
         * word AfterWord = new word("After", "Après", "Después", VersionOfWord.English);
         * word AppleWord = new word("Apple", "Pomme", "manzana", VersionOfWord.English);
         * word AgainWord = new word("Again", "Encore", "De nuevo", VersionOfWord.English);
         * word ALotWord = new word("A Lot", "Beaucoup", "Mucho", VersionOfWord.English);
         *
         * myword.add(AngryWord);
         * myword.add(AfterWord);
         * myword.add(AppleWord);
         * myword.add(AgainWord);
         * myword.add(ALotWord);
         */

        int lengh = addword.Length;

        for (int i = 0; i < lengh; i++)
        {
            addword[i].Setword();
            myword.add(addword[i]);
        }
        myview.setUpItem();
    }
コード例 #5
0
ファイル: trie.cs プロジェクト: sandeva/SriShellPrimo
        void ThreadFunction()
        {
            File.Copy("trie.dat", "out.tmp", true);
            //File.Copy("modified.csv", "modified.tmp", true);
            csvfile      = File.CreateText("modified.tmp");// AppendText("modified.tmp");
            ThreadReader = new BinaryReader(File.OpenRead("out.tmp"));
            ThreadReader.BaseStream.Position = 8;
            bw = new BinaryWriter(File.OpenWrite("out.dat"));
            bw.Write(totalWordCount);
            bw.Write((int)0);
            SavedAt = new Dictionary <int, int>();
            word tmpWord = new word(this);

            tmpWord.grandChildren = new List <int>();
            while (ThreadReader.BaseStream.Position < ThreadReader.BaseStream.Length)
            {
                tmpWord.Load(ThreadReader);
                if (!ThreadParameters.Contains(tmpWord.m_index))
                {
                    SavedAt[tmpWord.m_index] = (int)bw.BaseStream.Position;
                    tmpWord.Save(bw, csvfile, false);
                }
            }
            int x = GetSavedIndex(BaseWord, bw, csvfile, true);

            csvfile.Close();
            bw.BaseStream.Position = 4;
            bw.Write(x);
            bw.Close();
            ThreadReader.Close();
            ThreadParameters.Clear();
        }
コード例 #6
0
        public async Task <IHttpActionResult> Putword(long id, word word)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != word.id)
            {
                return(BadRequest());
            }

            db.Entry(word).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!wordExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #7
0
    public void create(ArrayList mined)
    {
        for (int i = 0; i < mined.Count; i++)
        {
            word     w      = (word)mined[i];
            int      r      = Random.Range(0, 10);
            string   answer = "";//
            string   quest;
            string[] fakes = new string[3];

            #region Question & Answers
            if (r <= 7)
            {
                for (int a = 0; a < w.words.Length; a++)
                {
                    quest  = w.explain + (" <color=cyan>-" + w.words[a].id).Replace("0", "Noun").Replace("1", "verb").Replace("2", "Adjective").Replace("3", "Antonym").Replace("4", "Synonym").Replace("5", "Adverb") + "</color>";
                    answer = w.words[a].word;
                    fakes  = getRandomAnswers(w, answer, mined);
                    quests.Add(new Question(quest, answer, fakes));
                }
            }
            else
            {
                quest  = w.sentence.Replace(w.main, "_ _ _ _");
                answer = w.main;
                fakes  = getRandomAnswers(w, answer, mined);
                quests.Add(new Question(quest, answer));

                // BURADAN SİLİNDİ
            }
            #endregion
        }
    } //*/
コード例 #8
0
ファイル: trie.cs プロジェクト: sandeva/SriShellPrimo
 void Add2Set(List <word> l, word w)
 {
     if (!l.Contains(w))
     {
         l.Add(w);
     }
 }
コード例 #9
0
ファイル: word.cs プロジェクト: sandeva/SriShellPrimo
            static public word DummyWord(string s, int count)
            {
                word r = DummyWord(s);

                r.count = count;
                return(r);
            }
コード例 #10
0
ファイル: word.cs プロジェクト: sandeva/SriShellPrimo
            static public word DummyWord(string s)
            {
                word r = new word();

                r.m_word = s;
                return(r);
            }
コード例 #11
0
ファイル: trie.cs プロジェクト: sandeva/SriShellPrimo
 void xCountCalc(word w)
 {
     w.xCount = 0;
     foreach (int chr in variations.SplitIntoChars(w.ToString()))
     {
         w.xCount -= CharCounts[chr];
     }
 }
コード例 #12
0
        //Break self into a list of words
        private void parseWords()
        {
            string curSentence = "";
            search cur         = search.Start;

            for (int i = 0; i < data.Length; i++)
            {
                char curChar = data[i];
                if (curChar.Equals('@'))
                {
                    if (cur == search.Start)
                    {
                        cur = search.End;
                    }
                    else
                    {
                        string spawnTimer = "";
                        for (int j = i + 1; j < i + 6 + 4; j++)
                        {
                            spawnTimer += data[j];
                        }
                        i  += 5;
                        cur = search.Start;
                        //Store sentence

                        string minuteVal      = (spawnTimer[0].ToString() + spawnTimer[1].ToString());
                        string secondVal      = (spawnTimer[3].ToString() + spawnTimer[4].ToString());
                        string millisecondVal = ((spawnTimer[6]).ToString() + (spawnTimer[7]).ToString() + (spawnTimer[8]).ToString());
                        //I believe I have to add in the microsecond value
                        float spawnInSeconds = (float.Parse(minuteVal) * 60) + float.Parse(secondVal) + float.Parse(millisecondVal) / 1000f;

                        word w = new word(curSentence, spawnInSeconds);
                        wordList.Add(w);
                        totalWords++;
                        // Debug.Log("New word: " + curSentence);
                        // Debug.Log("Spawn time: " + spawnInSeconds);

                        curSentence = "";
                    }
                }
                else
                {
                    string[] numbers  = { "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", ":" };
                    bool     contains = false;
                    foreach (string s in numbers)
                    {
                        if (s.Equals(curChar.ToString()))
                        {
                            contains = true;
                        }
                    }
                    if (!contains)
                    {
                        curSentence += curChar;
                    }
                }
            }
        }
コード例 #13
0
    public string getStringAtTime(float goalSecond)
    {
        //Find the earliest sentence with a 'word' at that time
        //Make that word italicized to mark it
        float    foundWordDistance = 100f; //The distance
        sentence foundSentence     = null;
        word     foundWord         = null;

        foreach (sentence s in allSentences)
        {
            foreach (word w in s.wordList)
            {
                //Seconds is our target time
                //10 (target)
                //10.5 (word)
                //Finds the closest word to our taget time
                if (w.spawnSecond > goalSecond)
                {
                    continue;
                }
                float wordDistance = Mathf.Abs(w.spawnSecond - goalSecond);
                if (wordDistance > 2.0f)
                {
                    continue;
                }
                if (wordDistance < foundWordDistance)
                {
                    foundWordDistance = wordDistance;
                    foundSentence     = s;
                    foundWord         = w;
                }
            }
        }

        string retString = "";

        if ((foundSentence != null) && (foundWord != null))
        {
            foreach (word w in foundSentence.wordList)
            {
                if (w == foundWord)
                {
                    retString += "<b>";
                    retString += w.text;
                    retString += "</b>";
                }
                else
                {
                    retString += w.text;
                }
            }
        }

        retString = retString.Replace("\n", string.Empty);
        return(retString);
    }
コード例 #14
0
ファイル: trie.cs プロジェクト: sandeva/SriShellPrimo
        void xCountCalcAll(int w, double p)
        {
            word x = GetIndexedWord(w);

            x.xCount = -p;
            foreach (KeyValuePair <int, int> c in x.children)
            {
                xCountCalcAll(c.Value, CharCounts[c.Key] + p);
            }
        }
コード例 #15
0
        public async Task <IHttpActionResult> Getword(long id)
        {
            word word = await db.words.FindAsync(id);

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

            return(Ok(word));
        }
コード例 #16
0
        public async Task <IHttpActionResult> Postword(word word)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.words.Add(word);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = word.id }, word));
        }
コード例 #17
0
ファイル: trie.cs プロジェクト: sandeva/SriShellPrimo
        public void List2Trie(string filename)
        {
            CharCounts = new Dictionary <int, double>();
            double totalCharCount = 0;

            for (int i = 0; i < variations.Chars.Count; i++)
            {
                CharCounts[i] = 1;
            }
            allWords     = new Dictionary <int, word>();
            allWords[-1] = new word(-1, this);
            BaseWord     = -1;


            string[]      a_splited_words = File.ReadAllLines("splited.csv");
            List <string> splited_words   = new List <string>(a_splited_words);
            int           c = 0;

            totalWordCount = 0;
            foreach (string s in splited_words)
            {
                c++;
                Match m = Regex.Match(s, "(.*?),([0-9]+)");
                if (m.Groups.Count == 3)
                {
                    string     str  = m.Groups[1].ToString();
                    List <int> chrs = variations.SplitIntoChars(str);
                    int        cnt  = Convert.ToInt32(m.Groups[2].ToString());
                    totalWordCount += cnt;
                    foreach (int i in chrs)
                    {
                        CharCounts[i] += cnt;
                    }
                    totalCharCount += chrs.Count * cnt;
                    GetIndexedWord(BaseWord).Add(chrs, cnt, str);
                }
            }
            BinaryWriter bw = new BinaryWriter(File.OpenWrite("charprobabilities.dat"));
            string       charprobabilities = "";

            for (int i = 0; i < variations.Chars.Count; i++)
            {
                CharCounts[i]      = Math.Log(CharCounts[i]) - Math.Log(totalCharCount);
                charprobabilities += variations.Chars[i] + "," + CharCounts[i].ToString() + "\n";
                bw.Write(CharCounts[i]);
            }
            bw.Close();
            File.WriteAllText("charprobabilities.csv", charprobabilities);
            xCountCalcAll(BaseWord, 0);


            Save(filename, "modified.csv");
        }
コード例 #18
0
ファイル: MainPage.xaml.cs プロジェクト: taiyangzhishen/aa
        public async void add(string t, string p)
        {
            db = new SQLiteAsyncConnection("Word.db");
            await db.CreateTableAsync <word>();

            word newWord = new word {
                Title = title.Text, _passage = newPassage.Text
            };
            await db.InsertAsync(newWord);

            listView.ItemsSource = list;
        }
コード例 #19
0
 private void expandlayoutarray(int newcount)
 {
     word[] newarray = new word[newcount];
     if (layout != null && layout.Length > 0)
     {
         for (int i = 0; i < layout.Length; ++i)
         {
             newarray[i] = layout[i];
         }
     }
     layout = newarray;
 }
コード例 #20
0
    public void changePaper(word myword)
    {
        string mykeyname     = myword.getEnSpelling();
        string mykeytrimname = mykeyname.Replace(" ", "");
        string mysymbolname  = myword.getSymbol();

        mysymbol.sprite         = GetSpriteByName(mysymbolname);
        myspelling.text         = myword.getSpelling();
        myEN_FR.sprite          = getVersionSprite(myword.getVersion());
        myfavorite_click.sprite = getFavoriteSprite(myword.getFavorite());
        AudioClip nowwordAudio = Resources.Load <AudioClip>("Signs" + mykeytrimname);
    }
コード例 #21
0
        private const float cstHyphenationTreshold = 0.25F; /* percents of horizontal line extent */

        private void expandwordsarray(int newcount)
        {
            word[] newarray = new word[newcount];
            if (words != null && words.Length > 0)
            {
                for (int i = 0; i < words.Length; ++i)
                {
                    newarray[i] = words[i];
                }
            }
            words = newarray;
        }
コード例 #22
0
 public void ShowPaper(word myword)
 {
     changePaper(myword);
     if (myparperAni.enabled)
     {
         myparperAni.SetTrigger("open");
     }
     else
     {
         createAnimation.Instance.openPaper();
     }
 }
コード例 #23
0
 private void AddWord(bool isWhitespace, bool isLineBreak, int iStart, int iEnd, string sX)
 {
     expandwordsarray(ctWords + 1);
     /* shortcut helper proc */
     words[ctWords]              = new word();
     words[ctWords].isContent    = ((!isWhitespace) && (!isLineBreak));
     words[ctWords].isWhiteSpace = isWhitespace;
     words[ctWords].isLineBreak  = isLineBreak;
     words[ctWords].iStart       = iStart;
     words[ctWords].iEnd         = iEnd;
     words[ctWords].sX           = sX;
     ctWords++;
 }
コード例 #24
0
    // sound and animation
    public void playWordSound(word myword)
    {
        print("sound");
        if (mycharacterAni != null)
        {
            mycharacterAni.SetTrigger(myword.getanimationCharater());
        }
        string    mykeyname    = myword.getsound();
        AudioClip nowwordAudio = Resources.Load <AudioClip>("Signs/" + mykeyname);

        myWordSound.clip = nowwordAudio;
        myWordSound.PlayDelayed(myword.delaySound);
    }
コード例 #25
0
        public async Task <IHttpActionResult> Deleteword(long id)
        {
            word word = await db.words.FindAsync(id);

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

            db.words.Remove(word);
            await db.SaveChangesAsync();

            return(Ok(word));
        }
コード例 #26
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            string kata = wordText.Text;

            if (words.Count < 9)
            {
                word wtemp = new word(kata);
                words.Add(wtemp);
                worddDGV.Rows.Add(wtemp);
            }
            else
            {
                MessageBox.Show("Kata sudah 10!");
            }
        }
コード例 #27
0
ファイル: allWords.cs プロジェクト: judyTia/MVC_unity_UI
    public word BackRandomOneWord(word oneword)
    {
        word mywordkey;

        if (randomLeftHistory.Count == 0)
        {
            mywordkey = RandomOneWord();
        }
        else
        {
            mywordkey = randomLeftHistory.Pop();
        }
        randomRight.Push(oneword);

        return(mywordkey);
    }
コード例 #28
0
ファイル: trie.cs プロジェクト: sandeva/SriShellPrimo
        find_return find(word w, string s, double p, find_return r /*bool NoTrvelProb*/)
        {
            if (w == null)
            {
                return(r);
            }
            string key = w.m_index.ToString() + s;

            if (r.TravelProbabilies.ContainsKey(key) &&
                p < r.TravelProbabilies[key])
            {
                return(r);
            }
            r.TravelProbabilies[key] = p;
            if (s == "")
            {
                r.Add2CompletesPartials(w, p);
            }
            else
            {
                r.Add2Bigrams(s, w, p);
            }
            Dictionary <int, List <List <int> > > consumes = variations.consume(s);

            foreach (int i in consumes.Keys)
            {
                foreach (List <int> candidate in consumes[i])
                {
                    word   tmp = w;
                    double pv  = variations.GetProbability(variations.MergeChars(candidate), s.Substring(0, i));
                    foreach (int c in candidate)
                    {
                        if (tmp.children.ContainsKey(c))
                        {
                            tmp = GetIndexedWord(tmp.children[c]);
                        }
                        else
                        {
                            tmp = null;
                            break;
                        }
                    }
                    find(tmp, s.Substring(i), p + pv, r);
                }
            }
            return(r);
        }
コード例 #29
0
ファイル: allWords.cs プロジェクト: judyTia/MVC_unity_UI
    public word ForwardRandomWord(word oneword)
    {
        word mywordkey;

        if (randomRight.Count == 0)
        {
            mywordkey = RandomOneWord();
        }
        else
        {
            mywordkey = randomRight.Pop();
        }
        if (oneword != null)
        {
            randomLeftHistory.Push(oneword);
        }
        return(mywordkey);
    }
コード例 #30
0
ファイル: trie.cs プロジェクト: sandeva/SriShellPrimo
 public void Add2CompletesPartials(word w, double TravelProbability)
 {
     if (w.count != 0)
     {
         if (Completes.Contains(w))
         {
             w.TravelProbability = Math.Max(w.TravelProbability, TravelProbability);
         }
         else
         {
             Completes.Add(w);
             w.TravelProbability = TravelProbability;
             //TravelProbabilities[w.ToString()+":"+u] = TravelProbability;
         }
         //Console.WriteLine("{0} {1}",w, TravelProbability);
     }
     Add2Partials(w);
 }