public void LoadAbsoluteKeyboardModel(bool pre = false, double prexk = 0f, double prexb = 0f, double preyk = 0f, double preyb = 0f) { absoluteGaussianPair = new GaussianPair[ALPHABET_SIZE]; string[] lines = XFileReader.Read("Absolute-General-Keyboard.txt"); string line = lines[0]; string[] lineArray = line.Split('\t'); double xk = double.Parse(lineArray[0]); double xb = double.Parse(lineArray[1]); double xstddev = double.Parse(lineArray[2]); double yk = double.Parse(lineArray[3]); double yb = double.Parse(lineArray[4]); double ystddev = double.Parse(lineArray[5]); if (pre) { xk = prexk; xb = prexb; yk = preyk; yb = preyb; } for (int i = 0; i < ALPHABET_SIZE; ++i) { Vector2 p = StandardPosition((char)(i + 'a')); absoluteGaussianPair[i] = new GaussianPair(new Gaussian(p.x * xk + xb, xstddev), new Gaussian(p.y * yk + yb, ystddev)); } Debug.Log("Load absolute keyboard GaussianPair : " + absoluteGaussianPair.Length); }
void LoadLanguageModel() { languageModel = new Dictionary <string, double>(); string[] lines = XFileReader.Read("ANC-all-count.txt"); foreach (string line in lines) { string[] lineArray = line.Split(' '); languageModel[lineArray[0]] = double.Parse(lineArray[1]); if (languageModel.Count >= LANGUAGE_MODEL_SIZE) { break; } } Debug.Log("Load language model : " + languageModel.Count); }
void Start() { fileStartTime = DateTime.Now.ToString("yyMMdd-HHmmss"); log = new XFileWriter(this, "log-"); deb = new XFileWriter(this, "deb-", false); SetupServer(); recognition = new Recognition(this); adaption = new Adaption(this, recognition); events = new List <string>(); eventsMutex = new object(); tSample = GameObject.Find("Sample").GetComponent <Text>(); tinputted = GameObject.Find("Inputted").GetComponent <Text>(); tDragItems = new Text[DRAG_ITEM_N]; GameObject canvas = GameObject.Find("Canvas"); for (int i = 0; i < DRAG_ROW; i++) { for (int j = 0; j < DRAG_COLUMN; j++) { GameObject gDragItem = Instantiate(prefabDragItem); gDragItem.transform.position = new Vector3(-150 + j * 105, -15 + i * -35, 700); gDragItem.transform.SetParent(canvas.transform); tDragItems[i * DRAG_COLUMN + j] = gDragItem.GetComponentInChildren <Text>(); } } inputtedWords = new List <string>(); inputtedPoints = new List <Vector2>(); inputtedPointsAll = new List <Vector2[]>(); //sampleSentences = XFileReader.Read("phrases-all-filtered.txt"); sampleSentences = XFileReader.Read("phrases-simple.txt"); for (int i = 0; i < sampleSentences.Length; i++) { sampleSentences[i] = sampleSentences[i].ToLower(); } sampleCnt = -1; UpdateSample(); UpdateInputted(); }