דילוג לתוכן
  • דף הבית
  • קטגוריות
  • פוסטים אחרונים
  • משתמשים
  • חיפוש
  • חוקי הפורום
כיווץ
תחומים

תחומים - פורום חרדי מקצועי

💡 רוצה לזכור קריאת שמע בזמן? לחץ כאן!
pcinfogmachP

pcinfogmach

@pcinfogmach
אודות
פוסטים
729
נושאים
189
שיתופים
0
קבוצות
0
עוקבים
3
עוקב אחרי
1

פוסטים

פוסטים אחרונים הגבוה ביותר שנוי במחלוקת

  • תוכנה לחיפוש בתוך מסמכים כדוגמת החיפוש של אוצר החכמה עם תרגום מלא לעברית וממשק מימין לשמאל
    pcinfogmachP pcinfogmach

    @אפרים22
    האם אתה מנסה לאנדקס מסמכי וורד.
    בזמנו כשדיברנט עם המפתח הוא אמר שאם מאנדקסים מסמכי וורד זה מאוד מכביד על האינדוקס כי אין לו את הכלים לעשות זאת בצורה ישירה (לשמור על העיצוב) ללא המרה קודם לpdf.
    הייתי ממליץ לך להישאר עם השימוש לה נועד התוכנה דהיינו מסמכי טקסט פשוטים ומסמכי Pdf.

    תוכנה

  • ביצוע פרקטי לאינדוקס מאגר טקסט עברי
    pcinfogmachP pcinfogmach

    @dovid כתב בביצוע פרקטי לאינדוקס מאגר טקסט עברי:

    אני צריך ערובה שהשקעתי בתשובה לא תירד לטמיון.
    גם מאוד מפריע לי הפיזור שלך בשאלות, זה נראה שאתה בלחץ אטומי. תברר דבר דבר, תעיין תבין ותחכים.

    לגבי הערובה אני נמצא במקום של התלמיד כך שהשאלה היא האם התלמיד יכול להגיד לרב שמה שהוא אומר זה יעיל לו או לא? לבינתיים לא איכזבת אז אני מאמין בך. אם נגיע לתוצאות שאפשר להשתמש בהם ברור שאשתמש בזה.
    האמת היא שאני עדיין מנסה לעכל את זה שיש פה מישהו שמוכן ככה לעזור בחפשיות (אם לא אשגע אותו מדאי הרבה). VBA הייתי צריך ללמוד לבד והדרך הייתה מפותלת ומעניינת. (היה לי שם חברותא אבל לא "רב").

    לחץ אטומי ממש לא - פשוט ככה הראש שלי עובד אני מבין דברים הפוך, לא מההתחלה לסוף אלא מהסוף להתחלה הריכוז שלי ג"כ עובד בצורה מעניינת כלומר שהריכוז שלי מאוד ממוקד - סוג של חפרפרת שפשוט נדבק על משהו עד שהוא מגיע לאשורו (גם הנקיונות שלי לשבת נראים ככה - וזה משגע את אישתי...) (מכיון שראית את התפתחות חלק מהפוסטים שלי אני חושב שאתה יכול לקבל תמונה קצת על מה אני מדבר).
    כל זה לא אומר שאני לא יכול לעבוד בצורה מסודרת אם צריך. אשתדל להישאר כאן בפוסט זה ולא לפזר שאלות לכל עבר.

    דבר ראשון החיפוש הוא לא הגיוני, הטבלה הרי מכילה מילים בודדות, לא ביטוי (של יותר ממילה).

    את זה אני יודע - הבדיקה היתה על חיפוש של מילה אחת כדי לבדוק מהירות שליפה.

    לגבי הסימות וכו' הסיבה היא בגלל שאני אוהב לבדוק מקרי קצה לפני שאני נכנס לעובי הקורה. אולי אתה צודק ואי אפשר לשפוט יעילות לפי מקרי קצה. למרות שבפרוייקט שלי השימוש בסיומות וכו' אמור להיות די מצוי.

    למעשה עשיתי עכשיו בדיקה ללא הסיומות ולא היה שום הבדל מצד המהירות

    command.Parameters.Add(new SQLiteParameter("@searchTerm", searchTerm));
    
    תכנות

  • ביצוע פרקטי לאינדוקס מאגר טקסט עברי
    pcinfogmachP pcinfogmach

    @dovid
    אשמח אם תפשיט לי את המילים "פרמטרי האחזור". מה בדיוק החסרון בFTS המהירות? או אולי כוונתך לאיך התוצאות יוצגו?


    למעשה ישבתי על SQLITE קצת לא יודע למה כל כך הסתבכתי לפני זה עם התכנות הבסיסי אכן זה די פשוט. (הוספתי פה גם רכיבים כדי להקל על מי שרוצה לראות את התוצאה הסופית).
    התוצאות שקיבלתי - אינדוקס די מהיר - אבל חיפוש קצת איטי אולי שיטת החיפוש שלי לא טובה? (השתמשתי ב-סריקה מלאה כדי לאפשר חיפוש לא מדויק)

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.SQLite;
    using System.Globalization;
    using System.IO;
    using System.Linq;
    using System.Reflection;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Windows.Forms;
    using static System.Windows.Forms.VisualStyles.VisualStyleElement;
    
    namespace WindowsFormsApp1
    {
        public partial class Form1 : Form
        {
            private System.Windows.Forms.Button buttonProcessFile;
            private System.Windows.Forms.Button buttonViewTable;
            private System.Windows.Forms.TextBox textBoxResult;
            private System.Windows.Forms.ProgressBar progressBar;
            private System.Windows.Forms.ProgressBar progressBar2;
            private System.Windows.Forms.Button buttonSearch;
            private DataGridView dataGridViewSearchResults;
            private System.Windows.Forms.TextBox textBoxSearch;
            public Form1()
            {
                InitializeComponent();
                InitializeDynamicControls();
            }
    
            private void InitializeDynamicControls()
            {
                // Create a Button for processing
                buttonProcessFile = new System.Windows.Forms.Button();
                buttonProcessFile.Text = "Process Text File";
                buttonProcessFile.Location = new System.Drawing.Point(12, 12);
                buttonProcessFile.Click += buttonProcessFile_Click;
                this.Controls.Add(buttonProcessFile);
    
    
                // Create a Button for processing
                buttonViewTable = new System.Windows.Forms.Button();
                buttonViewTable.Text = "View";
                buttonViewTable.Location = new System.Drawing.Point(100, 12);
                buttonViewTable.Click += buttonViewTable_Click;
                this.Controls.Add(buttonViewTable);
               
    
                //create progressbar 
                //progressBar = new System.Windows.Forms.ProgressBar();
                //progressBar.Dock = DockStyle.Bottom;
                //this.Controls.Add(progressBar);
    
                //create progressbar 
                progressBar2 = new System.Windows.Forms.ProgressBar();
                progressBar2.Dock = DockStyle.Bottom;
                this.Controls.Add(progressBar2);
    
                // Create a TextBox for displaying results
                textBoxResult = new System.Windows.Forms.TextBox();
                textBoxResult.Multiline = true;
                textBoxResult.ScrollBars = ScrollBars.Vertical;
                textBoxResult.Size = new System.Drawing.Size(400, 200);
                textBoxResult.Location = new System.Drawing.Point(12, 50);
                this.Controls.Add(textBoxResult);
    
                // Create a TextBox for entering search terms
                textBoxSearch = new System.Windows.Forms.TextBox();
                textBoxSearch.Location = new System.Drawing.Point(200, 12);
                this.Controls.Add(textBoxSearch);
    
                // Create a Button for initiating the search
                buttonSearch = new System.Windows.Forms.Button();
                buttonSearch.Text = "Search";
                buttonSearch.Location = new System.Drawing.Point(300, 12);
                buttonSearch.Click += buttonSearch_Click;
                this.Controls.Add(buttonSearch);
    
                // Create a DataGridView for displaying search results
                dataGridViewSearchResults = new DataGridView();
                dataGridViewSearchResults.Dock = DockStyle.Bottom;
                this.Controls.Add(dataGridViewSearchResults);
    
            }
    
            private void buttonSearch_Click(object sender, EventArgs e)
            {
                string searchTerm = textBoxSearch.Text.Trim();
                if (string.IsNullOrWhiteSpace(searchTerm))
                {
                    MessageBox.Show("Please enter a search term.");
                    return;
                }
    
                string databaseFilePath = GetDatabaseFilePath();
    
                using (SQLiteConnection connection = new SQLiteConnection($"Data Source={databaseFilePath};Version=3;"))
                {
                    connection.Open();
    
                    using (SQLiteCommand command = new SQLiteCommand("SELECT * FROM WordData WHERE Word LIKE @searchTerm;", connection))
                    {
                        command.Parameters.Add(new SQLiteParameter("@searchTerm", "%" + searchTerm + "%"));
    
                        using (SQLiteDataAdapter adapter = new SQLiteDataAdapter(command))
                        {
                            DataTable dataTable = new DataTable();
                            adapter.Fill(dataTable);
    
                            // Display the search results in the DataGridView
                            dataGridViewSearchResults.DataSource = dataTable;
                        }
                    }
                }
            }
    
            static string GetDatabaseFilePath()
            {
                // Get the path to the executable directory
                string programFolder = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
                return Path.Combine(programFolder, "your-database-file.sqlite");
            }
    
    
            private void buttonProcessFile_Click(object sender, EventArgs e)
            {
                // Create or open the SQLite database
                string databaseFilePath = GetDatabaseFilePath();
                using (SQLiteConnection connection = new SQLiteConnection($"Data Source={databaseFilePath};Version=3;"))
                {
                    connection.Open();
    
                    // Create a table to store word data
                    CreateTable(connection);
    
                    // Let the user choose a folder to scan for text files
                    string folderPath = GetFolderPath();
    
                    if (folderPath != null)
                    {
                        ProcessFolder(connection, folderPath);
                        textBoxResult.AppendText("Data saved to SQLite table." + Environment.NewLine);
                    }
                    else
                    {
                        textBoxResult.AppendText("No folder selected. Exiting..." + Environment.NewLine);
                    }
                }
            }
    
            private string GetFolderPath()
            {
                using (FolderBrowserDialog folderDialog = new FolderBrowserDialog())
                {
                    folderDialog.Description = "Select a folder to scan for text files.";
                    DialogResult result = folderDialog.ShowDialog();
    
                    if (result == DialogResult.OK)
                    {
                        return folderDialog.SelectedPath;
                    }
                    else
                    {
                        return null; // User canceled the folder selection
                    }
                }
            }
    
            private void ProcessFolder(SQLiteConnection connection, string folderPath)
            {
                string[] textFiles = Directory.GetFiles(folderPath, "*.txt", SearchOption.AllDirectories);
    
                progressBar2.Maximum = textFiles.Length;
                progressBar2.Value = 0;
                int fileCount = 0;
    
                foreach (string textFilePath in textFiles)
                {
                    ProcessTextFile(connection, textFilePath);
                    fileCount++;
                    progressBar2.Value++;
                }
    
                textBoxResult.AppendText($"Processed {fileCount} text files and saved data to SQLite table." + Environment.NewLine);
            }
    
            private void ProcessTextFile(SQLiteConnection connection, string textFilePath)
            {
                // Read the text file using Windows-1255 encoding
                string[] lines = File.ReadAllLines(textFilePath, Encoding.GetEncoding(1255));
                //progressBar.Value = 0;
                //progressBar.Maximum = lines.Length;
                int lineNumber = 1;
    
                List<WordData> wordDataList = new List<WordData>();
    
                // Regular expression to match Hebrew characters
                Regex hebrewRegex = new Regex(@"\p{IsHebrew}+(?<=\p{IsHebrew})\""(?=\p{IsHebrew})\p{IsHebrew}+|\p{IsHebrew}{2,}");
    
                foreach (string line in lines)
                {
                    // Use the regular expression to match and extract Hebrew words
                    MatchCollection matches = hebrewRegex.Matches(line);
    
                    foreach (Match match in matches)
                    {
                        string word = NormalizeHebrewText(match.Value);
    
                        // Add word data to the list
                        wordDataList.Add(new WordData
                        {
                            Word = word,
                            LineNumber = lineNumber,
                            FileName = textFilePath
                        });
                    }
    
                    lineNumber++;
                    //if (progressBar.Value < progressBar.Maximum)
                    //{ progressBar.Value++; }
                    
                }
    
                //// Sort the words using Hebrew culture
                //wordDataList.Sort((a, b) => string.Compare(a.Word, b.Word, new CultureInfo("he-IL"), CompareOptions.None));
    
                // Insert all word data into the SQLite table at once
                InsertWordDataBatch(connection, wordDataList);
    
                textBoxResult.AppendText($"{textFilePath} Processed {lines.Length} lines and saved data to SQLite table." + Environment.NewLine);
            }
    
            private string NormalizeHebrewText(string text)
            {
                // Normalize Hebrew text (e.g., remove diacritics)
                // You may need to implement this normalization based on your specific requirements.
                // Example: Normalize to remove diacritics (NFD normalization)
                text = new string(text.Normalize(NormalizationForm.FormD).Where(c => char.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark).ToArray()); // Normalize Hebrew text.
                return text; // Return the normalized text.
            }
    
    
    
    
            static void CreateTable(SQLiteConnection connection)
            {
                using (SQLiteCommand command = new SQLiteCommand(
                    "CREATE TABLE IF NOT EXISTS WordData (Word TEXT, LineNumber INT, FileName TEXT);", connection))
                {
                    command.ExecuteNonQuery();
                }
            }
    
            static void InsertWordDataBatch(SQLiteConnection connection, List<WordData> wordDataList)
            {
                using (SQLiteCommand command = new SQLiteCommand(connection))
                {
                    // Start a transaction for batch insert
                    using (var transaction = connection.BeginTransaction())
                    {
                        command.CommandText = "INSERT INTO WordData (Word, LineNumber, FileName) VALUES (@word, @lineNumber, @fileName);";
                        command.Parameters.Add(new SQLiteParameter("@word", DbType.String));
                        command.Parameters.Add(new SQLiteParameter("@lineNumber", DbType.Int32));
                        command.Parameters.Add(new SQLiteParameter("@fileName", DbType.String));
    
                        foreach (var wordData in wordDataList)
                        {
                            command.Parameters["@word"].Value = wordData.Word;
                            command.Parameters["@lineNumber"].Value = wordData.LineNumber;
                            command.Parameters["@fileName"].Value = wordData.FileName;
    
                            // Add the command to the transaction
                            command.ExecuteNonQuery();
                        }
    
                        // Commit the transaction to perform the batch insert
                        transaction.Commit();
                    }
                }
            }
    
            private void buttonViewTable_Click(object sender, EventArgs e)
            {
                string databaseFilePath = GetDatabaseFilePath();
    
                using (SQLiteConnection connection = new SQLiteConnection($"Data Source={databaseFilePath};Version=3;"))
                {
                    connection.Open();
    
                    using (SQLiteCommand command = new SQLiteCommand("SELECT * FROM WordData;", connection))
                    {
                        using (SQLiteDataAdapter adapter = new SQLiteDataAdapter(command))
                        {
                            DataTable dataTable = new DataTable();
                            adapter.Fill(dataTable);
    
                            // Create a new form to display the table
                            Form tableForm = new Form();
                            tableForm.Text = "WordData Table Contents";
    
                            // Create a DataGridView control and set its properties
                            DataGridView dataGridView = new DataGridView();
                            dataGridView.Dock = DockStyle.Fill;
                            dataGridView.DataSource = dataTable;
    
                            // Add the DataGridView to the form
                            tableForm.Controls.Add(dataGridView);
    
                            // Show the form as a dialog
                            tableForm.ShowDialog();
                        }
                    }
                }
            }
    
    
    
    
            public class WordData
            {
                public string Word { get; set; }
                public int LineNumber { get; set; }
                public string FileName { get; set; }
            }
    
        }
    }
    

    ועוד שאלה:

    @dovid כתב בביצוע פרקטי לאינדוקס מאגר טקסט עברי:

    לגבי הפרוייקט שלכם תוכלו לבנות רשימת מילים, ולהכניס לטבלה את הפרטים הבאים:
    המילה, מס' ספר, מס' שורה/פסקה, מיקום
    בטבלה אחרת להכניס את הנתונים עצמם לשליפה מהירה של פסקאות של ספרים, ככה:
    מס' פסקה (מספר רץ), פסקה, מס' ספר

    לא הצלחתי למצוא את המכנה המשותף בין שני הטבלאות שמאפשר לי להצליב בין המידע שאקבל מטבלה א' לצורך טבלה ב'.
    אולי עם דוגמא קצרה אוכל לרדת לסוף דעתך.

    תכנות

  • גמ"ח עזרה בvba מאקרו - עבור תוכנת וורד
    pcinfogmachP pcinfogmach

    מכיוון שלא ראיתי מישהו שסידר את הנושא לכן אמרתי אעלה פה קצת מה שאספתי מנסיוני.
    מי שיש לו שאלות יכול לפנות אלי במייל (שם משתמש בגימייל) - ללא התחייבות. וכמובן שאפשר גם לפתוח פוסט כאן בפורום ולהרוויח את הידע הכללי של החברים היקרים.

    תוכלו לעיין בנושאים אלו בתור התחלה.

    • קורסים למתחילים VBA
    • איך ליצור יוזרפורם userform
    • איך להכין תוסף לוורד בקלות מהקודים שלכם
    • איך להתקין קוד מאקרו בתוך תבנית
    • אוסף קודים שימושיים
    • אוסף תבניות מאקרו
    • תוסף לוורד עם המון קודים שימושיים (התוסף חינמי ואפשר להשתמש בקודים ללא הגבלה)
    • ידיעה חשובה ב-VBA: ביטול פעולה אחרונה למאקרו שלם כיחידה אחת
    • איך למנוע מסך לבן מפקודות מאקרו ארוכות: VBA

    מי שמכיר עוד קישורים שימושיים שיכתוב לתועלת הציבור אשמח להוסיף בפוסט המקור בלי נדר.

    תוכנה

  • הסתעפות מייצור אינדקס - עזרה בקידוד C#
    pcinfogmachP pcinfogmach

    @dovid כתב בביצוע פרקטי לאינדוקס מאגר טקסט עברי:

    במילים אחרות אם אתה לא רוכש, אז אולי גם אל תשאל...

    אולי תסביר לי עוד קצת(או שאולי כדאי לפתוח אשכול חדש על זה): אפשר לתכנת שם תוכנה שלימה (והאם זה מומלץ) או רק לבדוק קודים? ומה בדיוק יש שם שאין למי שיש לו למשל chatgpt? וכמה שונה התיכנות שם מvisual studio?

    תכנות

  • הסתעפות מייצור אינדקס - עזרה בקידוד C#
    pcinfogmachP pcinfogmach

    @dovid
    אשריכם ישראל!
    שאלה: אם הבנתי נכון המעלה בlinqpad זה שאני יכול לבדוק את הקודים שלי במהירות?
    ועוד שאלה: הגירסה החינמית לא מספיק?

    תכנות

  • הסתעפות מייצור אינדקס - עזרה בקידוד C#
    pcinfogmachP pcinfogmach

    @dovid
    אני יודע C# בסיסי (היה גם חלק דברים שתיכנתתי בעצמי בתוסף - רק שמסיבות אישיות אני החלטתי לשים לעצמי גבול כמה אני הולך לתכנת) הבעיה היא ברגע שמתחילים לדבר איתי על מושגים מעולם התיכנות שאני לא נפגשתי בהם בלמידה העצמית שלי. וכל מה שהמתכנת אומר זה (זה מורכב מאוד ונאנח לו ככה)...

    תכנות

  • הסתעפות מייצור אינדקס - עזרה בקידוד C#
    pcinfogmachP pcinfogmach

    @dovid כתב בביצוע פרקטי לאינדוקס מאגר טקסט עברי:

    @pcinfogmach הקוד שהבאתי עדיין איטי? או שלא נמצא עוד האיש שיטמיע אותו?
    אתם צוות של אלף איש?

    התושבה היא - קצת משניהם.
    המפתח לא מעוניין כ"כ בפיתוח הוא מאוד עמוס זה אני שדוחף אותו לפרוייקט ועוד כמה כך שכל בעיה שצצה בעצם נופלת עלי.
    לבינתיים הקוד שהבאת לא עבד לנו אבל עוד לא התייאשנו לגמרי אולי כשיהיה למפתח יותר זמן אם יהיה לו.... הוא ישב על זה שוב.

    תכנות

  • ביצוע פרקטי לאינדוקס מאגר טקסט עברי
    pcinfogmachP pcinfogmach

    @dovid כתב בביצוע פרקטי לאינדוקס מאגר טקסט עברי:

    @yossiz הטכניקה שציינת מייתרת את כל הנושא (במקום לבנות אינדקסים, לשמור את התוכן כולו בעמודה עם FTS וגמרנו).
    אני לא הצעתי את זה כי לזכרוני זה טוב רק לאנגלית וגם אז זה לחיפושים "סטנדרטיים" ולא נותן חופש למפתח כמה להיות משוכלל.

    תרשו לי לשאול מהי בדיוק הטכניקה החדשנית של yossiz ואיך היא מייתרת את כל הנושא?
    האם למעשה היא מייתרת או רק תיאורטית?

    הצצתי בהצעות ש @yossiz נתן ונראה שם שהוא עובד עם העקרון של lucene ובני משפחתו הבעיה עם זה שהם לא עומדים בקצב כאשר צריך להציג הרבה תוצאות. משא"כ אינדקס לבינתיים לפי מה שבדקנו דוקא כן עומד בזה. למרות שלבינתיים עוד לא מצאנו צורה מושלמת ליצור אינדקס.

    תכנות

  • שאלה: מישהו יודע איזה קוד regex עושים לחיפוש מילה עם ניקוד או טעמים?
    pcinfogmachP pcinfogmach

    שאלה: מישהו יודע איזה קוד regex עושים לחיפוש מילה עם ניקוד או טעמים?

    תכנות

  • ביצוע פרקטי לאינדוקס מאגר טקסט עברי
    pcinfogmachP pcinfogmach

    @dovid
    תודה רבה על המענה הנפלא!

    יצרנו תוכנה בסיסית לבדוק את sqlite
    הבעיה שהאטיות שלו בבניית האינדקס פשוט לא פרקטית

    אולי אנחנו לא בנינו את הקוד נכון?
    בכל אופן מצו"ב הקוד בc# אם מישהו יכול לעזור

    using System;
    using System.Data.SQLite;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Windows.Forms;
    
    namespace TestSqlite
    {
        public partial class Form1 : Form
        {
            private ProgressBar progressBar;
            private Label progressLabel;
    
            public Form1()
            {
                InitializeComponent();
                InitializeUI();
            }
    
            private void InitializeUI()
            {
                Button startIndexingButton = new Button();
                startIndexingButton.Text = "Start Indexing";
                startIndexingButton.Click += StartIndexingButton_Click;
                startIndexingButton.Dock = DockStyle.Top;
    
                progressBar = new ProgressBar();
                progressBar.Dock = DockStyle.Bottom;
    
                progressLabel = new Label();
                progressLabel.Dock = DockStyle.Bottom;
    
                Controls.Add(progressBar);
                Controls.Add(progressLabel);
                Controls.Add(startIndexingButton);
            }
    
            private void StartIndexingButton_Click(object sender, EventArgs e)
            {
                string folderPath = @"C:\Users\0533105132\Desktop\MyBooks"; // Replace with the path to your folder.
                string databasePath = "index.db";
    
                CreateDatabase(databasePath);
    
                // Recursively process text files in the specified folder.
                ProcessFolder(folderPath, databasePath);
    
                MessageBox.Show("Indexing complete.");
            }
    
            private void CreateDatabase(string databasePath)
            {
                using (SQLiteConnection connection = new SQLiteConnection($"Data Source={databasePath}"))
                {
                    connection.Open();
    
                    string createTableQuery = @"
                        CREATE TABLE IF NOT EXISTS WordIndex (
                            Word TEXT,
                            FilePath TEXT,
                            LineNumber INT,
                            WordPosition INT
                        );
                    ";
    
                    using (SQLiteCommand command = new SQLiteCommand(createTableQuery, connection))
                    {
                        command.ExecuteNonQuery();
                    }
                }
            }
    
            private void ProcessFolder(string folderPath, string databasePath)
            {
                string[] files = Directory.GetFiles(folderPath, "*.txt", SearchOption.AllDirectories);
                progressBar.Maximum = files.Length;
                progressBar.Value = 0;
    
                foreach (string file in files)
                {
                    progressLabel.Text = $"Processing: {Path.GetFileName(file)}";
                    Application.DoEvents(); // Update the label text
    
                    ProcessFile(file, databasePath);
    
                    progressBar.Value++;
                }
    
                progressLabel.Text = "Processing complete.";
            }
    
            private void ProcessFile(string filePath, string databasePath)
            {
                using (SQLiteConnection connection = new SQLiteConnection($"Data Source={databasePath}"))
                {
                    connection.Open();
    
                    using (SQLiteCommand command = new SQLiteCommand(connection))
                    {
                        StringBuilder insertBatch = new StringBuilder();
                        string[] lines = File.ReadAllLines(filePath, Encoding.GetEncoding(1255));
                        int lineNumber = 0;
    
                        foreach (string line in lines)
                        {
                            lineNumber++;
    
                            string[] words = Regex.Split(line, @"\W+");
    
                            foreach (string word in words)
                            {
                                if (!string.IsNullOrWhiteSpace(word))
                                {
                                    string normalizedWord = word.ToLower();
                                    insertBatch.AppendLine("INSERT INTO WordIndex (Word, FilePath, LineNumber, WordPosition) " +
                                        $"VALUES ('{normalizedWord}', '{filePath}', {lineNumber}, {insertBatch.Length});");
                                }
                            }
                        }
    
                        // Execute all insert statements in a single transaction
                        command.CommandText = insertBatch.ToString();
                        command.ExecuteNonQuery();
                    }
                }
            }
        }
    }
    
    

    מצו"ב גם תמונה של הטבלה
    d140ce75-4bab-424f-a607-6a5daefe8c5a-image.png

    תכנות
  • 1
  • 2
  • 33
  • 34
  • 35
  • 36
  • 37
  • 35 / 37
  • התחברות

  • אין לך חשבון עדיין? הרשמה

  • התחברו או הירשמו כדי לחפש.
  • פוסט ראשון
    פוסט אחרון
0
  • דף הבית
  • קטגוריות
  • פוסטים אחרונים
  • משתמשים
  • חיפוש
  • חוקי הפורום