0
485 次瀏覽

I found an instance of a capitalised word following a comma that shouldn’t be capitalised, and now I’m wondering if there are more. Obviously, many names fit this criteria and would also be found with the simple expression:
\,\s[A-Z]
Is there any way to exclude even the more common names from this, e.g., ‘God’?

舊文章 - 以原文顯示
Paratext (642 點) 提出 | 485 次瀏覽

1 個回答

0
最佳回答

Hi Paul

No easy way to “ignore” capitalized names that I know of. Might I
suggest using an expression in RegExPal to find all capital initial
words rather than just the capital letter. With the list sorted you
could look thru the list and easily pick out the occurrences that are
NOT names.

The following looks for a comma followed by a space, then a capital
letter, followed by a string of lowercase letters with possible diacritics.

, \p{Lu}[\p{Ll}\p{M}]+

The matches look like:

The sorted list looks like:

Hope this helps.

D anon467281 Global Publishing Services WBT Central (Africa, Europe,
Eurasia thru India) DBL Curator, Scripture Typesetting trainer & Regular
Expression “specialist” Dallas, TX

舊文章 - 以原文顯示
(571 點) 提出
已重新顯示

Beautiful (once I found Tools > Count/Extract…)! Thanks, anon467281.

Paul

舊文章 - 以原文顯示

Follow on question: I’m trying to include the next three or four words in
the sorted list, i.e., some context (this would be helpful to determine if
a result is part of a Technical Term). This works:
, \p{Lu}[\p{Ll}] \p{Ll}[\p{Ll}]+
and returns a capitalised word followed by a space and any lowercase word;
but this doesn’t:
, \p{Lu}[\p{Ll}] \p{Lu}[\p{Ll}]+
and neither does this:
, \p{Lu}[\p{Ll}] \p{Ll}[\p{Ll}] \p{Lu}[\p{Ll}]+
Is it not possible to look up two capitalised words in a row?

Paul

舊文章 - 以原文顯示

Paul,

Make sure you have the + for 1 or more at the end of each “word”. In your
examples you only have the + at the end of the second word. This means you
are searching for an uppercase lowercase space word

anon848905
Americas Area Language Technology Coordinator
[Email Removed]
[Phone Removed]Office at JAARS)
[Phone Removed]Cell)
Skype name: anon848905

舊文章 - 以原文顯示

Thanks, anon848905! I didn’t understand the significance of +. But something
about your response actually helped me come up with something more flexible:
, \p{Lu}[\p{Ll}]+ \w+ \w+ \w+
As long as the first condition is met–comma space Uppercase.word–it will
return any kind of word following, Capital or lowercase. And I can extend
the ‘context’ as far as I want–even before the comma, if so desired. Fun
fun!

Thanks again,

Paul

舊文章 - 以原文顯示

Hi Paul

Some explanations of regular expression syntax to help your knowledge
acquisition.

  • Technically \w matches all letters and numbers, while \p{L} just
    matches letters.
  • The + matches 1 or more occurrences of the previous match. An *
    matches zero or more.
  • The [ ] are your self made definition of a class that will match any
    character inside the brackets.
    o When you have one item in the brackets there is no need for the
    brackets.
    [\p{Ll}] is the same as \p{Ll}.
    It does not hurt to have the square brackets, they are however
    unnecessary.

D anon467281

Global Publishing Services
WBT Central (Africa, Europe, Eurasia thru India) DBL Curator, Scripture Typesetting trainer & Regular Expression "specialist"
Dallas, TX

舊文章 - 以原文顯示

* would be better than + for a language like English, because you need to allow one-letter words, like “a”.

@Paul: @anon467281’s expression was matching one-or-more of lowercase-or-modifier. The or in my sentence means you need the square brackets – you’re listing more than one thing that can match each time – each of the multiple times the + looks for the “one or more” it wants to match.

Modifier is typically a diacritic – and accent on a letter – and is needed if you might have decomposed diacritics.

I’d suggest you might need to include word-medial punctuation for many languages, too. So for English (and with some context, as you suggested):

, \p{Lu}[\p{Ll}\p{M}-'’]* [\p{L}-'’]+ [\p{L}-'’]+

This allows hyphens and either straight or curly apostrophes. The \p{M} allows for loan words that have diacritics. But a flaw is that, by grabbing some context, it won’t match if there are less than three words between the comma and the next punctuation mark (you could add more regex code to fix that).

You might want to allow for more than one capital in the first word. e.g. if “eVisa” is a word, and you want it capitalised “EVisa” at the start of a sentence, but not after a comma:

, \p{Lu}[\p{L}\p{M}-'’]* [\p{L}-'’]+ [\p{L}-'’]+

– just one lowercase L removed from the second character class (character classes are the \p things).

舊文章 - 以原文顯示

wdavidhj & Paul & others

First, these types of discussions are fun and educational. They can
present the potential power of using regular expressions.

The expression can be as complicated as you want to make it. It’s
complexity depends on you languages words such as mid-word
capitalization, medial word characters such as a hyphen or apostrophe,
and other variables unique to your language.

Paul introduced some great considerations. I have responded to some of
those and added a new potential regular expression to use in the dialog
that follows.

D anon467281

Global Publishing Services
WBT Central (Africa, Europe, Eurasia thru India) DBL Curator, Scripture Typesetting trainer & Regular Expression "specialist"
Dallas, TX

[wdavidhj] wdavidhj [Link Removed]
January 18

anon467281:

  * The + matches 1 or more occurrences of the previous match. An
    * matches zero or more.
  • would be better than + for a language like English, because you need
    to allow one-letter words, like “a”.

    * The [ ] are your self-made definition of a class that will
      match any character inside the brackets.
      When you have one item in the brackets there is no need for
      the brackets.
      [\p{Ll}] is the same as \p{Ll}.
      It does not hurt to have the square brackets, they are however
      unnecessary.
    

@Paul [Link Removed]: @anon467281
[Link Removed]’s expression was matching
one-or-more of /lowercase-or-modifier/^† . The /or/ in my sentence
means you need the square brackets – you’re listing more than one
thing that can match each time – each of the multiple times the +
looks for the “one or more” it wants to match.

^† Modifier is typically a diacritic – and accent on a letter – and is
needed if you might have decomposed diacritics.

I’d suggest you might need to include word-medial punctuation for many
languages, too. So for English (and with some context, as you suggested):

, \p{Lu}[\p{Ll}\p{M}-’’]* [\p{L}-’’]+ [\p{L}-’’]+ |

This allows hyphens and either straight or curly apostrophes. The

\p{M}| allows

Inside the square brackets a - between to items is a range character
matching anything from the character before thru the character after as
in a-z matching the letters a thru z.

Simply placing the space followed by the 2nd word in parenthesis and
including an * (asterisk)plus after the closing parenthesis like the
following would match 0 to an infinite number of following words. But
that is probably way more than you need to evaluate the context than you
need.

( [\p{L}-’’]+)*

for loan words that have diacritics. But a flaw is that, by grabbing
some context, it won’t match if there are less than three words
between the comma and the next punctuation mark (you could add more
regex code to fix that).

A slight variation of the expression as follows limits the number of
words to 0-4 after the initial , and capitalized word.

I might suggest also matching an optional punctuation character at the
end of each word. That would make the end expression look like:

, \p{Lu}[\p{L}\p{M}-’’]* \p{P}?( [\p{L}\p{M}-’’]\p{P}?){0,4}

The {0,4} is a repeat what precedes (in this case of a word with
possible ending punctuation) of as few as zero times to as many as 4 times.

舊文章 - 以原文顯示

相關問題

0
1 個回答 115 次瀏覽
如何建立 REGEX 搜尋,以找出舊約中所有獨特的專有名詞?(來源文本使用 \pn ...\pn* 標記)也就是說,我該如何取得舊約中所有專有名詞的清單,同時避免每個詞彙出現多次?這部分可能需要透過 Paratext 以外的工具來完成。
Clear7419 251 提出 已提問 11月 19, 2024
0
2 個回答 578 次瀏覽
各位讀者,您好 我想尋找 \fq 後面跟著任意字串(包含 ɛ ɔ ɲ ŋ),直到第一個 \\ft,接著是一個空格,然後後面不跟冒號的情況 範例句子: \fq cintɔnŋ Natan i ta ŋuŋ kɔnkɔli bo Solomani ... ^\:] 貪婪程度太高了 有什麼建議可以將搜尋限制在第一次出現的情況嗎? 提前感謝, Bart
goodgoan 347 提出 已提問 8月 3, 2023
0
2 個回答 522 次瀏覽
我收到一位譯者的這封電子郵件 我雖然能寫出基礎的正則表達式,但認為我可能會遺漏一些可能作為句子結尾的標點符號 請問有沒有人能幫忙? 我希望進行一次最終標點檢查,這不在 Paratext 的標準檢查範圍內 具體來說,我想確 ... 但至少能給我一份比檢查所有節更短的清單 如果你能寫出一些 REGEX 代碼來幫助我,我將非常感激 ) 謝謝, james_post
[Moderator]
james_post
2.1k 提出
已提問 3月 30, 2023
0
3 個回答 294 次瀏覽
Hi, Does anyone know how I can find anywhere in my PT project where there are two quotes within the same paragraph? I can ... and they asked, ** **Is Peter here? Thanks in advance
anon953007 213 提出 已提問 9月 9, 2020
0
8 個回答 1.4k 次瀏覽
We have a user who has inserted a lot of \pn and some \nd inside of footnotes. We now know we need those to be ... the search to inside of a single footnote? Thank you, MSEAIT/LT
MSEAIT_LT 478 提出 已提問 8月 20, 2018
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
There is neither Jew nor Gentile, neither slave nor free, nor is there male and female, for you are all one in Christ Jesus.
Galatians 3:28
3,045 個問題
6,005 個回答
5,671 則評論
2,026 位使用者