Skip to content

Commit 063eb51

Browse files
wgx998877tellarin
authored andcommitted
Fix ipv6 bug for single ‘:’ (microsoft#414)
* fix ipv6 bug * add a test case
1 parent 765c7ba commit 063eb51

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

.NET/Microsoft.Recognizers.Definitions/BaseIp.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static class BaseIp
2828
public static readonly string Ipv6EllipsisRegex6 = $@"(({BasicIpv6Element}:){{5}}((:{BasicIpv6Element}){{1,2}}))";
2929
public static readonly string Ipv6EllipsisRegex7 = $@"(({BasicIpv6Element}:){{6}}((:{BasicIpv6Element}){{1}}))";
3030
public static readonly string Ipv6EllipsisRegex8 = $@"(({BasicIpv6Element}:){{7}}(:))";
31-
public static readonly string Ipv6EllipsisRegexOther = $@"\B::\B|\B:(:{BasicIpv6Element}){{0,7}}\b|\b({BasicIpv6Element}:){{0,7}}:\B";
31+
public static readonly string Ipv6EllipsisRegexOther = $@"\B::\B|\B:(:{BasicIpv6Element}){{1,7}}\b|\b({BasicIpv6Element}:){{1,7}}:\B";
3232
public static readonly string MergedIpv6Regex = $@"({BasicIpv6Regex}|{Ipv6EllipsisRegex1}|{Ipv6EllipsisRegex2}|{Ipv6EllipsisRegex3}|{Ipv6EllipsisRegex4}|{Ipv6EllipsisRegex5}|{Ipv6EllipsisRegex6}|{Ipv6EllipsisRegex7}|{Ipv6EllipsisRegex8})";
3333
public static readonly string Ipv6Regex = $@"(\b{MergedIpv6Regex}\b)|({Ipv6EllipsisRegexOther})";
3434
}

JavaScript/packages/recognizers-sequence/src/resources/baseIp.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export namespace BaseIp {
1818
export const Ipv6EllipsisRegex6 = `((${BasicIpv6Element}:){5}((:${BasicIpv6Element}){1,2}))`;
1919
export const Ipv6EllipsisRegex7 = `((${BasicIpv6Element}:){6}((:${BasicIpv6Element}){1}))`;
2020
export const Ipv6EllipsisRegex8 = `((${BasicIpv6Element}:){7}(:))`;
21-
export const Ipv6EllipsisRegexOther = `\\B::\\B|\\B:(:${BasicIpv6Element}){0,7}\\b|\\b(${BasicIpv6Element}:){0,7}:\\B`;
21+
export const Ipv6EllipsisRegexOther = `\\B::\\B|\\B:(:${BasicIpv6Element}){1,7}\\b|\\b(${BasicIpv6Element}:){1,7}:\\B`;
2222
export const MergedIpv6Regex = `(${BasicIpv6Regex}|${Ipv6EllipsisRegex1}|${Ipv6EllipsisRegex2}|${Ipv6EllipsisRegex3}|${Ipv6EllipsisRegex4}|${Ipv6EllipsisRegex5}|${Ipv6EllipsisRegex6}|${Ipv6EllipsisRegex7}|${Ipv6EllipsisRegex8})`;
2323
export const Ipv6Regex = `(\\b${MergedIpv6Regex}\\b)|(${Ipv6EllipsisRegexOther})`;
2424
}

Patterns/Base-Ip.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Ipv6EllipsisRegex8: !nestedRegex
3131
def: (({BasicIpv6Element}:){7}(:))
3232
references: [BasicIpv6Element]
3333
Ipv6EllipsisRegexOther: !nestedRegex
34-
def: \B::\B|\B:(:{BasicIpv6Element}){0,7}\b|\b({BasicIpv6Element}:){0,7}:\B
34+
def: \B::\B|\B:(:{BasicIpv6Element}){1,7}\b|\b({BasicIpv6Element}:){1,7}:\B
3535
references: [BasicIpv6Element]
3636
MergedIpv6Regex: !nestedRegex
3737
def: ({BasicIpv6Regex}|{Ipv6EllipsisRegex1}|{Ipv6EllipsisRegex2}|{Ipv6EllipsisRegex3}|{Ipv6EllipsisRegex4}|{Ipv6EllipsisRegex5}|{Ipv6EllipsisRegex6}|{Ipv6EllipsisRegex7}|{Ipv6EllipsisRegex8})

Specs/Sequence/English/IpAddressModel.json

+40
Original file line numberDiff line numberDiff line change
@@ -323,11 +323,51 @@
323323
}
324324
]
325325
},
326+
{
327+
"Input": "the train arrives at 10:00",
328+
"NotSupportedByDesign": "python",
329+
"Results": []
330+
},
326331
{
327332
"Input": "wrong IPV6 address FE06::1::2",
328333
"NotSupportedByDesign": "python",
329334
"Results": []
330335
},
336+
{
337+
"Input": "wrong IPV6 address :",
338+
"NotSupportedByDesign": "python",
339+
"Results": []
340+
},
341+
{
342+
"Input": "I say:",
343+
"NotSupportedByDesign": "python",
344+
"Results": []
345+
},
346+
{
347+
"Input": "I said :",
348+
"NotSupportedByDesign": "python",
349+
"Results": []
350+
},
351+
{
352+
"Input": "lync:",
353+
"NotSupportedByDesign": "python",
354+
"Results": []
355+
},
356+
{
357+
"Input": "lync: :",
358+
"NotSupportedByDesign": "python",
359+
"Results": []
360+
},
361+
{
362+
"Input": ":as you say",
363+
"NotSupportedByDesign": "python",
364+
"Results": []
365+
},
366+
{
367+
"Input": ": as you say",
368+
"NotSupportedByDesign": "python",
369+
"Results": []
370+
},
331371
{
332372
"Input": "wrong IPV6 address 12::44:f:45::1",
333373
"NotSupportedByDesign": "python",

0 commit comments

Comments
 (0)