Skip to content

Commit 833e5b2

Browse files
author
Artur Zakirov
committed
Fix hyphenated word
1 parent 2a43603 commit 833e5b2

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ SELECT to_tsvector('english', '123-abc') as def_parser,
2323
-----------------+-----------------------------
2424
'123':1 'abc':2 | '123':2 '123-abc':1 'abc':3
2525
(1 row)
26+
27+
SELECT to_tsvector('english', 'rel-3.2-A') as def_parser,
28+
to_tsvector('english_ts', 'rel-3.2-A') as new_parser;
29+
def_parser | new_parser
30+
------------------+-------------------------------
31+
'-3.2':2 'rel':1 | '3.2':3 'rel':2 'rel-3.2-a':1
32+
(1 row)
2633
```
2734

2835
## License

expected/pg_tsparser.out

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,16 @@ SELECT * FROM ts_parse('tsparser', '345 qwe@efd.r '' http://www.com/ http://aew.
152152
12 | .
153153
20 | 4.2
154154
12 | ,
155-
1 | readline
156-
20 | -4.2
155+
15 | readline-4.2
156+
11 | readline
157+
12 | -
158+
9 | 4.2
159+
12 |
160+
15 | readline-4.2
161+
11 | readline
162+
12 | -
163+
9 | 4.2.
157164
12 |
158-
1 | readline
159-
20 | -4.2
160-
12 | .
161165
22 | 234
162166
12 | +
163167
|
@@ -173,7 +177,7 @@ SELECT * FROM ts_parse('tsparser', '345 qwe@efd.r '' http://www.com/ http://aew.
173177
12 |
174178
12 | <>
175179
1 | qwerty
176-
(139 rows)
180+
(143 rows)
177181

178182
-- Test text search configuration with parser
179183
CREATE TEXT SEARCH CONFIGURATION english_ts (

tsparser.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ static const TParserStateActionItem actionTPS_InHyphenAsciiWordFirst[] = {
16001600
{p_isEOF, 0, A_POP, TPS_Null, 0, NULL},
16011601
{p_isasclet, 0, A_NEXT, TPS_InHyphenAsciiWord, 0, NULL},
16021602
{p_isalpha, 0, A_NEXT, TPS_InHyphenWord, 0, NULL},
1603-
{p_isdigit, 0, A_NEXT, TPS_InHyphenDigitLookahead, 0, NULL},
1603+
{p_isdigit, 0, A_NEXT, TPS_InHyphenNumWord, 0, NULL},
16041604
{NULL, 0, A_POP, TPS_Null, 0, NULL}
16051605
};
16061606

@@ -1618,7 +1618,7 @@ static const TParserStateActionItem actionTPS_InHyphenAsciiWord[] = {
16181618
static const TParserStateActionItem actionTPS_InHyphenWordFirst[] = {
16191619
{p_isEOF, 0, A_POP, TPS_Null, 0, NULL},
16201620
{p_isalpha, 0, A_NEXT, TPS_InHyphenWord, 0, NULL},
1621-
{p_isdigit, 0, A_NEXT, TPS_InHyphenDigitLookahead, 0, NULL},
1621+
{p_isdigit, 0, A_NEXT, TPS_InHyphenNumWord, 0, NULL},
16221622
{NULL, 0, A_POP, TPS_Null, 0, NULL}
16231623
};
16241624

@@ -1635,14 +1635,15 @@ static const TParserStateActionItem actionTPS_InHyphenWord[] = {
16351635
static const TParserStateActionItem actionTPS_InHyphenNumWordFirst[] = {
16361636
{p_isEOF, 0, A_POP, TPS_Null, 0, NULL},
16371637
{p_isalpha, 0, A_NEXT, TPS_InHyphenNumWord, 0, NULL},
1638-
{p_isdigit, 0, A_NEXT, TPS_InHyphenDigitLookahead, 0, NULL},
1638+
{p_isdigit, 0, A_NEXT, TPS_InHyphenNumWord, 0, NULL},
16391639
{NULL, 0, A_POP, TPS_Null, 0, NULL}
16401640
};
16411641

16421642
static const TParserStateActionItem actionTPS_InHyphenNumWord[] = {
16431643
{p_isEOF, 0, A_BINGO | A_CLRALL, TPS_InParseHyphen, NUMHWORD, SpecialHyphen},
16441644
{p_isalnum, 0, A_NEXT, TPS_InHyphenNumWord, 0, NULL},
16451645
{p_isspecial, 0, A_NEXT, TPS_InHyphenNumWord, 0, NULL},
1646+
{p_iseqC, '.', A_PUSH, TPS_InHyphenNumWordFirst, 0, NULL},
16461647
{p_iseqC, '-', A_PUSH, TPS_InHyphenNumWordFirst, 0, NULL},
16471648
{p_iseqC, '_', A_PUSH, TPS_InHyphenNumWordFirst, 0, NULL},
16481649
{NULL, 0, A_BINGO | A_CLRALL, TPS_InParseHyphen, NUMHWORD, SpecialHyphen}
@@ -1694,6 +1695,7 @@ static const TParserStateActionItem actionTPS_InHyphenNumWordPart[] = {
16941695
{p_isEOF, 0, A_BINGO, TPS_Base, NUMPARTHWORD, NULL},
16951696
{p_isalnum, 0, A_NEXT, TPS_InHyphenNumWordPart, 0, NULL},
16961697
{p_isspecial, 0, A_NEXT, TPS_InHyphenNumWordPart, 0, NULL},
1698+
{p_iseqC, '.', A_NEXT, TPS_InHyphenNumWordPart, 0, NULL},
16971699
{NULL, 0, A_BINGO, TPS_InParseHyphen, NUMPARTHWORD, NULL}
16981700
};
16991701

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy