Beispiel #1
0
 public TextWordsHistory(TextWords tw, System.DateTimeOffset now, int newId)
 {
     id            = newId;
     wordid        = tw.wordid;
     words         = tw.words;
     ArchiveDate   = now;
     textid        = tw.textid;
     AddComma      = tw.AddComma;
     AddDot        = tw.AddDot;
     AddSpace      = tw.AddSpace;
     IsAllCaps     = tw.IsAllCaps;
     IsCapitalized = tw.IsCapitalized;
     IsFootNote    = tw.IsFootNote;
     IsHeader      = tw.IsHeader;
     AddColon      = tw.AddColon;
     AddHyphenMin  = tw.AddHyphenMin;
     Semicolon     = tw.Semicolon;
     LBracket      = tw.LBracket;
     PreSpace      = tw.PreSpace;
     RBracket      = tw.RBracket;
     RParentThesis = tw.RParentThesis;
     LParentThesis = tw.LParentThesis;
     LDQuote       = tw.LDQuote;
     RDQuote       = tw.RDQuote;
     RSQuote       = tw.RSQuote;
     LSQuote       = tw.LSQuote;
     AddSlash      = tw.AddSlash;
     AddGT         = tw.AddGT;
     AddLT         = tw.AddLT;
     AddBang       = tw.AddBang;
     AddSlashAfter = tw.AddSlashAfter;
     QMark         = tw.QMark;
     AddEqual      = tw.AddEqual;
     AddAmp        = tw.AddAmp;
 }
        private void OpenFile()
        {
            var dialog = new OpenFileDialogService(".txt", "Text documents (.txt)|*.txt");

            FilePath = dialog.OpenFile();
            if (!string.IsNullOrEmpty(FilePath))
            {
                IsOpenFileButtonEnabled   = false;
                IsProjectMainPanelEnabled = true;
            }
            var text  = TextFile.ReadFile(FilePath);
            var words = TextWords.GetUniqueWordList(TextWords.FindWords(text));

            foreach (var word in words)
            {
                ProjectTextWords.Add(word);
            }
            OnPropertyChanged("ProjectTextWords");
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="textid"></param>
        /// <param name="w">The single word to be converted to a number</param>
        /// <returns> the new maxid from textwords</returns>
        private async Task CompressRange(Text t, string w,
                                         bool pAddSpace,
                                         bool addDot,
                                         bool addComma,
                                         bool pIsFootNote,
                                         bool pIsHeader,
                                         bool isColon,
                                         bool bAddSemiColon,
                                         bool pIsHyphen,
                                         bool paddLBracket,
                                         bool ppaddRBracket,
                                         bool paddRParenthesis,
                                         bool paddLParenthesis,
                                         bool paddLSQuote,
                                         bool paddRSQuote,
                                         bool paddLDQuote,
                                         bool paddRDQuote,
                                         bool paddLT,
                                         bool paddGT,
                                         bool paddSlash,
                                         bool paddBang, bool addPreSpace, bool pAddQMark, bool pAddSlashAfter, bool pAddEqual,
                                         bool pAddAmp, int langid
                                         )
        {
            //short wordid = 0;
            // we only find case sensitve searches
            IsCapitalized(w, out bool capitalized, out bool allCaps);
            if (capitalized || allCaps)
            {
                w = w.ToLower();
            }
            // numbers can become huge, and thus, waste space!
            bool isNumber  = int.TryParse(w, out int number);
            var  foundWord = await FindWord(w, langid);

            if (foundWord == null)
            {
                foundWord = new words()
                {
                    IsNumber = isNumber,
                    //TODO: make language
                    LangId = (short)langid
                };
                if (isNumber)
                {
                    foundWord.number = number;
                }
                else
                {
                    foundWord.word = w;
                }
                //TODO findout if this is optional, if so, leave out.
                if (maxWordId == null)
                {
                    maxWordId = await _context.Words.MaxAsync(m => m.id.Value);
                }
                maxWordId++;
                foundWord.id = maxWordId;
                if (!isNumber)
                {
                    foundWord.hash = new Models.WordLanguageKey(w, langid).GetHashCode();
                }
                _context.Words.Add(foundWord);
            }
            var wordid = foundWord.id.Value;

            var tw = new TextWords
            {
                id            = ++maxTextWordId,
                textid        = t.textid,
                IsAllCaps     = allCaps,
                AddSpace      = pAddSpace,
                IsFootNote    = pIsFootNote,
                IsHeader      = pIsHeader,
                wordid        = wordid,
                IsCapitalized = capitalized,
                AddComma      = addComma,
                AddDot        = addDot,
                AddColon      = isColon,
                AddHyphenMin  = pIsHyphen,
                LSQuote       = paddLSQuote,
                RSQuote       = paddRSQuote,
                RDQuote       = paddRDQuote,
                LDQuote       = paddLDQuote,
                RParentThesis = paddRParenthesis,
                LParentThesis = paddLParenthesis,
                AddGT         = paddGT,
                AddLT         = paddLT,
                AddSlash      = paddSlash,
                AddBang       = paddBang,
                LBracket      = paddLBracket,
                Semicolon     = bAddSemiColon,
                RBracket      = ppaddRBracket,
                PreSpace      = addPreSpace,
                QMark         = pAddQMark,
                AddSlashAfter = pAddSlashAfter,
                AddEqual      = pAddEqual,
                PrefixAmp     = pAddAmp
            };

            tw.words = foundWord;
            t.TextWords.Add(tw);
        }