0
484 次浏览

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 分) 发布 | 484 次浏览

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 发布 提问于 十一月 19, 2024
Paratext
0
2 个回答 578 次浏览
亲爱的读者 我想找到 \fq 后面跟着任意字符串(包括 ɛ ɔ ɲ ŋ),直到第一个 \\ft,其后跟一个空格,且后面不跟冒号 示例句子: \fq cintɔnŋ Natan i ta ŋuŋ kɔnkɔli bo Solomani ŋununu \ft ... [^\:] 过于贪婪 有什么建议可以限制搜索范围到第一次出现的情况吗? 提前致谢, Bart
goodgoan 347 发布 提问于 八月 3, 2023
0
2 个回答 522 次浏览
我收到了一位译者的这封邮件 我可以写一个简单的正则表达式,但我认为我可能会遗漏一些可能出现在句末的标点符号 有人能帮忙吗? 我希望进行一次最终的标点检查,这不是 Paratext 标准检查的一部分 具体来说,我想确保我们 ... 但至少这能给我一个比检查所有节更短的列表 如果你能写一些 REGEX 代码来帮助我,我将不胜感激 ) 谢谢, james_post
[Moderator]
james_post
2.1k 发布
提问于 三月 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, 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 发布 提问于 八月 20, 2018
Welcome to Support Bible, where you can ask questions and receive answers from other members of the community.
Accept the one whose faith is weak, without quarreling over disputable matters.
Romans 14:1
3,045 个问题
6,005 个回答
5,671 条评论
2,026 位用户