noxxienl/nladdresslexer
Composer 安装命令:
composer require noxxienl/nladdresslexer
包简介
Package to evaluate and parse dutch addresses
README 文档
README
Dutch address parser is a library to parse address lines into the segments street, number and suffix.
Example:
Plein 1926 12 A
Will be parsed to:
| Street | Number | Suffix |
|---|---|---|
| Plein 1926 | 12 | A |
Installation
Composer is used to install this package
composer require noxxienl/nladdresslexer
Upgrade from 1.x
2.x requires a minimum of php 8.1 to run. Support for php 8 and lower has been dropped.
To upgrade from 1.x simply update your composer file with
"noxxienl/nladdresslexer": "^2.0"
and run:
composer update noxxienl/nladdresslexer
Usage
use noxxienl\nladdresslexer\Parser; $parser = new Parser; $parser->evaluate('Plein 1926 12 A'); echo $parser->getStreet() . "\r\n"; // Plein 1926 echo $parser->getNumber() . "\r\n"; // 12 echo $parser->getSuffix() . "\r\n"; // A echo $parser->getOriginalString();
Usage with splitting address
Sometimes you may have address that does not have the format street, number & suffix. To let the parser correctly do its work you need to split the string on your own before the parser can do its work.
For example:
50 A, Ringweg Zuid / Rijksweg A20
use noxxienl\nladdresslexer\Parser; $parser = new Parser; list($number, $street) = explode(', ', '50 A, Ringweg Zuid / Rijksweg A20'); $parser->evaluate($street, $number); echo $parser->getStreet() . "\r\n"; // Ringweg Zuid / Rijgsweg A20 echo $parser->getNumber() . "\r\n"; // 50 echo $parser->getSuffix() . "\r\n"; // A echo $parser->getOriginalString();
Usage for splitting only numbers
Sometimes you may wish to split only the number and suffix. You can do so by setting the formatting of the parser to the following before executing the parsing:
Parser::setAddressFormat([ Parser::T_NUMBER, Parser::T_SUFFIX, ]);
Be carefull: When setting the address format, it is changed for every parsing to beyond that point. Reset the format to its original state when you want to parse a full address:
Parser::setAddressFormat([ Parser::T_STREET, Parser::T_NUMBER, Parser::T_SUFFIX, ]);
Testing
Testing is done using pestphp. (https://pestphp.com/)
./vendor/bin/pest
To run the tests.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Bugs
Submit a issue to the github repository and if you can find the fix be sure to also submit a pull request!
License
noxxienl/nladdresslexer 适用场景与选型建议
noxxienl/nladdresslexer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 81.6k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2020 年 09 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 noxxienl/nladdresslexer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 noxxienl/nladdresslexer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 81.6k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-09-22