Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
utopia/migrations/0042_a_predicate_is_named_one_way.sql at main · deeplethe/utopia · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
View all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
deeplethe
utopia
Repository navigation
Code
Issues
55
(55)
Pull requests
18
(18)
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
utopia
/
migrations
/
0042_a_predicate_is_named_one_way.sql
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
47 lines (45 loc) · 2.45 KB
main
Breadcrumbs
utopia
/
migrations
/
0042_a_predicate_is_named_one_way.sql
Copy path
Top
File metadata and controls
Code
Blame
47 lines (45 loc) · 2.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--
0042:谓词的显示名只有一种写法——**小驼峰**。
--
--
一个装了 schema.org 的库里,谓词名同时存在四种形态:`acceptedAnswer`(3819)、
--
`owns`(966)、`ApplicableCertificate`(60)、`access to`(88)。前两种是同一种
--
写法的长短两例,后两种是另外两种写法。在左栏那一列里挨着排,读起来就是没规矩。
--
--
定的规矩与 RDF/OWL、schema.org 一致,**而且它带信息量**:
--
--
类 → 大驼峰 Person / CreativeWork
--
谓词 → 小驼峰 worksFor / acceptedAnswer / accessTo
--
--
大小写本身就在说这个词是类还是属性,一眼分得开。库里的类已经是大驼峰
--
(2774 条,另 3 条是 schema.org 自己的 `3DModel`,数字开头,不动),所以这一刀
--
只动谓词。
--
--
**改 label 是安全的**:它从来不是身份。4875 条谓词带 `iri`,RDF 导出优先用
--
`iri`、没有才从 `key` 铸一个,任何导出路径都不读 label。`key` 也早就归一成
--
snake_case(4996/4999 与 label 只差大小写和分隔符)。
--
--
**只动写错的那些,不从 key 反推**。反推会把 `productID` 变成 `productId`——
--
to_key 在连续大写之间不插下划线,`product_id` 再拼回去就丢了缩写。所以:
--
含分隔符的 → 拼成小驼峰,每一段除首字母外原样保留
--
首字母大写的 → 只小写第一个字符
--
两条都不碰词内部的大小写,`productID`、`hasLEI`、`accessibilityAPI` 原样留着。
--
(落这一刀时查过:含分隔符的 88 条里 0 条带连续大写,大写开头的 60 条里
--
0 条以连续大写开头,所以这两条规则在现有数据上不会伤到任何缩写。)
--
--
那 60 条大写开头的全部来自 unece.org,且 label 就是 IRI 末段——不是导入弄错了,
--
是那份词表自己不一致(同一个命名空间里 `brandName` 又是小驼峰)。这里有意
--
偏离它的局部名,因为 `iri` 把真身留住了。
UPDATE
relation_types
SET
label
=
(
SELECT
string_agg(
CASE WHEN i
=
1
THEN
lower
(left(p,
1
))
||
substr(p,
2
)
ELSE
upper
(left(p,
1
))
||
substr(p,
2
)
END,
'
'
ORDER BY
i)
FROM
unnest(regexp_split_to_array(btrim(label),
'
[ _-]+
'
))
WITH ORDINALITY
AS
t(p, i)
WHERE
p
<>
'
'
)
WHERE
label ~
'
[ _-]
'
;
UPDATE
relation_types
SET
label
=
lower
(left(label,
1
))
||
substr(label,
2
)
WHERE
label ~
'
^[A-Z]
'
;
You can’t perform that action at this time.