### Edge Cases and Special Scenarios Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The library effectively handles various edge cases, including parenthetical content, sentences without spaces, and named entities containing punctuation. ```APIDOC ## Edge Cases and Special Scenarios The library handles various edge cases including parenthetical content, sentences without spaces, and named entities with punctuation. ```csharp using PragmaticSegmenterNet; // Parenthetical content inside sentence var result = Segmenter.Segment("He teaches science (He previously worked for 5 years as an engineer.) at the local University."); // Result: ["He teaches science (He previously worked for 5 years as an engineer.) at the local University."] // No space between sentences var result2 = Segmenter.Segment("Hello world.Today is Tuesday.Mr. Smith went to the store and bought 1,000.That is a lot."); // Result: ["Hello world.", "Today is Tuesday.", "Mr. Smith went to the store and bought 1,000.", "That is a lot."] // Named entities with exclamation points (e.g., Yahoo!) var result3 = Segmenter.Segment("She works at Yahoo! in the accounting department."); // Result: ["She works at Yahoo! in the accounting department."] // Single character input var single = Segmenter.Segment("a"); // Result: ["a"] // Empty or whitespace input var empty = Segmenter.Segment(""); // Result: [] var whitespace = Segmenter.Segment(" "); // Result: [] ``` ``` -------------------------------- ### Segment text into sentences Source: https://github.com/uglytoad/pragmaticsegmenternet/blob/master/README.md Use the Segmenter.Segment method to split input strings into a list of sentences. The method supports specifying a language for improved accuracy. ```csharp using PragmaticSegmenterNet; IReadOnlyList result = Segmenter.Segment("One Sentence. And another sentence."); // ["One Sentence.", "And another sentence."] IReadOnlyList result2 = Segmenter.Segment("Anything.", Language.Italian); // ["Anything"] ``` -------------------------------- ### Perform Basic Sentence Segmentation Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt Use the Segmenter.Segment method to split text into an IReadOnlyList of sentences, handling standard punctuation like periods, question marks, and exclamation points. ```csharp using PragmaticSegmenterNet; // Basic usage - splits text into sentences IReadOnlyList sentences = Segmenter.Segment("Hello World. My name is Jonas."); // Result: ["Hello World.", "My name is Jonas."] // Handles question marks and exclamation points var result = Segmenter.Segment("What is your name? My name is Jonas."); // Result: ["What is your name?", "My name is Jonas."] var result2 = Segmenter.Segment("There it is! I found it."); // Result: ["There it is!", "I found it."] ``` -------------------------------- ### Segmenter.Segment Method Source: https://github.com/uglytoad/pragmaticsegmenternet/blob/master/README.md The Segment method is the primary entry point for performing sentence boundary detection on a provided string. ```APIDOC ## Segmenter.Segment ### Description Splits a string into a list of sentences using rule-based boundary detection. ### Parameters #### Method Parameters - **text** (string) - Required - The input text to be segmented. - **language** (Language enum) - Optional - The language of the text (default: English). - **cleanText** (bool) - Optional - Whether to clean the input text by removing extra newlines and whitespace (default: true). - **documentType** (DocumentType enum) - Optional - The type of document (Any, PDF, HTML) to determine specific reformatting rules (default: Any). ### Request Example Segmenter.Segment("One Sentence. And another sentence.", Language.English, true, DocumentType.Any); ### Response #### Success Response - **result** (IReadOnlyList) - A list of segmented sentences. ``` -------------------------------- ### Handle Edge Cases in Text Segmentation Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The library handles various edge cases including parenthetical content, sentences without spaces, named entities with punctuation, single characters, and empty or whitespace input. ```csharp using PragmaticSegmenterNet; // Parenthetical content inside sentence var result = Segmenter.Segment("He teaches science (He previously worked for 5 years as an engineer.) at the local University."); // Result: ["He teaches science (He previously worked for 5 years as an engineer.) at the local University."] ``` ```csharp // No space between sentences var result2 = Segmenter.Segment("Hello world.Today is Tuesday.Mr. Smith went to the store and bought 1,000.That is a lot."); // Result: ["Hello world.", "Today is Tuesday.", "Mr. Smith went to the store and bought 1,000.", "That is a lot."] ``` ```csharp // Named entities with exclamation points (e.g., Yahoo!) var result3 = Segmenter.Segment("She works at Yahoo! in the accounting department."); // Result: ["She works at Yahoo! in the accounting department."] ``` ```csharp // Single character input var single = Segmenter.Segment("a"); // Result: ["a"] ``` ```csharp // Empty or whitespace input var empty = Segmenter.Segment(""); // Result: [] ``` ```csharp var whitespace = Segmenter.Segment(" "); // Result: [] ``` -------------------------------- ### Handle Abbreviations in Text Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The library automatically detects common abbreviations to prevent incorrect sentence splitting at periods within titles, initials, or organizational names. ```csharp using PragmaticSegmenterNet; // Single letter abbreviations (middle initials) var result = Segmenter.Segment("My name is Jonas E. Smith."); // Result: ["My name is Jonas E. Smith."] // Two-letter abbreviations (Mt., St., Dr., etc.) var result2 = Segmenter.Segment("I can see Mt. Fuji from here."); // Result: ["I can see Mt. Fuji from here."] // Multi-period abbreviations var result3 = Segmenter.Segment("I visited the U.S.A. last year."); // Result: ["I visited the U.S.A. last year."] // Abbreviations at end of sentence vs mid-sentence var result4 = Segmenter.Segment("I live in the U.S. How about you?"); // Result: ["I live in the U.S.", "How about you?"] var result5 = Segmenter.Segment("I work for the U.S. Government in Virginia."); // Result: ["I work for the U.S. Government in Virginia."] // Company abbreviations var result6 = Segmenter.Segment("They closed the deal with Pitt, Briggs & Co. at noon."); // Result: ["They closed the deal with Pitt, Briggs & Co. at noon."] ``` -------------------------------- ### Handling Numbers and Currency Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The segmenter is designed to preserve numbers with decimal points and currency values, ensuring they are not misinterpreted as sentence boundaries. ```APIDOC ## Handling Numbers and Currency The segmenter preserves numbers with decimal points and currency values, distinguishing them from sentence boundaries. ```csharp using PragmaticSegmenterNet; // Currency values var result = Segmenter.Segment("She has $100.00 in her bag."); // Result: ["She has $100.00 in her bag."] // Currency at end of sentence var result2 = Segmenter.Segment("She has $100.00. It is in her bag."); // Result: ["She has $100.00.", "It is in her bag."] // German number formatting (periods as thousand separators) var german = Segmenter.Segment("Wir haben 1.000.000 Euro.", Language.German); // Result: ["Wir haben 1.000.000 Euro."] // German decimal numbers var german2 = Segmenter.Segment("Sie bekommen 3,50 Euro zurück.", Language.German); // Result: ["Sie bekommen 3,50 Euro zurück."] // Geo coordinates var geo = Segmenter.Segment("You can find it at N°. 1026.253.553. That is where the treasure is."); // Result: ["You can find it at N°. 1026.253.553.", "That is where the treasure is."] ``` ``` -------------------------------- ### Detect Various List Formats in C# Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt Use the Segmenter to identify and split different types of lists, such as numbered, bulleted, and alphabetical lists. Ensure correct formatting for each list type. ```csharp using PragmaticSegmenterNet; // Numbered lists with periods var result = Segmenter.Segment("1. The first item 2. The second item"); // Result: ["1. The first item", "2. The second item"] // Numbered lists with parentheses var result2 = Segmenter.Segment("1) The first item 2) The second item"); // Result: ["1) The first item", "2) The second item"] // Bulleted lists var result3 = Segmenter.Segment("• 9. The first item • 10. The second item"); // Result: ["• 9. The first item", "• 10. The second item"] // Alphabetical lists var result4 = Segmenter.Segment("a. The first item b. The second item c. The third list item"); // Result: ["a. The first item", "b. The second item", "c. The third list item"] // Roman numeral lists var result5 = Segmenter.Segment("(i) Hello world. (ii) Hello world. (iii) Hello world."); // Result: ["(i) Hello world.", "(ii) Hello world.", "(iii) Hello world."] ``` -------------------------------- ### Handle Numbers and Currency in Segmentation Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The segmenter preserves numbers with decimal points and currency values, distinguishing them from sentence boundaries. It also supports German number formatting. ```csharp // Currency values var result = Segmenter.Segment("She has $100.00 in her bag."); // Result: ["She has $100.00 in her bag."] ``` ```csharp // Currency at end of sentence var result2 = Segmenter.Segment("She has $100.00. It is in her bag."); // Result: ["She has $100.00.", "It is in her bag."] ``` ```csharp // German number formatting (periods as thousand separators) var german = Segmenter.Segment("Wir haben 1.000.000 Euro.", Language.German); // Result: ["Wir haben 1.000.000 Euro."] ``` ```csharp // German decimal numbers var german2 = Segmenter.Segment("Sie bekommen 3,50 Euro zurück.", Language.German); // Result: ["Sie bekommen 3,50 Euro zurück."] ``` ```csharp // Geo coordinates var geo = Segmenter.Segment("You can find it at N°. 1026.253.553. That is where the treasure is."); // Result: ["You can find it at N°. 1026.253.553.", "That is where the treasure is."] ``` -------------------------------- ### Segment method signature Source: https://github.com/uglytoad/pragmaticsegmenternet/blob/master/README.md The Segment method accepts optional parameters for language, text cleaning, and document type. ```csharp IReadOnlyList Segment(string text, Language language = Language.English, bool cleanText = true, DocumentType documentType = DocumentType.Any) ``` -------------------------------- ### Utilize Language Support in C# Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt Leverage the `Language` enum to specify the target language for accurate segmentation, considering language-specific rules for abbreviations and punctuation. The default is English. ```csharp using PragmaticSegmenterNet; // English (default) var english = Segmenter.Segment("Hello World. My name is Jonas."); // Result: ["Hello World.", "My name is Jonas."] // German - handles German quotation marks and abbreviations var german = Segmenter.Segment("„Ich habe heute keine Zeit", sagte die Frau und flüsterte leise: „Und auch keine Lust." Wir haben 1.000.000 Euro.", Language.German); // Result: ["„Ich habe heute keine Zeit", sagte die Frau und flüsterte leise: „Und auch keine Lust.", "Wir haben 1.000.000 Euro."] // German abbreviations var german2 = Segmenter.Segment("Wir trafen Dr. med. Meyer in der Stadt.", Language.German); // Result: ["Wir trafen Dr. med. Meyer in der Stadt."] // Japanese - handles full-width punctuation var japanese = Segmenter.Segment("これはペンです。それはマーカーです。", Language.Japanese); // Result: ["これはペンです。", "それはマーカーです。"] // Japanese question marks var japanese2 = Segmenter.Segment("それは何ですか?ペンですか?", Language.Japanese); // Result: ["それは何ですか?", "ペンですか?"] // Chinese var chinese = Segmenter.Segment("我们明天一起去看《摔跤吧!爸爸》好吗?好!", Language.Chinese); // Result: ["我们明天一起去看《摔跤吧!爸爸》好吗?", "好!"] // Supported languages: English, Amharic, Arabic, Armenian, Bulgarian, Burmese, // Chinese, Danish, Dutch, French, German, Greek, Hindi, Italian, Japanese, // Kazakh, Persian, Polish, Russian, Spanish, Urdu ``` -------------------------------- ### Manage Quotations and Nested Text Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The library correctly identifies sentence boundaries when dealing with quoted strings, including single quotes and nested quotations. ```csharp using PragmaticSegmenterNet; // Quotation inside sentence var result = Segmenter.Segment("She turned to him, \"This is great.\" she said."); // Result: ["She turned to him, \"This is great.\" she said."] // Quotation at end of sentence followed by new sentence var result2 = Segmenter.Segment("She turned to him, \"This is great.\" She held the book out to show him."); // Result: ["She turned to him, \"This is great.\"", "She held the book out to show him."] // Single quotes var result3 = Segmenter.Segment("She turned to him, 'This is great.' she said."); // Result: ["She turned to him, 'This is great.' she said."] // Complex nested quotations var result4 = Segmenter.Segment("\"Dinah'll miss me very much to-night, I should think!\" (Dinah was the cat.) \"I hope they'll remember her saucer of milk at tea-time.\""); // Result: ["\"Dinah'll miss me very much to-night, I should think!\"", "(Dinah was the cat.)", "\"I hope they'll remember her saucer of milk at tea-time.\""] ``` -------------------------------- ### Process Multiple Punctuation in C# Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The segmenter handles sequences of identical or mixed punctuation marks at the end of sentences. This ensures accurate segmentation even with emphatic punctuation. ```csharp using PragmaticSegmenterNet; // Double exclamation var result = Segmenter.Segment("Hello!! Long time no see."); // Result: ["Hello!!", "Long time no see."] // Double question mark var result2 = Segmenter.Segment("Hello?? Who is there?"); // Result: ["Hello??", "Who is there?"] // Mixed punctuation var result3 = Segmenter.Segment("Hello!? Is that you?"); // Result: ["Hello!?", "Is that you?"] var result4 = Segmenter.Segment("Unbelievable??!?!"); // Result: ["Unbelievable??!?!"] ``` -------------------------------- ### Document Type Handling Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The `DocumentType` parameter allows specialized text cleaning for different source formats, particularly useful for PDF text extraction. It helps in correctly segmenting sentences that might be split by newlines due to PDF formatting. ```APIDOC ## Document Type Handling The `DocumentType` parameter allows specialized text cleaning for different source formats, particularly useful for PDF text extraction. ```csharp using PragmaticSegmenterNet; // Default (Any) - standard text cleaning var result = Segmenter.Segment("It was a cold \nnight in the city."); // Result: ["It was a cold night in the city."] // PDF document type - handles mid-sentence newlines common in PDF extraction var pdfResult = Segmenter.Segment("This is a sentence\ncut off in the middle because pdf.", documentType: DocumentType.Pdf); // Result: ["This is a sentence cut off in the middle because pdf."] // German PDF with complex formatting var germanPdf = Segmenter.Segment("Andere \nFischsorten (z.B. Hai, Thunfisch, Aal und Seeteufel) weisen einen erhöhten Quecksilbergehalt \nauf und sollten deshalb in der Schwangerschaft nur selten verzehrt werden.", Language.German, documentType: DocumentType.Pdf); // Result: ["Andere Fischsorten (z.B. Hai, Thunfisch, Aal und Seeteufel) weisen einen erhöhten Quecksilbergehalt auf und sollten deshalb in der Schwangerschaft nur selten verzehrt werden."] ``` ``` -------------------------------- ### Handle Ellipses Correctly in C# Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt Distinguish between ellipses used within sentences and those marking sentence boundaries. The segmenter correctly identifies sentence-ending ellipses. ```csharp using PragmaticSegmenterNet; // Ellipsis within sentence (not a boundary) var result = Segmenter.Segment("I wasn't really ... well, what I mean...see . . . what I'm saying, the thing is . . . I didn't mean it."); // Result: ["I wasn't really ... well, what I mean...see . . . what I'm saying, the thing is . . . I didn't mean it."] // Ellipsis at end of sentence (is a boundary) var result2 = Segmenter.Segment("I never meant that.... She left the store."); // Result: ["I never meant that....", "She left the store."] // Four-dot ellipsis (period + ellipsis) var result3 = Segmenter.Segment("One further habit which was somewhat weakened . . . was that of combining words into self-interpreting compounds. . . . The practice was not abandoned. . . ."); // Result: ["One further habit which was somewhat weakened . . . was that of combining words into self-interpreting compounds.", ". . . The practice was not abandoned. . . ."] ``` -------------------------------- ### Preserve Email and URL Boundaries Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The segmenter recognizes that periods contained within email addresses and web URLs do not represent sentence boundaries. ```csharp using PragmaticSegmenterNet; // Email addresses var result = Segmenter.Segment("Her email is Jane.Doe@example.com. I sent her an email."); // Result: ["Her email is Jane.Doe@example.com.", "I sent her an email."] // Web addresses var result2 = Segmenter.Segment("The site is: https://www.example.50.com/new-site/awesome_content.html. Please check it out."); // Result: ["The site is: https://www.example.50.com/new-site/awesome_content.html.", "Please check it out."] ``` -------------------------------- ### Segment Text with Document Type Handling Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt Use the DocumentType parameter to apply specialized text cleaning for different source formats like PDF. This is useful for handling mid-sentence newlines common in PDF text extraction. ```csharp using PragmaticSegmenterNet; // Default (Any) - standard text cleaning var result = Segmenter.Segment("It was a cold night in the city."); // Result: ["It was a cold night in the city."] ``` ```csharp // PDF document type - handles mid-sentence newlines common in PDF extraction var pdfResult = Segmenter.Segment("This is a sentence cut off in the middle because pdf.", documentType: DocumentType.Pdf); // Result: ["This is a sentence cut off in the middle because pdf."] ``` ```csharp // German PDF with complex formatting var germanPdf = Segmenter.Segment("Andere Fischsorten (z.B. Hai, Thunfisch, Aal und Seeteufel) weisen einen erhöhten Quecksilbergehalt auf und sollten deshalb in der Schwangerschaft nur selten verzehrt werden.", Language.German, documentType: DocumentType.Pdf); // Result: ["Andere Fischsorten (z.B. Hai, Thunfisch, Aal und Seeteufel) weisen einen erhöhten Quecksilbergehalt auf und sollten deshalb in der Schwangerschaft nur selten verzehrt werden."] ``` -------------------------------- ### Text Cleaning Control Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The `cleanText` parameter controls whether input text is preprocessed before segmentation. By default, text cleaning is enabled to normalize whitespace and formatting. ```APIDOC ## Text Cleaning Control The `cleanText` parameter controls whether input text is preprocessed before segmentation. ```csharp using PragmaticSegmenterNet; // With text cleaning (default: true) - normalizes whitespace and formatting var cleaned = Segmenter.Segment("Hello World. My name is Jonas.", cleanText: true); // Result: ["Hello World.", "My name is Jonas."] // Without text cleaning - preserves original text formatting var uncleaned = Segmenter.Segment("Hello World. My name is Jonas.", cleanText: false); // Result depends on exact input formatting // Full method signature IReadOnlyList Segment( string text, Language language = Language.English, bool cleanText = true, DocumentType documentType = DocumentType.Any ); ``` ``` -------------------------------- ### Control Text Cleaning During Segmentation Source: https://context7.com/uglytoad/pragmaticsegmenternet/llms.txt The cleanText parameter controls whether input text is preprocessed before segmentation. By default, text cleaning is enabled to normalize whitespace and formatting. ```csharp using PragmaticSegmenterNet; // With text cleaning (default: true) - normalizes whitespace and formatting var cleaned = Segmenter.Segment("Hello World. My name is Jonas.", cleanText: true); // Result: ["Hello World.", "My name is Jonas."] ``` ```csharp // Without text cleaning - preserves original text formatting var uncleaned = Segmenter.Segment("Hello World. My name is Jonas.", cleanText: false); // Result depends on exact input formatting ``` ```csharp // Full method signature IReadOnlyList Segment( string text, Language language = Language.English, bool cleanText = true, DocumentType documentType = DocumentType.Any ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.