├── .gitattributes
├── .gitignore
├── LICENSE
├── LibPostalConsole
├── .gitignore
├── LibPostalConsole.csproj
├── Program.cs
└── Properties
│ └── AssemblyInfo.cs
├── LibPostalNet.sln
├── LibPostalNet
├── .gitignore
├── LibPostalNet.csproj
├── Properties
│ └── AssemblyInfo.cs
├── libpostal.cs
├── libpostal.h
├── libpostalpartial.cs
└── postal.dll
├── README.md
└── Tests
├── Simple.cs
└── Tests.csproj
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 |
3 | ## files generated by popular Visual Studio add-ons.
4 |
5 | ##
6 |
7 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
8 |
9 |
10 |
11 | # User-specific files
12 |
13 | *.rsuser
14 |
15 | *.suo
16 |
17 | *.user
18 |
19 | *.userosscache
20 |
21 | *.sln.docstates
22 |
23 |
24 |
25 | # User-specific files (MonoDevelop/Xamarin Studio)
26 |
27 | *.userprefs
28 |
29 |
30 |
31 | # Build results
32 |
33 | [Dd]ebug/
34 |
35 | [Dd]ebugPublic/
36 |
37 | [Rr]elease/
38 |
39 | [Rr]eleases/
40 |
41 | x64/
42 |
43 | x86/
44 |
45 | [Aa][Rr][Mm]/
46 |
47 | [Aa][Rr][Mm]64/
48 |
49 | bld/
50 |
51 | [Bb]in/
52 |
53 | [Oo]bj/
54 |
55 | [Ll]og/
56 |
57 |
58 |
59 | # Visual Studio 2015/2017 cache/options directory
60 |
61 | .vs/
62 |
63 | # Uncomment if you have tasks that create the project's static files in wwwroot
64 |
65 | #wwwroot/
66 |
67 |
68 |
69 | # Visual Studio 2017 auto generated files
70 |
71 | Generated\ Files/
72 |
73 |
74 |
75 | # MSTest test Results
76 |
77 | [Tt]est[Rr]esult*/
78 |
79 | [Bb]uild[Ll]og.*
80 |
81 |
82 |
83 | # NUNIT
84 |
85 | *.VisualState.xml
86 |
87 | TestResult.xml
88 |
89 |
90 |
91 | # Build Results of an ATL Project
92 |
93 | [Dd]ebugPS/
94 |
95 | [Rr]eleasePS/
96 |
97 | dlldata.c
98 |
99 |
100 |
101 | # Benchmark Results
102 |
103 | BenchmarkDotNet.Artifacts/
104 |
105 |
106 |
107 | # .NET Core
108 |
109 | project.lock.json
110 |
111 | project.fragment.lock.json
112 |
113 | artifacts/
114 |
115 |
116 |
117 | # StyleCop
118 |
119 | StyleCopReport.xml
120 |
121 |
122 |
123 | # Files built by Visual Studio
124 |
125 | *_i.c
126 |
127 | *_p.c
128 |
129 | *_h.h
130 |
131 | *.ilk
132 |
133 | *.meta
134 |
135 | *.obj
136 |
137 | *.iobj
138 |
139 | *.pch
140 |
141 | *.pdb
142 |
143 | *.ipdb
144 |
145 | *.pgc
146 |
147 | *.pgd
148 |
149 | *.rsp
150 |
151 | *.sbr
152 |
153 | *.tlb
154 |
155 | *.tli
156 |
157 | *.tlh
158 |
159 | *.tmp
160 |
161 | *.tmp_proj
162 |
163 | *_wpftmp.csproj
164 |
165 | *.log
166 |
167 | *.vspscc
168 |
169 | *.vssscc
170 |
171 | .builds
172 |
173 | *.pidb
174 |
175 | *.svclog
176 |
177 | *.scc
178 |
179 |
180 |
181 | # Chutzpah Test files
182 |
183 | _Chutzpah*
184 |
185 |
186 |
187 | # Visual C++ cache files
188 |
189 | ipch/
190 |
191 | *.aps
192 |
193 | *.ncb
194 |
195 | *.opendb
196 |
197 | *.opensdf
198 |
199 | *.sdf
200 |
201 | *.cachefile
202 |
203 | *.VC.db
204 |
205 | *.VC.VC.opendb
206 |
207 |
208 |
209 | # Visual Studio profiler
210 |
211 | *.psess
212 |
213 | *.vsp
214 |
215 | *.vspx
216 |
217 | *.sap
218 |
219 |
220 |
221 | # Visual Studio Trace Files
222 |
223 | *.e2e
224 |
225 |
226 |
227 | # TFS 2012 Local Workspace
228 |
229 | $tf/
230 |
231 |
232 |
233 | # Guidance Automation Toolkit
234 |
235 | *.gpState
236 |
237 |
238 |
239 | # ReSharper is a .NET coding add-in
240 |
241 | _ReSharper*/
242 |
243 | *.[Rr]e[Ss]harper
244 |
245 | *.DotSettings.user
246 |
247 |
248 |
249 | # JustCode is a .NET coding add-in
250 |
251 | .JustCode
252 |
253 |
254 |
255 | # TeamCity is a build add-in
256 |
257 | _TeamCity*
258 |
259 |
260 |
261 | # DotCover is a Code Coverage Tool
262 |
263 | *.dotCover
264 |
265 |
266 |
267 | # AxoCover is a Code Coverage Tool
268 |
269 | .axoCover/*
270 |
271 | !.axoCover/settings.json
272 |
273 |
274 |
275 | # Visual Studio code coverage results
276 |
277 | *.coverage
278 |
279 | *.coveragexml
280 |
281 |
282 |
283 | # NCrunch
284 |
285 | _NCrunch_*
286 |
287 | .*crunch*.local.xml
288 |
289 | nCrunchTemp_*
290 |
291 |
292 |
293 | # MightyMoose
294 |
295 | *.mm.*
296 |
297 | AutoTest.Net/
298 |
299 |
300 |
301 | # Web workbench (sass)
302 |
303 | .sass-cache/
304 |
305 |
306 |
307 | # Installshield output folder
308 |
309 | [Ee]xpress/
310 |
311 |
312 |
313 | # DocProject is a documentation generator add-in
314 |
315 | DocProject/buildhelp/
316 |
317 | DocProject/Help/*.HxT
318 |
319 | DocProject/Help/*.HxC
320 |
321 | DocProject/Help/*.hhc
322 |
323 | DocProject/Help/*.hhk
324 |
325 | DocProject/Help/*.hhp
326 |
327 | DocProject/Help/Html2
328 |
329 | DocProject/Help/html
330 |
331 |
332 |
333 | # Click-Once directory
334 |
335 | publish/
336 |
337 |
338 |
339 | # Publish Web Output
340 |
341 | *.[Pp]ublish.xml
342 |
343 | *.azurePubxml
344 |
345 | # Note: Comment the next line if you want to checkin your web deploy settings,
346 |
347 | # but database connection strings (with potential passwords) will be unencrypted
348 |
349 | *.pubxml
350 |
351 | *.publishproj
352 |
353 |
354 |
355 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
356 |
357 | # checkin your Azure Web App publish settings, but sensitive information contained
358 |
359 | # in these scripts will be unencrypted
360 |
361 | PublishScripts/
362 |
363 |
364 |
365 | # NuGet Packages
366 |
367 | *.nupkg
368 |
369 | # The packages folder can be ignored because of Package Restore
370 |
371 | **/[Pp]ackages/*
372 |
373 | # except build/, which is used as an MSBuild target.
374 |
375 | !**/[Pp]ackages/build/
376 |
377 | # Uncomment if necessary however generally it will be regenerated when needed
378 |
379 | #!**/[Pp]ackages/repositories.config
380 |
381 | # NuGet v3's project.json files produces more ignorable files
382 |
383 | *.nuget.props
384 |
385 | *.nuget.targets
386 |
387 |
388 |
389 | # Microsoft Azure Build Output
390 |
391 | csx/
392 |
393 | *.build.csdef
394 |
395 |
396 |
397 | # Microsoft Azure Emulator
398 |
399 | ecf/
400 |
401 | rcf/
402 |
403 |
404 |
405 | # Windows Store app package directories and files
406 |
407 | AppPackages/
408 |
409 | BundleArtifacts/
410 |
411 | Package.StoreAssociation.xml
412 |
413 | _pkginfo.txt
414 |
415 | *.appx
416 |
417 |
418 |
419 | # Visual Studio cache files
420 |
421 | # files ending in .cache can be ignored
422 |
423 | *.[Cc]ache
424 |
425 | # but keep track of directories ending in .cache
426 |
427 | !?*.[Cc]ache/
428 |
429 |
430 |
431 | # Others
432 |
433 | ClientBin/
434 |
435 | ~$*
436 |
437 | *~
438 |
439 | *.dbmdl
440 |
441 | *.dbproj.schemaview
442 |
443 | *.jfm
444 |
445 | *.pfx
446 |
447 | *.publishsettings
448 |
449 | orleans.codegen.cs
450 |
451 |
452 |
453 | # Including strong name files can present a security risk
454 |
455 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
456 |
457 | #*.snk
458 |
459 |
460 |
461 | # Since there are multiple workflows, uncomment next line to ignore bower_components
462 |
463 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
464 |
465 | #bower_components/
466 |
467 | # ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true
468 |
469 | **/wwwroot/lib/
470 |
471 |
472 |
473 | # RIA/Silverlight projects
474 |
475 | Generated_Code/
476 |
477 |
478 |
479 | # Backup & report files from converting an old project file
480 |
481 | # to a newer Visual Studio version. Backup files are not needed,
482 |
483 | # because we have git ;-)
484 |
485 | _UpgradeReport_Files/
486 |
487 | Backup*/
488 |
489 | UpgradeLog*.XML
490 |
491 | UpgradeLog*.htm
492 |
493 | ServiceFabricBackup/
494 |
495 | *.rptproj.bak
496 |
497 |
498 |
499 | # SQL Server files
500 |
501 | *.mdf
502 |
503 | *.ldf
504 |
505 | *.ndf
506 |
507 |
508 |
509 | # Business Intelligence projects
510 |
511 | *.rdl.data
512 |
513 | *.bim.layout
514 |
515 | *.bim_*.settings
516 |
517 | *.rptproj.rsuser
518 |
519 |
520 |
521 | # Microsoft Fakes
522 |
523 | FakesAssemblies/
524 |
525 |
526 |
527 | # GhostDoc plugin setting file
528 |
529 | *.GhostDoc.xml
530 |
531 |
532 |
533 | # Node.js Tools for Visual Studio
534 |
535 | .ntvs_analysis.dat
536 |
537 | node_modules/
538 |
539 |
540 |
541 | # Visual Studio 6 build log
542 |
543 | *.plg
544 |
545 |
546 |
547 | # Visual Studio 6 workspace options file
548 |
549 | *.opt
550 |
551 |
552 |
553 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
554 |
555 | *.vbw
556 |
557 |
558 |
559 | # Visual Studio LightSwitch build output
560 |
561 | **/*.HTMLClient/GeneratedArtifacts
562 |
563 | **/*.DesktopClient/GeneratedArtifacts
564 |
565 | **/*.DesktopClient/ModelManifest.xml
566 |
567 | **/*.Server/GeneratedArtifacts
568 |
569 | **/*.Server/ModelManifest.xml
570 |
571 | _Pvt_Extensions
572 |
573 |
574 |
575 | # Paket dependency manager
576 |
577 | .paket/paket.exe
578 |
579 | paket-files/
580 |
581 |
582 |
583 | # FAKE - F# Make
584 |
585 | .fake/
586 |
587 |
588 |
589 | # JetBrains Rider
590 |
591 | .idea/
592 |
593 | *.sln.iml
594 |
595 |
596 |
597 | # CodeRush personal settings
598 |
599 | .cr/personal
600 |
601 |
602 |
603 | # Python Tools for Visual Studio (PTVS)
604 |
605 | __pycache__/
606 |
607 | *.pyc
608 |
609 |
610 |
611 | # Cake - Uncomment if you are using it
612 |
613 | # tools/**
614 |
615 | # !tools/packages.config
616 |
617 |
618 |
619 | # Tabs Studio
620 |
621 | *.tss
622 |
623 |
624 |
625 | # Telerik's JustMock configuration file
626 |
627 | *.jmconfig
628 |
629 |
630 |
631 | # BizTalk build output
632 |
633 | *.btp.cs
634 |
635 | *.btm.cs
636 |
637 | *.odx.cs
638 |
639 | *.xsd.cs
640 |
641 |
642 |
643 | # OpenCover UI analysis results
644 |
645 | OpenCover/
646 |
647 |
648 |
649 | # Azure Stream Analytics local run output
650 |
651 | ASALocalRun/
652 |
653 |
654 |
655 | # MSBuild Binary and Structured Log
656 |
657 | *.binlog
658 |
659 |
660 |
661 | # NVidia Nsight GPU debugger configuration file
662 |
663 | *.nvuser
664 |
665 |
666 |
667 | # MFractors (Xamarin productivity tool) working folder
668 |
669 | .mfractor/
670 |
671 |
672 |
673 | # Local History for Visual Studio
674 |
675 | .localhistory/
676 |
677 |
678 |
679 | # BeatPulse healthcheck temp database
680 |
681 | healthchecksdb
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 LibPostalNet
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/LibPostalConsole/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 |
3 | ## files generated by popular Visual Studio add-ons.
4 |
5 | ##
6 |
7 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
8 |
9 |
10 |
11 | # User-specific files
12 |
13 | *.rsuser
14 |
15 | *.suo
16 |
17 | *.user
18 |
19 | *.userosscache
20 |
21 | *.sln.docstates
22 |
23 |
24 |
25 | # User-specific files (MonoDevelop/Xamarin Studio)
26 |
27 | *.userprefs
28 |
29 |
30 |
31 | # Build results
32 |
33 | [Dd]ebug/
34 |
35 | [Dd]ebugPublic/
36 |
37 | [Rr]elease/
38 |
39 | [Rr]eleases/
40 |
41 | x64/
42 |
43 | x86/
44 |
45 | [Aa][Rr][Mm]/
46 |
47 | [Aa][Rr][Mm]64/
48 |
49 | bld/
50 |
51 | [Bb]in/
52 |
53 | [Oo]bj/
54 |
55 | [Ll]og/
56 |
57 |
58 |
59 | # Visual Studio 2015/2017 cache/options directory
60 |
61 | .vs/
62 |
63 | # Uncomment if you have tasks that create the project's static files in wwwroot
64 |
65 | #wwwroot/
66 |
67 |
68 |
69 | # Visual Studio 2017 auto generated files
70 |
71 | Generated\ Files/
72 |
73 |
74 |
75 | # MSTest test Results
76 |
77 | [Tt]est[Rr]esult*/
78 |
79 | [Bb]uild[Ll]og.*
80 |
81 |
82 |
83 | # NUNIT
84 |
85 | *.VisualState.xml
86 |
87 | TestResult.xml
88 |
89 |
90 |
91 | # Build Results of an ATL Project
92 |
93 | [Dd]ebugPS/
94 |
95 | [Rr]eleasePS/
96 |
97 | dlldata.c
98 |
99 |
100 |
101 | # Benchmark Results
102 |
103 | BenchmarkDotNet.Artifacts/
104 |
105 |
106 |
107 | # .NET Core
108 |
109 | project.lock.json
110 |
111 | project.fragment.lock.json
112 |
113 | artifacts/
114 |
115 |
116 |
117 | # StyleCop
118 |
119 | StyleCopReport.xml
120 |
121 |
122 |
123 | # Files built by Visual Studio
124 |
125 | *_i.c
126 |
127 | *_p.c
128 |
129 | *_h.h
130 |
131 | *.ilk
132 |
133 | *.meta
134 |
135 | *.obj
136 |
137 | *.iobj
138 |
139 | *.pch
140 |
141 | *.pdb
142 |
143 | *.ipdb
144 |
145 | *.pgc
146 |
147 | *.pgd
148 |
149 | *.rsp
150 |
151 | *.sbr
152 |
153 | *.tlb
154 |
155 | *.tli
156 |
157 | *.tlh
158 |
159 | *.tmp
160 |
161 | *.tmp_proj
162 |
163 | *_wpftmp.csproj
164 |
165 | *.log
166 |
167 | *.vspscc
168 |
169 | *.vssscc
170 |
171 | .builds
172 |
173 | *.pidb
174 |
175 | *.svclog
176 |
177 | *.scc
178 |
179 |
180 |
181 | # Chutzpah Test files
182 |
183 | _Chutzpah*
184 |
185 |
186 |
187 | # Visual C++ cache files
188 |
189 | ipch/
190 |
191 | *.aps
192 |
193 | *.ncb
194 |
195 | *.opendb
196 |
197 | *.opensdf
198 |
199 | *.sdf
200 |
201 | *.cachefile
202 |
203 | *.VC.db
204 |
205 | *.VC.VC.opendb
206 |
207 |
208 |
209 | # Visual Studio profiler
210 |
211 | *.psess
212 |
213 | *.vsp
214 |
215 | *.vspx
216 |
217 | *.sap
218 |
219 |
220 |
221 | # Visual Studio Trace Files
222 |
223 | *.e2e
224 |
225 |
226 |
227 | # TFS 2012 Local Workspace
228 |
229 | $tf/
230 |
231 |
232 |
233 | # Guidance Automation Toolkit
234 |
235 | *.gpState
236 |
237 |
238 |
239 | # ReSharper is a .NET coding add-in
240 |
241 | _ReSharper*/
242 |
243 | *.[Rr]e[Ss]harper
244 |
245 | *.DotSettings.user
246 |
247 |
248 |
249 | # JustCode is a .NET coding add-in
250 |
251 | .JustCode
252 |
253 |
254 |
255 | # TeamCity is a build add-in
256 |
257 | _TeamCity*
258 |
259 |
260 |
261 | # DotCover is a Code Coverage Tool
262 |
263 | *.dotCover
264 |
265 |
266 |
267 | # AxoCover is a Code Coverage Tool
268 |
269 | .axoCover/*
270 |
271 | !.axoCover/settings.json
272 |
273 |
274 |
275 | # Visual Studio code coverage results
276 |
277 | *.coverage
278 |
279 | *.coveragexml
280 |
281 |
282 |
283 | # NCrunch
284 |
285 | _NCrunch_*
286 |
287 | .*crunch*.local.xml
288 |
289 | nCrunchTemp_*
290 |
291 |
292 |
293 | # MightyMoose
294 |
295 | *.mm.*
296 |
297 | AutoTest.Net/
298 |
299 |
300 |
301 | # Web workbench (sass)
302 |
303 | .sass-cache/
304 |
305 |
306 |
307 | # Installshield output folder
308 |
309 | [Ee]xpress/
310 |
311 |
312 |
313 | # DocProject is a documentation generator add-in
314 |
315 | DocProject/buildhelp/
316 |
317 | DocProject/Help/*.HxT
318 |
319 | DocProject/Help/*.HxC
320 |
321 | DocProject/Help/*.hhc
322 |
323 | DocProject/Help/*.hhk
324 |
325 | DocProject/Help/*.hhp
326 |
327 | DocProject/Help/Html2
328 |
329 | DocProject/Help/html
330 |
331 |
332 |
333 | # Click-Once directory
334 |
335 | publish/
336 |
337 |
338 |
339 | # Publish Web Output
340 |
341 | *.[Pp]ublish.xml
342 |
343 | *.azurePubxml
344 |
345 | # Note: Comment the next line if you want to checkin your web deploy settings,
346 |
347 | # but database connection strings (with potential passwords) will be unencrypted
348 |
349 | *.pubxml
350 |
351 | *.publishproj
352 |
353 |
354 |
355 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
356 |
357 | # checkin your Azure Web App publish settings, but sensitive information contained
358 |
359 | # in these scripts will be unencrypted
360 |
361 | PublishScripts/
362 |
363 |
364 |
365 | # NuGet Packages
366 |
367 | *.nupkg
368 |
369 | # The packages folder can be ignored because of Package Restore
370 |
371 | **/[Pp]ackages/*
372 |
373 | # except build/, which is used as an MSBuild target.
374 |
375 | !**/[Pp]ackages/build/
376 |
377 | # Uncomment if necessary however generally it will be regenerated when needed
378 |
379 | #!**/[Pp]ackages/repositories.config
380 |
381 | # NuGet v3's project.json files produces more ignorable files
382 |
383 | *.nuget.props
384 |
385 | *.nuget.targets
386 |
387 |
388 |
389 | # Microsoft Azure Build Output
390 |
391 | csx/
392 |
393 | *.build.csdef
394 |
395 |
396 |
397 | # Microsoft Azure Emulator
398 |
399 | ecf/
400 |
401 | rcf/
402 |
403 |
404 |
405 | # Windows Store app package directories and files
406 |
407 | AppPackages/
408 |
409 | BundleArtifacts/
410 |
411 | Package.StoreAssociation.xml
412 |
413 | _pkginfo.txt
414 |
415 | *.appx
416 |
417 |
418 |
419 | # Visual Studio cache files
420 |
421 | # files ending in .cache can be ignored
422 |
423 | *.[Cc]ache
424 |
425 | # but keep track of directories ending in .cache
426 |
427 | !?*.[Cc]ache/
428 |
429 |
430 |
431 | # Others
432 |
433 | ClientBin/
434 |
435 | ~$*
436 |
437 | *~
438 |
439 | *.dbmdl
440 |
441 | *.dbproj.schemaview
442 |
443 | *.jfm
444 |
445 | *.pfx
446 |
447 | *.publishsettings
448 |
449 | orleans.codegen.cs
450 |
451 |
452 |
453 | # Including strong name files can present a security risk
454 |
455 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
456 |
457 | #*.snk
458 |
459 |
460 |
461 | # Since there are multiple workflows, uncomment next line to ignore bower_components
462 |
463 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
464 |
465 | #bower_components/
466 |
467 | # ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true
468 |
469 | **/wwwroot/lib/
470 |
471 |
472 |
473 | # RIA/Silverlight projects
474 |
475 | Generated_Code/
476 |
477 |
478 |
479 | # Backup & report files from converting an old project file
480 |
481 | # to a newer Visual Studio version. Backup files are not needed,
482 |
483 | # because we have git ;-)
484 |
485 | _UpgradeReport_Files/
486 |
487 | Backup*/
488 |
489 | UpgradeLog*.XML
490 |
491 | UpgradeLog*.htm
492 |
493 | ServiceFabricBackup/
494 |
495 | *.rptproj.bak
496 |
497 |
498 |
499 | # SQL Server files
500 |
501 | *.mdf
502 |
503 | *.ldf
504 |
505 | *.ndf
506 |
507 |
508 |
509 | # Business Intelligence projects
510 |
511 | *.rdl.data
512 |
513 | *.bim.layout
514 |
515 | *.bim_*.settings
516 |
517 | *.rptproj.rsuser
518 |
519 |
520 |
521 | # Microsoft Fakes
522 |
523 | FakesAssemblies/
524 |
525 |
526 |
527 | # GhostDoc plugin setting file
528 |
529 | *.GhostDoc.xml
530 |
531 |
532 |
533 | # Node.js Tools for Visual Studio
534 |
535 | .ntvs_analysis.dat
536 |
537 | node_modules/
538 |
539 |
540 |
541 | # Visual Studio 6 build log
542 |
543 | *.plg
544 |
545 |
546 |
547 | # Visual Studio 6 workspace options file
548 |
549 | *.opt
550 |
551 |
552 |
553 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
554 |
555 | *.vbw
556 |
557 |
558 |
559 | # Visual Studio LightSwitch build output
560 |
561 | **/*.HTMLClient/GeneratedArtifacts
562 |
563 | **/*.DesktopClient/GeneratedArtifacts
564 |
565 | **/*.DesktopClient/ModelManifest.xml
566 |
567 | **/*.Server/GeneratedArtifacts
568 |
569 | **/*.Server/ModelManifest.xml
570 |
571 | _Pvt_Extensions
572 |
573 |
574 |
575 | # Paket dependency manager
576 |
577 | .paket/paket.exe
578 |
579 | paket-files/
580 |
581 |
582 |
583 | # FAKE - F# Make
584 |
585 | .fake/
586 |
587 |
588 |
589 | # JetBrains Rider
590 |
591 | .idea/
592 |
593 | *.sln.iml
594 |
595 |
596 |
597 | # CodeRush personal settings
598 |
599 | .cr/personal
600 |
601 |
602 |
603 | # Python Tools for Visual Studio (PTVS)
604 |
605 | __pycache__/
606 |
607 | *.pyc
608 |
609 |
610 |
611 | # Cake - Uncomment if you are using it
612 |
613 | # tools/**
614 |
615 | # !tools/packages.config
616 |
617 |
618 |
619 | # Tabs Studio
620 |
621 | *.tss
622 |
623 |
624 |
625 | # Telerik's JustMock configuration file
626 |
627 | *.jmconfig
628 |
629 |
630 |
631 | # BizTalk build output
632 |
633 | *.btp.cs
634 |
635 | *.btm.cs
636 |
637 | *.odx.cs
638 |
639 | *.xsd.cs
640 |
641 |
642 |
643 | # OpenCover UI analysis results
644 |
645 | OpenCover/
646 |
647 |
648 |
649 | # Azure Stream Analytics local run output
650 |
651 | ASALocalRun/
652 |
653 |
654 |
655 | # MSBuild Binary and Structured Log
656 |
657 | *.binlog
658 |
659 |
660 |
661 | # NVidia Nsight GPU debugger configuration file
662 |
663 | *.nvuser
664 |
665 |
666 |
667 | # MFractors (Xamarin productivity tool) working folder
668 |
669 | .mfractor/
670 |
671 |
672 |
673 | # Local History for Visual Studio
674 |
675 | .localhistory/
676 |
677 |
678 |
679 | # BeatPulse healthcheck temp database
680 |
681 | healthchecksdb
--------------------------------------------------------------------------------
/LibPostalConsole/LibPostalConsole.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netcoreapp3.1
4 | Exe
5 | false
6 |
7 |
8 | true
9 |
10 |
11 | bin\x64\Debug\
12 | true
13 | MinimumRecommendedRules.ruleset
14 |
15 |
16 | bin\x64\Release\
17 | MinimumRecommendedRules.ruleset
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LibPostalConsole/Program.cs:
--------------------------------------------------------------------------------
1 | using LibPostalNet;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Runtime.InteropServices;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace LibPostalConsole
10 | {
11 | class Program
12 | {
13 | ///
14 | /// An example of using the LibPostalNet library
15 | ///
16 | /// args[0] should be the path to libpostal data files
17 | static void Main(string[] args)
18 | {
19 | if (args.Length > 0)
20 | {
21 | var dataPath = args[0];
22 | libpostal.LibpostalSetupDatadir(dataPath);
23 | libpostal.LibpostalSetupParserDatadir(dataPath);
24 | libpostal.LibpostalSetupLanguageClassifierDatadir(dataPath);
25 | }
26 | else
27 | {
28 | libpostal.LibpostalSetup();
29 | libpostal.LibpostalSetupParser();
30 | libpostal.LibpostalSetupLanguageClassifier();
31 | }
32 |
33 | var query = "Av. Beira Mar 1647 - Salgueiros, 4400-382 Vila Nova de Gaia";
34 |
35 | var response = libpostal.LibpostalParseAddress(query, new LibpostalAddressParserOptions());
36 |
37 | var x = response.Results;
38 | foreach (var result in x)
39 | {
40 | Console.WriteLine(result.ToString());
41 | }
42 |
43 | libpostal.LibpostalAddressParserResponseDestroy(response);
44 |
45 | var expansion = libpostal.LibpostalExpandAddress(query, libpostal.LibpostalGetDefaultOptions());
46 | foreach (var s in expansion.Expansions)
47 | {
48 | Console.WriteLine(s);
49 | }
50 |
51 | // Teardown (only called once at the end of your program)
52 | libpostal.LibpostalTeardown();
53 | libpostal.LibpostalTeardownParser();
54 | libpostal.LibpostalTeardownLanguageClassifier();
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/LibPostalConsole/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LibPostalConsole")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LibPostalConsole")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("d5134f73-3439-420c-aa2d-b305d13d9f75")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/LibPostalNet.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.28010.2050
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibPostalNet", "LibPostalNet\LibPostalNet.csproj", "{7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibPostalConsole", "LibPostalConsole\LibPostalConsole.csproj", "{D5134F73-3439-420C-AA2D-B305D13D9F75}"
9 | EndProject
10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{47F5D5A8-8496-4390-92D9-273665D4DDC2}"
11 | ProjectSection(SolutionItems) = preProject
12 | README.md = README.md
13 | EndProjectSection
14 | EndProject
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{D0654F14-0A97-4A21-944F-61D293C3E3FC}"
16 | EndProject
17 | Global
18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
19 | Debug|Any CPU = Debug|Any CPU
20 | Debug|x64 = Debug|x64
21 | Debug|x86 = Debug|x86
22 | Release|Any CPU = Release|Any CPU
23 | Release|x64 = Release|x64
24 | Release|x86 = Release|x86
25 | EndGlobalSection
26 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
27 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Debug|Any CPU.ActiveCfg = Debug|x64
28 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Debug|Any CPU.Build.0 = Debug|x64
29 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Debug|x64.ActiveCfg = Debug|x64
30 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Debug|x64.Build.0 = Debug|x64
31 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Debug|x86.ActiveCfg = Debug|x86
32 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Debug|x86.Build.0 = Debug|x86
33 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Release|Any CPU.ActiveCfg = Release|Any CPU
34 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Release|Any CPU.Build.0 = Release|Any CPU
35 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Release|x64.ActiveCfg = Release|x64
36 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Release|x64.Build.0 = Release|x64
37 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Release|x86.ActiveCfg = Release|x86
38 | {7154A21B-B8A8-4A1F-A1DB-078C1F1B600E}.Release|x86.Build.0 = Release|x86
39 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Debug|Any CPU.ActiveCfg = Debug|x64
40 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Debug|Any CPU.Build.0 = Debug|x64
41 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Debug|x64.ActiveCfg = Debug|x64
42 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Debug|x64.Build.0 = Debug|x64
43 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Debug|x86.ActiveCfg = Debug|Any CPU
44 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Debug|x86.Build.0 = Debug|Any CPU
45 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Release|Any CPU.ActiveCfg = Release|Any CPU
46 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Release|Any CPU.Build.0 = Release|Any CPU
47 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Release|x64.ActiveCfg = Release|x64
48 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Release|x64.Build.0 = Release|x64
49 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Release|x86.ActiveCfg = Release|Any CPU
50 | {D5134F73-3439-420C-AA2D-B305D13D9F75}.Release|x86.Build.0 = Release|Any CPU
51 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
52 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
53 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Debug|x64.ActiveCfg = Debug|Any CPU
54 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Debug|x64.Build.0 = Debug|Any CPU
55 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Debug|x86.ActiveCfg = Debug|Any CPU
56 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Debug|x86.Build.0 = Debug|Any CPU
57 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
58 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Release|Any CPU.Build.0 = Release|Any CPU
59 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Release|x64.ActiveCfg = Release|Any CPU
60 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Release|x64.Build.0 = Release|Any CPU
61 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Release|x86.ActiveCfg = Release|Any CPU
62 | {D0654F14-0A97-4A21-944F-61D293C3E3FC}.Release|x86.Build.0 = Release|Any CPU
63 | EndGlobalSection
64 | GlobalSection(SolutionProperties) = preSolution
65 | HideSolutionNode = FALSE
66 | EndGlobalSection
67 | GlobalSection(ExtensibilityGlobals) = postSolution
68 | SolutionGuid = {014BA928-C928-4CCD-8B6F-7078D8C11548}
69 | EndGlobalSection
70 | EndGlobal
71 |
--------------------------------------------------------------------------------
/LibPostalNet/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 |
3 | ## files generated by popular Visual Studio add-ons.
4 |
5 | ##
6 |
7 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
8 |
9 |
10 |
11 | # User-specific files
12 |
13 | *.rsuser
14 |
15 | *.suo
16 |
17 | *.user
18 |
19 | *.userosscache
20 |
21 | *.sln.docstates
22 |
23 |
24 |
25 | # User-specific files (MonoDevelop/Xamarin Studio)
26 |
27 | *.userprefs
28 |
29 |
30 |
31 | # Build results
32 |
33 | [Dd]ebug/
34 |
35 | [Dd]ebugPublic/
36 |
37 | [Rr]elease/
38 |
39 | [Rr]eleases/
40 |
41 | x64/
42 |
43 | x86/
44 |
45 | [Aa][Rr][Mm]/
46 |
47 | [Aa][Rr][Mm]64/
48 |
49 | bld/
50 |
51 | [Bb]in/
52 |
53 | [Oo]bj/
54 |
55 | [Ll]og/
56 |
57 |
58 |
59 | # Visual Studio 2015/2017 cache/options directory
60 |
61 | .vs/
62 |
63 | # Uncomment if you have tasks that create the project's static files in wwwroot
64 |
65 | #wwwroot/
66 |
67 |
68 |
69 | # Visual Studio 2017 auto generated files
70 |
71 | Generated\ Files/
72 |
73 |
74 |
75 | # MSTest test Results
76 |
77 | [Tt]est[Rr]esult*/
78 |
79 | [Bb]uild[Ll]og.*
80 |
81 |
82 |
83 | # NUNIT
84 |
85 | *.VisualState.xml
86 |
87 | TestResult.xml
88 |
89 |
90 |
91 | # Build Results of an ATL Project
92 |
93 | [Dd]ebugPS/
94 |
95 | [Rr]eleasePS/
96 |
97 | dlldata.c
98 |
99 |
100 |
101 | # Benchmark Results
102 |
103 | BenchmarkDotNet.Artifacts/
104 |
105 |
106 |
107 | # .NET Core
108 |
109 | project.lock.json
110 |
111 | project.fragment.lock.json
112 |
113 | artifacts/
114 |
115 |
116 |
117 | # StyleCop
118 |
119 | StyleCopReport.xml
120 |
121 |
122 |
123 | # Files built by Visual Studio
124 |
125 | *_i.c
126 |
127 | *_p.c
128 |
129 | *_h.h
130 |
131 | *.ilk
132 |
133 | *.meta
134 |
135 | *.obj
136 |
137 | *.iobj
138 |
139 | *.pch
140 |
141 | *.pdb
142 |
143 | *.ipdb
144 |
145 | *.pgc
146 |
147 | *.pgd
148 |
149 | *.rsp
150 |
151 | *.sbr
152 |
153 | *.tlb
154 |
155 | *.tli
156 |
157 | *.tlh
158 |
159 | *.tmp
160 |
161 | *.tmp_proj
162 |
163 | *_wpftmp.csproj
164 |
165 | *.log
166 |
167 | *.vspscc
168 |
169 | *.vssscc
170 |
171 | .builds
172 |
173 | *.pidb
174 |
175 | *.svclog
176 |
177 | *.scc
178 |
179 |
180 |
181 | # Chutzpah Test files
182 |
183 | _Chutzpah*
184 |
185 |
186 |
187 | # Visual C++ cache files
188 |
189 | ipch/
190 |
191 | *.aps
192 |
193 | *.ncb
194 |
195 | *.opendb
196 |
197 | *.opensdf
198 |
199 | *.sdf
200 |
201 | *.cachefile
202 |
203 | *.VC.db
204 |
205 | *.VC.VC.opendb
206 |
207 |
208 |
209 | # Visual Studio profiler
210 |
211 | *.psess
212 |
213 | *.vsp
214 |
215 | *.vspx
216 |
217 | *.sap
218 |
219 |
220 |
221 | # Visual Studio Trace Files
222 |
223 | *.e2e
224 |
225 |
226 |
227 | # TFS 2012 Local Workspace
228 |
229 | $tf/
230 |
231 |
232 |
233 | # Guidance Automation Toolkit
234 |
235 | *.gpState
236 |
237 |
238 |
239 | # ReSharper is a .NET coding add-in
240 |
241 | _ReSharper*/
242 |
243 | *.[Rr]e[Ss]harper
244 |
245 | *.DotSettings.user
246 |
247 |
248 |
249 | # JustCode is a .NET coding add-in
250 |
251 | .JustCode
252 |
253 |
254 |
255 | # TeamCity is a build add-in
256 |
257 | _TeamCity*
258 |
259 |
260 |
261 | # DotCover is a Code Coverage Tool
262 |
263 | *.dotCover
264 |
265 |
266 |
267 | # AxoCover is a Code Coverage Tool
268 |
269 | .axoCover/*
270 |
271 | !.axoCover/settings.json
272 |
273 |
274 |
275 | # Visual Studio code coverage results
276 |
277 | *.coverage
278 |
279 | *.coveragexml
280 |
281 |
282 |
283 | # NCrunch
284 |
285 | _NCrunch_*
286 |
287 | .*crunch*.local.xml
288 |
289 | nCrunchTemp_*
290 |
291 |
292 |
293 | # MightyMoose
294 |
295 | *.mm.*
296 |
297 | AutoTest.Net/
298 |
299 |
300 |
301 | # Web workbench (sass)
302 |
303 | .sass-cache/
304 |
305 |
306 |
307 | # Installshield output folder
308 |
309 | [Ee]xpress/
310 |
311 |
312 |
313 | # DocProject is a documentation generator add-in
314 |
315 | DocProject/buildhelp/
316 |
317 | DocProject/Help/*.HxT
318 |
319 | DocProject/Help/*.HxC
320 |
321 | DocProject/Help/*.hhc
322 |
323 | DocProject/Help/*.hhk
324 |
325 | DocProject/Help/*.hhp
326 |
327 | DocProject/Help/Html2
328 |
329 | DocProject/Help/html
330 |
331 |
332 |
333 | # Click-Once directory
334 |
335 | publish/
336 |
337 |
338 |
339 | # Publish Web Output
340 |
341 | *.[Pp]ublish.xml
342 |
343 | *.azurePubxml
344 |
345 | # Note: Comment the next line if you want to checkin your web deploy settings,
346 |
347 | # but database connection strings (with potential passwords) will be unencrypted
348 |
349 | *.pubxml
350 |
351 | *.publishproj
352 |
353 |
354 |
355 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
356 |
357 | # checkin your Azure Web App publish settings, but sensitive information contained
358 |
359 | # in these scripts will be unencrypted
360 |
361 | PublishScripts/
362 |
363 |
364 |
365 | # NuGet Packages
366 |
367 | *.nupkg
368 |
369 | # The packages folder can be ignored because of Package Restore
370 |
371 | **/[Pp]ackages/*
372 |
373 | # except build/, which is used as an MSBuild target.
374 |
375 | !**/[Pp]ackages/build/
376 |
377 | # Uncomment if necessary however generally it will be regenerated when needed
378 |
379 | #!**/[Pp]ackages/repositories.config
380 |
381 | # NuGet v3's project.json files produces more ignorable files
382 |
383 | *.nuget.props
384 |
385 | *.nuget.targets
386 |
387 |
388 |
389 | # Microsoft Azure Build Output
390 |
391 | csx/
392 |
393 | *.build.csdef
394 |
395 |
396 |
397 | # Microsoft Azure Emulator
398 |
399 | ecf/
400 |
401 | rcf/
402 |
403 |
404 |
405 | # Windows Store app package directories and files
406 |
407 | AppPackages/
408 |
409 | BundleArtifacts/
410 |
411 | Package.StoreAssociation.xml
412 |
413 | _pkginfo.txt
414 |
415 | *.appx
416 |
417 |
418 |
419 | # Visual Studio cache files
420 |
421 | # files ending in .cache can be ignored
422 |
423 | *.[Cc]ache
424 |
425 | # but keep track of directories ending in .cache
426 |
427 | !?*.[Cc]ache/
428 |
429 |
430 |
431 | # Others
432 |
433 | ClientBin/
434 |
435 | ~$*
436 |
437 | *~
438 |
439 | *.dbmdl
440 |
441 | *.dbproj.schemaview
442 |
443 | *.jfm
444 |
445 | *.pfx
446 |
447 | *.publishsettings
448 |
449 | orleans.codegen.cs
450 |
451 |
452 |
453 | # Including strong name files can present a security risk
454 |
455 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
456 |
457 | #*.snk
458 |
459 |
460 |
461 | # Since there are multiple workflows, uncomment next line to ignore bower_components
462 |
463 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
464 |
465 | #bower_components/
466 |
467 | # ASP.NET Core default setup: bower directory is configured as wwwroot/lib/ and bower restore is true
468 |
469 | **/wwwroot/lib/
470 |
471 |
472 |
473 | # RIA/Silverlight projects
474 |
475 | Generated_Code/
476 |
477 |
478 |
479 | # Backup & report files from converting an old project file
480 |
481 | # to a newer Visual Studio version. Backup files are not needed,
482 |
483 | # because we have git ;-)
484 |
485 | _UpgradeReport_Files/
486 |
487 | Backup*/
488 |
489 | UpgradeLog*.XML
490 |
491 | UpgradeLog*.htm
492 |
493 | ServiceFabricBackup/
494 |
495 | *.rptproj.bak
496 |
497 |
498 |
499 | # SQL Server files
500 |
501 | *.mdf
502 |
503 | *.ldf
504 |
505 | *.ndf
506 |
507 |
508 |
509 | # Business Intelligence projects
510 |
511 | *.rdl.data
512 |
513 | *.bim.layout
514 |
515 | *.bim_*.settings
516 |
517 | *.rptproj.rsuser
518 |
519 |
520 |
521 | # Microsoft Fakes
522 |
523 | FakesAssemblies/
524 |
525 |
526 |
527 | # GhostDoc plugin setting file
528 |
529 | *.GhostDoc.xml
530 |
531 |
532 |
533 | # Node.js Tools for Visual Studio
534 |
535 | .ntvs_analysis.dat
536 |
537 | node_modules/
538 |
539 |
540 |
541 | # Visual Studio 6 build log
542 |
543 | *.plg
544 |
545 |
546 |
547 | # Visual Studio 6 workspace options file
548 |
549 | *.opt
550 |
551 |
552 |
553 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
554 |
555 | *.vbw
556 |
557 |
558 |
559 | # Visual Studio LightSwitch build output
560 |
561 | **/*.HTMLClient/GeneratedArtifacts
562 |
563 | **/*.DesktopClient/GeneratedArtifacts
564 |
565 | **/*.DesktopClient/ModelManifest.xml
566 |
567 | **/*.Server/GeneratedArtifacts
568 |
569 | **/*.Server/ModelManifest.xml
570 |
571 | _Pvt_Extensions
572 |
573 |
574 |
575 | # Paket dependency manager
576 |
577 | .paket/paket.exe
578 |
579 | paket-files/
580 |
581 |
582 |
583 | # FAKE - F# Make
584 |
585 | .fake/
586 |
587 |
588 |
589 | # JetBrains Rider
590 |
591 | .idea/
592 |
593 | *.sln.iml
594 |
595 |
596 |
597 | # CodeRush personal settings
598 |
599 | .cr/personal
600 |
601 |
602 |
603 | # Python Tools for Visual Studio (PTVS)
604 |
605 | __pycache__/
606 |
607 | *.pyc
608 |
609 |
610 |
611 | # Cake - Uncomment if you are using it
612 |
613 | # tools/**
614 |
615 | # !tools/packages.config
616 |
617 |
618 |
619 | # Tabs Studio
620 |
621 | *.tss
622 |
623 |
624 |
625 | # Telerik's JustMock configuration file
626 |
627 | *.jmconfig
628 |
629 |
630 |
631 | # BizTalk build output
632 |
633 | *.btp.cs
634 |
635 | *.btm.cs
636 |
637 | *.odx.cs
638 |
639 | *.xsd.cs
640 |
641 |
642 |
643 | # OpenCover UI analysis results
644 |
645 | OpenCover/
646 |
647 |
648 |
649 | # Azure Stream Analytics local run output
650 |
651 | ASALocalRun/
652 |
653 |
654 |
655 | # MSBuild Binary and Structured Log
656 |
657 | *.binlog
658 |
659 |
660 |
661 | # NVidia Nsight GPU debugger configuration file
662 |
663 | *.nvuser
664 |
665 |
666 |
667 | # MFractors (Xamarin productivity tool) working folder
668 |
669 | .mfractor/
670 |
671 |
672 |
673 | # Local History for Visual Studio
674 |
675 | .localhistory/
676 |
677 |
678 |
679 | # BeatPulse healthcheck temp database
680 |
681 | healthchecksdb
--------------------------------------------------------------------------------
/LibPostalNet/LibPostalNet.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | netstandard2.1
4 | Library
5 | false
6 | true
7 |
8 |
9 | bin\x64\Debug\
10 | MinimumRecommendedRules.ruleset
11 |
12 |
13 | bin\x64\Release\
14 | MinimumRecommendedRules.ruleset
15 |
16 |
17 | bin\x86\Debug\
18 | MinimumRecommendedRules.ruleset
19 |
20 |
21 | bin\x86\Release\
22 | MinimumRecommendedRules.ruleset
23 |
24 |
25 |
26 | Always
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/LibPostalNet/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("LibPostalNet")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("LibPostalNet")]
13 | [assembly: AssemblyCopyright("Copyright © 2017")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("7154a21b-b8a8-4a1f-a1db-078c1f1b600e")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 | [assembly: InternalsVisibleTo("libpostal")]
38 |
--------------------------------------------------------------------------------
/LibPostalNet/libpostal.cs:
--------------------------------------------------------------------------------
1 | // ----------------------------------------------------------------------------
2 | //
3 | // This is autogenerated code by CppSharp.
4 | // Do not edit this file or all your changes will be lost after re-generation.
5 | //
6 | // ----------------------------------------------------------------------------
7 | using System;
8 | using System.Runtime.InteropServices;
9 | using System.Security;
10 |
11 | namespace LibPostalNet
12 | {
13 | public unsafe partial class LibpostalNormalizeResponse
14 | {
15 | internal static global::LibPostalNet.LibpostalNormalizeResponse __CreateInstance(global::System.SByte** native, global::System.UInt64 count)
16 | {
17 | var expansions = new string[count];
18 | for (ulong i = 0; i < count; i++)
19 | {
20 | var normalized = new IntPtr(native[i]);
21 | var str = Marshal.PtrToStringAnsi(normalized);
22 | expansions[i] = str;
23 | }
24 |
25 | libpostal.LibpostalExpansionArrayDestroy(native, count);
26 |
27 | return new global::LibPostalNet.LibpostalNormalizeResponse(expansions);
28 | }
29 |
30 | protected LibpostalNormalizeResponse(string[] expansions)
31 | {
32 | Expansions = expansions;
33 | }
34 |
35 | public string[] Expansions { get; private set; }
36 | }
37 |
38 | public unsafe partial class LibpostalNormalizeOptions : IDisposable
39 | {
40 | [StructLayout(LayoutKind.Explicit, Size = 40)]
41 | public partial struct __Internal
42 | {
43 | [FieldOffset(0)]
44 | internal global::System.IntPtr languages;
45 |
46 | [FieldOffset(8)]
47 | internal ulong num_languages;
48 |
49 | [FieldOffset(16)]
50 | internal ushort address_components;
51 |
52 | [FieldOffset(18)]
53 | internal byte latin_ascii;
54 |
55 | [FieldOffset(19)]
56 | internal byte transliterate;
57 |
58 | [FieldOffset(20)]
59 | internal byte strip_accents;
60 |
61 | [FieldOffset(21)]
62 | internal byte decompose;
63 |
64 | [FieldOffset(22)]
65 | internal byte lowercase;
66 |
67 | [FieldOffset(23)]
68 | internal byte trim_string;
69 |
70 | [FieldOffset(24)]
71 | internal byte drop_parentheticals;
72 |
73 | [FieldOffset(25)]
74 | internal byte replace_numeric_hyphens;
75 |
76 | [FieldOffset(26)]
77 | internal byte delete_numeric_hyphens;
78 |
79 | [FieldOffset(27)]
80 | internal byte split_alpha_from_numeric;
81 |
82 | [FieldOffset(28)]
83 | internal byte replace_word_hyphens;
84 |
85 | [FieldOffset(29)]
86 | internal byte delete_word_hyphens;
87 |
88 | [FieldOffset(30)]
89 | internal byte delete_final_periods;
90 |
91 | [FieldOffset(31)]
92 | internal byte delete_acronym_periods;
93 |
94 | [FieldOffset(32)]
95 | internal byte drop_english_possessives;
96 |
97 | [FieldOffset(33)]
98 | internal byte delete_apostrophes;
99 |
100 | [FieldOffset(34)]
101 | internal byte expand_numex;
102 |
103 | [FieldOffset(35)]
104 | internal byte roman_numerals;
105 |
106 | [SuppressUnmanagedCodeSecurity]
107 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
108 | EntryPoint = "??0libpostal_normalize_options@@QEAA@AEBU0@@Z")]
109 | internal static extern global::System.IntPtr cctor(global::System.IntPtr instance, global::System.IntPtr _0);
110 | }
111 |
112 | public global::System.IntPtr __Instance { get; protected set; }
113 |
114 | protected int __PointerAdjustment;
115 | internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary();
116 | protected void*[] __OriginalVTables;
117 |
118 | protected bool __ownsNativeInstance;
119 |
120 | internal static global::LibPostalNet.LibpostalNormalizeOptions __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
121 | {
122 | return new global::LibPostalNet.LibpostalNormalizeOptions(native.ToPointer(), skipVTables);
123 | }
124 |
125 | internal static global::LibPostalNet.LibpostalNormalizeOptions __CreateInstance(global::LibPostalNet.LibpostalNormalizeOptions.__Internal native, bool skipVTables = false)
126 | {
127 | return new global::LibPostalNet.LibpostalNormalizeOptions(native, skipVTables);
128 | }
129 |
130 | private static void* __CopyValue(global::LibPostalNet.LibpostalNormalizeOptions.__Internal native)
131 | {
132 | var ret = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalNormalizeOptions.__Internal));
133 | *(global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)ret = native;
134 | return ret.ToPointer();
135 | }
136 |
137 | private LibpostalNormalizeOptions(global::LibPostalNet.LibpostalNormalizeOptions.__Internal native, bool skipVTables = false)
138 | : this(__CopyValue(native), skipVTables)
139 | {
140 | __ownsNativeInstance = true;
141 | NativeToManagedMap[__Instance] = this;
142 | }
143 |
144 | protected LibpostalNormalizeOptions(void* native, bool skipVTables = false)
145 | {
146 | if (native == null)
147 | return;
148 | __Instance = new global::System.IntPtr(native);
149 | }
150 |
151 | public LibpostalNormalizeOptions()
152 | {
153 | __Instance = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalNormalizeOptions.__Internal));
154 | __ownsNativeInstance = true;
155 | NativeToManagedMap[__Instance] = this;
156 | }
157 |
158 | public LibpostalNormalizeOptions(global::LibPostalNet.LibpostalNormalizeOptions _0)
159 | {
160 | __Instance = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalNormalizeOptions.__Internal));
161 | __ownsNativeInstance = true;
162 | NativeToManagedMap[__Instance] = this;
163 | *((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance) = *((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)_0.__Instance);
164 | }
165 |
166 | ~LibpostalNormalizeOptions()
167 | {
168 | Dispose(false);
169 | }
170 |
171 | public void Dispose()
172 | {
173 | Dispose(disposing: true);
174 | GC.SuppressFinalize(this);
175 | }
176 |
177 | public virtual void Dispose(bool disposing)
178 | {
179 | if (__Instance == IntPtr.Zero)
180 | return;
181 | global::LibPostalNet.LibpostalNormalizeOptions __dummy;
182 | NativeToManagedMap.TryRemove(__Instance, out __dummy);
183 | if (__ownsNativeInstance)
184 | Marshal.FreeHGlobal(__Instance);
185 | __Instance = IntPtr.Zero;
186 | }
187 |
188 | // These constants are copied from libposta.h
189 | // TODO: Find a way to import the constants from the C library directly
190 | public const ushort LIBPOSTAL_ADDRESS_NONE = 0;
191 | public const ushort LIBPOSTAL_ADDRESS_ANY = (1 << 0);
192 | public const ushort LIBPOSTAL_ADDRESS_NAME = (1 << 1);
193 | public const ushort LIBPOSTAL_ADDRESS_HOUSE_NUMBER = (1 << 2);
194 | public const ushort LIBPOSTAL_ADDRESS_STREET = (1 << 3);
195 | public const ushort LIBPOSTAL_ADDRESS_UNIT = (1 << 4);
196 | public const ushort LIBPOSTAL_ADDRESS_LEVEL = (1 << 5);
197 | public const ushort LIBPOSTAL_ADDRESS_STAIRCASE = (1 << 6);
198 | public const ushort LIBPOSTAL_ADDRESS_ENTRANCE = (1 << 7);
199 |
200 | public const ushort LIBPOSTAL_ADDRESS_CATEGORY = (1 << 8);
201 | public const ushort LIBPOSTAL_ADDRESS_NEAR = (1 << 9);
202 |
203 | public const ushort LIBPOSTAL_ADDRESS_TOPONYM = (1 << 13);
204 | public const ushort LIBPOSTAL_ADDRESS_POSTAL_CODE = (1 << 14);
205 | public const ushort LIBPOSTAL_ADDRESS_PO_BOX = (1 << 15);
206 | public const ushort LIBPOSTAL_ADDRESS_ALL = ((1 << 16) - 1);
207 |
208 | public sbyte** Languages
209 | {
210 | get
211 | {
212 | return (sbyte**)((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->languages;
213 | }
214 |
215 | set
216 | {
217 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->languages = (global::System.IntPtr)value;
218 | }
219 | }
220 |
221 | public ulong NumLanguages
222 | {
223 | get
224 | {
225 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->num_languages;
226 | }
227 |
228 | set
229 | {
230 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->num_languages = value;
231 | }
232 | }
233 |
234 | public ushort AddressComponents
235 | {
236 | get
237 | {
238 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->address_components;
239 | }
240 |
241 | set
242 | {
243 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->address_components = value;
244 | }
245 | }
246 |
247 | public bool LatinAscii
248 | {
249 | get
250 | {
251 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->latin_ascii != 0;
252 | }
253 |
254 | set
255 | {
256 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->latin_ascii = (byte)(value ? 1 : 0);
257 | }
258 | }
259 |
260 | public bool Transliterate
261 | {
262 | get
263 | {
264 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->transliterate != 0;
265 | }
266 |
267 | set
268 | {
269 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->transliterate = (byte)(value ? 1 : 0);
270 | }
271 | }
272 |
273 | public bool StripAccents
274 | {
275 | get
276 | {
277 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->strip_accents != 0;
278 | }
279 |
280 | set
281 | {
282 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->strip_accents = (byte)(value ? 1 : 0);
283 | }
284 | }
285 |
286 | public bool Decompose
287 | {
288 | get
289 | {
290 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->decompose != 0;
291 | }
292 |
293 | set
294 | {
295 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->decompose = (byte)(value ? 1 : 0);
296 | }
297 | }
298 |
299 | public bool Lowercase
300 | {
301 | get
302 | {
303 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->lowercase != 0;
304 | }
305 |
306 | set
307 | {
308 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->lowercase = (byte)(value ? 1 : 0);
309 | }
310 | }
311 |
312 | public bool TrimString
313 | {
314 | get
315 | {
316 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->trim_string != 0;
317 | }
318 |
319 | set
320 | {
321 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->trim_string = (byte)(value ? 1 : 0);
322 | }
323 | }
324 |
325 | public bool DropParentheticals
326 | {
327 | get
328 | {
329 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->drop_parentheticals != 0;
330 | }
331 |
332 | set
333 | {
334 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->drop_parentheticals = (byte)(value ? 1 : 0);
335 | }
336 | }
337 |
338 | public bool ReplaceNumericHyphens
339 | {
340 | get
341 | {
342 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->replace_numeric_hyphens != 0;
343 | }
344 |
345 | set
346 | {
347 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->replace_numeric_hyphens = (byte)(value ? 1 : 0);
348 | }
349 | }
350 |
351 | public bool DeleteNumericHyphens
352 | {
353 | get
354 | {
355 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_numeric_hyphens != 0;
356 | }
357 |
358 | set
359 | {
360 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_numeric_hyphens = (byte)(value ? 1 : 0);
361 | }
362 | }
363 |
364 | public bool SplitAlphaFromNumeric
365 | {
366 | get
367 | {
368 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->split_alpha_from_numeric != 0;
369 | }
370 |
371 | set
372 | {
373 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->split_alpha_from_numeric = (byte)(value ? 1 : 0);
374 | }
375 | }
376 |
377 | public bool ReplaceWordHyphens
378 | {
379 | get
380 | {
381 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->replace_word_hyphens != 0;
382 | }
383 |
384 | set
385 | {
386 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->replace_word_hyphens = (byte)(value ? 1 : 0);
387 | }
388 | }
389 |
390 | public bool DeleteWordHyphens
391 | {
392 | get
393 | {
394 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_word_hyphens != 0;
395 | }
396 |
397 | set
398 | {
399 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_word_hyphens = (byte)(value ? 1 : 0);
400 | }
401 | }
402 |
403 | public bool DeleteFinalPeriods
404 | {
405 | get
406 | {
407 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_final_periods != 0;
408 | }
409 |
410 | set
411 | {
412 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_final_periods = (byte)(value ? 1 : 0);
413 | }
414 | }
415 |
416 | public bool DeleteAcronymPeriods
417 | {
418 | get
419 | {
420 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_acronym_periods != 0;
421 | }
422 |
423 | set
424 | {
425 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_acronym_periods = (byte)(value ? 1 : 0);
426 | }
427 | }
428 |
429 | public bool DropEnglishPossessives
430 | {
431 | get
432 | {
433 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->drop_english_possessives != 0;
434 | }
435 |
436 | set
437 | {
438 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->drop_english_possessives = (byte)(value ? 1 : 0);
439 | }
440 | }
441 |
442 | public bool DeleteApostrophes
443 | {
444 | get
445 | {
446 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_apostrophes != 0;
447 | }
448 |
449 | set
450 | {
451 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->delete_apostrophes = (byte)(value ? 1 : 0);
452 | }
453 | }
454 |
455 | public bool ExpandNumex
456 | {
457 | get
458 | {
459 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->expand_numex != 0;
460 | }
461 |
462 | set
463 | {
464 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->expand_numex = (byte)(value ? 1 : 0);
465 | }
466 | }
467 |
468 | public bool RomanNumerals
469 | {
470 | get
471 | {
472 | return ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->roman_numerals != 0;
473 | }
474 |
475 | set
476 | {
477 | ((global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)__Instance)->roman_numerals = (byte)(value ? 1 : 0);
478 | }
479 | }
480 | }
481 |
482 | public unsafe partial class LibpostalAddressParserResponse : IDisposable
483 | {
484 | [StructLayout(LayoutKind.Explicit, Size = 24)]
485 | public partial struct __Internal
486 | {
487 | [FieldOffset(0)]
488 | internal ulong num_components;
489 |
490 | [FieldOffset(8)]
491 | internal global::System.IntPtr components;
492 |
493 | [FieldOffset(16)]
494 | internal global::System.IntPtr labels;
495 |
496 | [SuppressUnmanagedCodeSecurity]
497 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
498 | EntryPoint = "??0libpostal_address_parser_response@@QEAA@AEBU0@@Z")]
499 | internal static extern global::System.IntPtr cctor(global::System.IntPtr instance, global::System.IntPtr _0);
500 | }
501 |
502 | public global::System.IntPtr __Instance { get; protected set; }
503 |
504 | protected int __PointerAdjustment;
505 | internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary();
506 | protected void*[] __OriginalVTables;
507 |
508 | protected bool __ownsNativeInstance;
509 |
510 | internal static global::LibPostalNet.LibpostalAddressParserResponse __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
511 | {
512 | return new global::LibPostalNet.LibpostalAddressParserResponse(native.ToPointer(), skipVTables);
513 | }
514 |
515 | internal static global::LibPostalNet.LibpostalAddressParserResponse __CreateInstance(global::LibPostalNet.LibpostalAddressParserResponse.__Internal native, bool skipVTables = false)
516 | {
517 | return new global::LibPostalNet.LibpostalAddressParserResponse(native, skipVTables);
518 | }
519 |
520 | private static void* __CopyValue(global::LibPostalNet.LibpostalAddressParserResponse.__Internal native)
521 | {
522 | var ret = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalAddressParserResponse.__Internal));
523 | *(global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)ret = native;
524 | return ret.ToPointer();
525 | }
526 |
527 | private LibpostalAddressParserResponse(global::LibPostalNet.LibpostalAddressParserResponse.__Internal native, bool skipVTables = false)
528 | : this(__CopyValue(native), skipVTables)
529 | {
530 | __ownsNativeInstance = true;
531 | NativeToManagedMap[__Instance] = this;
532 | }
533 |
534 | protected LibpostalAddressParserResponse(void* native, bool skipVTables = false)
535 | {
536 | if (native == null)
537 | return;
538 | __Instance = new global::System.IntPtr(native);
539 | }
540 |
541 | public LibpostalAddressParserResponse()
542 | {
543 | __Instance = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalAddressParserResponse.__Internal));
544 | __ownsNativeInstance = true;
545 | NativeToManagedMap[__Instance] = this;
546 | }
547 |
548 | public LibpostalAddressParserResponse(global::LibPostalNet.LibpostalAddressParserResponse _0)
549 | {
550 | __Instance = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalAddressParserResponse.__Internal));
551 | __ownsNativeInstance = true;
552 | NativeToManagedMap[__Instance] = this;
553 | *((global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)__Instance) = *((global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)_0.__Instance);
554 | }
555 |
556 | ~LibpostalAddressParserResponse()
557 | {
558 | Dispose(false);
559 | }
560 |
561 | public void Dispose()
562 | {
563 | Dispose(disposing: true);
564 | GC.SuppressFinalize(this);
565 | }
566 |
567 | public virtual void Dispose(bool disposing)
568 | {
569 | if (__Instance == IntPtr.Zero)
570 | return;
571 | global::LibPostalNet.LibpostalAddressParserResponse __dummy;
572 | NativeToManagedMap.TryRemove(__Instance, out __dummy);
573 | if (__ownsNativeInstance)
574 | Marshal.FreeHGlobal(__Instance);
575 | __Instance = IntPtr.Zero;
576 | }
577 |
578 | public ulong NumComponents
579 | {
580 | get
581 | {
582 | return ((global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)__Instance)->num_components;
583 | }
584 |
585 | set
586 | {
587 | ((global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)__Instance)->num_components = value;
588 | }
589 | }
590 |
591 | public sbyte** Components
592 | {
593 | get
594 | {
595 | return (sbyte**)((global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)__Instance)->components;
596 | }
597 |
598 | set
599 | {
600 | ((global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)__Instance)->components = (global::System.IntPtr)value;
601 | }
602 | }
603 |
604 | public sbyte** Labels
605 | {
606 | get
607 | {
608 | return (sbyte**)((global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)__Instance)->labels;
609 | }
610 |
611 | set
612 | {
613 | ((global::LibPostalNet.LibpostalAddressParserResponse.__Internal*)__Instance)->labels = (global::System.IntPtr)value;
614 | }
615 | }
616 | }
617 |
618 | public unsafe partial class LibpostalAddressParserOptions : IDisposable
619 | {
620 | [StructLayout(LayoutKind.Explicit, Size = 16)]
621 | public partial struct __Internal
622 | {
623 | [FieldOffset(0)]
624 | internal global::System.IntPtr language;
625 |
626 | [FieldOffset(8)]
627 | internal global::System.IntPtr country;
628 |
629 | [SuppressUnmanagedCodeSecurity]
630 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
631 | EntryPoint = "??0libpostal_address_parser_options@@QEAA@AEBU0@@Z")]
632 | internal static extern global::System.IntPtr cctor(global::System.IntPtr instance, global::System.IntPtr _0);
633 | }
634 |
635 | public global::System.IntPtr __Instance { get; protected set; }
636 |
637 | protected int __PointerAdjustment;
638 | internal static readonly global::System.Collections.Concurrent.ConcurrentDictionary NativeToManagedMap = new global::System.Collections.Concurrent.ConcurrentDictionary();
639 | protected void*[] __OriginalVTables;
640 |
641 | protected bool __ownsNativeInstance;
642 |
643 | internal static global::LibPostalNet.LibpostalAddressParserOptions __CreateInstance(global::System.IntPtr native, bool skipVTables = false)
644 | {
645 | return new global::LibPostalNet.LibpostalAddressParserOptions(native.ToPointer(), skipVTables);
646 | }
647 |
648 | internal static global::LibPostalNet.LibpostalAddressParserOptions __CreateInstance(global::LibPostalNet.LibpostalAddressParserOptions.__Internal native, bool skipVTables = false)
649 | {
650 | return new global::LibPostalNet.LibpostalAddressParserOptions(native, skipVTables);
651 | }
652 |
653 | private static void* __CopyValue(global::LibPostalNet.LibpostalAddressParserOptions.__Internal native)
654 | {
655 | var ret = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalAddressParserOptions.__Internal));
656 | *(global::LibPostalNet.LibpostalAddressParserOptions.__Internal*)ret = native;
657 | return ret.ToPointer();
658 | }
659 |
660 | private LibpostalAddressParserOptions(global::LibPostalNet.LibpostalAddressParserOptions.__Internal native, bool skipVTables = false)
661 | : this(__CopyValue(native), skipVTables)
662 | {
663 | __ownsNativeInstance = true;
664 | NativeToManagedMap[__Instance] = this;
665 | }
666 |
667 | protected LibpostalAddressParserOptions(void* native, bool skipVTables = false)
668 | {
669 | if (native == null)
670 | return;
671 | __Instance = new global::System.IntPtr(native);
672 | }
673 |
674 | public LibpostalAddressParserOptions()
675 | {
676 | __Instance = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalAddressParserOptions.__Internal));
677 | __ownsNativeInstance = true;
678 | NativeToManagedMap[__Instance] = this;
679 | }
680 |
681 | public LibpostalAddressParserOptions(global::LibPostalNet.LibpostalAddressParserOptions _0)
682 | {
683 | __Instance = Marshal.AllocHGlobal(sizeof(global::LibPostalNet.LibpostalAddressParserOptions.__Internal));
684 | __ownsNativeInstance = true;
685 | NativeToManagedMap[__Instance] = this;
686 | *((global::LibPostalNet.LibpostalAddressParserOptions.__Internal*)__Instance) = *((global::LibPostalNet.LibpostalAddressParserOptions.__Internal*)_0.__Instance);
687 | }
688 |
689 | ~LibpostalAddressParserOptions()
690 | {
691 | Dispose(false);
692 | }
693 |
694 | public void Dispose()
695 | {
696 | Dispose(disposing: true);
697 | GC.SuppressFinalize(this);
698 | }
699 |
700 | public virtual void Dispose(bool disposing)
701 | {
702 | if (__Instance == IntPtr.Zero)
703 | return;
704 | global::LibPostalNet.LibpostalAddressParserOptions __dummy;
705 | NativeToManagedMap.TryRemove(__Instance, out __dummy);
706 | if (__ownsNativeInstance)
707 | Marshal.FreeHGlobal(__Instance);
708 | __Instance = IntPtr.Zero;
709 | }
710 |
711 | public string Language
712 | {
713 | get
714 | {
715 | return Marshal.PtrToStringAnsi(((global::LibPostalNet.LibpostalAddressParserOptions.__Internal*)__Instance)->language);
716 | }
717 |
718 | set
719 | {
720 | ((global::LibPostalNet.LibpostalAddressParserOptions.__Internal*)__Instance)->language = Marshal.StringToHGlobalAnsi(value);
721 | }
722 | }
723 |
724 | public string Country
725 | {
726 | get
727 | {
728 | return Marshal.PtrToStringAnsi(((global::LibPostalNet.LibpostalAddressParserOptions.__Internal*)__Instance)->country);
729 | }
730 |
731 | set
732 | {
733 | ((global::LibPostalNet.LibpostalAddressParserOptions.__Internal*)__Instance)->country = Marshal.StringToHGlobalAnsi(value);
734 | }
735 | }
736 | }
737 |
738 | public unsafe partial class libpostal
739 | {
740 |
741 | public partial struct __Internal
742 | {
743 | [SuppressUnmanagedCodeSecurity]
744 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
745 | EntryPoint = "libpostal_get_default_options")]
746 | internal static extern void LibpostalGetDefaultOptions(global::System.IntPtr @return);
747 |
748 | [SuppressUnmanagedCodeSecurity]
749 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
750 | EntryPoint = "libpostal_expand_address")]
751 | internal static extern sbyte** LibpostalExpandAddress([MarshalAs(UnmanagedType.LPUTF8Str)] string input, global::LibPostalNet.LibpostalNormalizeOptions.__Internal options, ulong* n);
752 |
753 | [SuppressUnmanagedCodeSecurity]
754 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
755 | EntryPoint = "libpostal_expansion_array_destroy")]
756 | internal static extern void LibpostalExpansionArrayDestroy(sbyte** expansions, ulong n);
757 |
758 | [SuppressUnmanagedCodeSecurity]
759 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
760 | EntryPoint = "libpostal_address_parser_response_destroy")]
761 | internal static extern void LibpostalAddressParserResponseDestroy(global::System.IntPtr self);
762 |
763 | [SuppressUnmanagedCodeSecurity]
764 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
765 | EntryPoint = "libpostal_get_address_parser_default_options")]
766 | internal static extern void LibpostalGetAddressParserDefaultOptions(global::System.IntPtr @return);
767 |
768 | [SuppressUnmanagedCodeSecurity]
769 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
770 | EntryPoint = "libpostal_parse_address")]
771 | internal static extern global::System.IntPtr LibpostalParseAddress([MarshalAs(UnmanagedType.LPUTF8Str)] string address, global::LibPostalNet.LibpostalAddressParserOptions.__Internal options);
772 |
773 | [SuppressUnmanagedCodeSecurity]
774 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
775 | EntryPoint = "libpostal_setup")]
776 | [return: MarshalAs(UnmanagedType.I1)]
777 | internal static extern bool LibpostalSetup();
778 |
779 | [SuppressUnmanagedCodeSecurity]
780 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
781 | EntryPoint = "libpostal_setup_datadir")]
782 | [return: MarshalAs(UnmanagedType.I1)]
783 | internal static extern bool LibpostalSetupDatadir([MarshalAs(UnmanagedType.LPUTF8Str)] string datadir);
784 |
785 | [SuppressUnmanagedCodeSecurity]
786 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
787 | EntryPoint = "libpostal_teardown")]
788 | internal static extern void LibpostalTeardown();
789 |
790 | [SuppressUnmanagedCodeSecurity]
791 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
792 | EntryPoint = "libpostal_setup_parser")]
793 | [return: MarshalAs(UnmanagedType.I1)]
794 | internal static extern bool LibpostalSetupParser();
795 |
796 | [SuppressUnmanagedCodeSecurity]
797 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
798 | EntryPoint = "libpostal_setup_parser_datadir")]
799 | [return: MarshalAs(UnmanagedType.I1)]
800 | internal static extern bool LibpostalSetupParserDatadir([MarshalAs(UnmanagedType.LPUTF8Str)] string datadir);
801 |
802 | [SuppressUnmanagedCodeSecurity]
803 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
804 | EntryPoint = "libpostal_teardown_parser")]
805 | internal static extern void LibpostalTeardownParser();
806 |
807 | [SuppressUnmanagedCodeSecurity]
808 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
809 | EntryPoint = "libpostal_setup_language_classifier")]
810 | [return: MarshalAs(UnmanagedType.I1)]
811 | internal static extern bool LibpostalSetupLanguageClassifier();
812 |
813 | [SuppressUnmanagedCodeSecurity]
814 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
815 | EntryPoint = "libpostal_setup_language_classifier_datadir")]
816 | [return: MarshalAs(UnmanagedType.I1)]
817 | internal static extern bool LibpostalSetupLanguageClassifierDatadir([MarshalAs(UnmanagedType.LPUTF8Str)] string datadir);
818 |
819 | [SuppressUnmanagedCodeSecurity]
820 | [DllImport("postal", CallingConvention = global::System.Runtime.InteropServices.CallingConvention.Cdecl,
821 | EntryPoint = "libpostal_teardown_language_classifier")]
822 | internal static extern void LibpostalTeardownLanguageClassifier();
823 | }
824 |
825 | public static global::LibPostalNet.LibpostalNormalizeOptions LibpostalGetDefaultOptions()
826 | {
827 | var __ret = new global::LibPostalNet.LibpostalNormalizeOptions.__Internal();
828 | __Internal.LibpostalGetDefaultOptions(new IntPtr(&__ret));
829 | return global::LibPostalNet.LibpostalNormalizeOptions.__CreateInstance(__ret);
830 | }
831 |
832 | public static global::LibPostalNet.LibpostalNormalizeResponse LibpostalExpandAddress(string input, global::LibPostalNet.LibpostalNormalizeOptions options)
833 | {
834 | var __arg1 = ReferenceEquals(options, null) ? new global::LibPostalNet.LibpostalNormalizeOptions.__Internal() : *(global::LibPostalNet.LibpostalNormalizeOptions.__Internal*)options.__Instance;
835 | var __arg2 = new ulong();
836 | var __ret = __Internal.LibpostalExpandAddress(input, __arg1, &__arg2);
837 | global::LibPostalNet.LibpostalNormalizeResponse __result0;
838 | if (__arg2 == (ulong)0) __result0 = null;
839 | __result0 = global::LibPostalNet.LibpostalNormalizeResponse.__CreateInstance(__ret, __arg2);
840 | return __result0;
841 |
842 | }
843 |
844 | public static void LibpostalExpansionArrayDestroy(sbyte** expansions, ulong n)
845 | {
846 | __Internal.LibpostalExpansionArrayDestroy(expansions, n);
847 | }
848 |
849 | public static void LibpostalAddressParserResponseDestroy(global::LibPostalNet.LibpostalAddressParserResponse self)
850 | {
851 | var __arg0 = ReferenceEquals(self, null) ? global::System.IntPtr.Zero : self.__Instance;
852 | __Internal.LibpostalAddressParserResponseDestroy(__arg0);
853 | }
854 |
855 | public static global::LibPostalNet.LibpostalAddressParserOptions LibpostalGetAddressParserDefaultOptions()
856 | {
857 | var __ret = new global::LibPostalNet.LibpostalAddressParserOptions.__Internal();
858 | __Internal.LibpostalGetAddressParserDefaultOptions(new IntPtr(&__ret));
859 | return global::LibPostalNet.LibpostalAddressParserOptions.__CreateInstance(__ret);
860 | }
861 |
862 | public static global::LibPostalNet.LibpostalAddressParserResponse LibpostalParseAddress(string address, global::LibPostalNet.LibpostalAddressParserOptions options)
863 | {
864 | var __arg1 = ReferenceEquals(options, null) ? new global::LibPostalNet.LibpostalAddressParserOptions.__Internal() : *(global::LibPostalNet.LibpostalAddressParserOptions.__Internal*)options.__Instance;
865 | var __ret = __Internal.LibpostalParseAddress(address, __arg1);
866 | global::LibPostalNet.LibpostalAddressParserResponse __result0;
867 | if (__ret == IntPtr.Zero) __result0 = null;
868 | else if (global::LibPostalNet.LibpostalAddressParserResponse.NativeToManagedMap.ContainsKey(__ret))
869 | __result0 = (global::LibPostalNet.LibpostalAddressParserResponse)global::LibPostalNet.LibpostalAddressParserResponse.NativeToManagedMap[__ret];
870 | else __result0 = global::LibPostalNet.LibpostalAddressParserResponse.__CreateInstance(__ret);
871 | return __result0;
872 | }
873 |
874 | public static bool LibpostalSetup()
875 | {
876 | var __ret = __Internal.LibpostalSetup();
877 | return __ret;
878 | }
879 |
880 | public static bool LibpostalSetupDatadir(string datadir)
881 | {
882 | var __ret = __Internal.LibpostalSetupDatadir(datadir);
883 | return __ret;
884 | }
885 |
886 | public static void LibpostalTeardown()
887 | {
888 | __Internal.LibpostalTeardown();
889 | }
890 |
891 | public static bool LibpostalSetupParser()
892 | {
893 | var __ret = __Internal.LibpostalSetupParser();
894 | return __ret;
895 | }
896 |
897 | public static bool LibpostalSetupParserDatadir(string datadir)
898 | {
899 | var __ret = __Internal.LibpostalSetupParserDatadir(datadir);
900 | return __ret;
901 | }
902 |
903 | public static void LibpostalTeardownParser()
904 | {
905 | __Internal.LibpostalTeardownParser();
906 | }
907 |
908 | public static bool LibpostalSetupLanguageClassifier()
909 | {
910 | var __ret = __Internal.LibpostalSetupLanguageClassifier();
911 | return __ret;
912 | }
913 |
914 | public static bool LibpostalSetupLanguageClassifierDatadir(string datadir)
915 | {
916 | var __ret = __Internal.LibpostalSetupLanguageClassifierDatadir(datadir);
917 | return __ret;
918 | }
919 |
920 | public static void LibpostalTeardownLanguageClassifier()
921 | {
922 | __Internal.LibpostalTeardownLanguageClassifier();
923 | }
924 | }
925 | }
926 |
--------------------------------------------------------------------------------
/LibPostalNet/libpostal.h:
--------------------------------------------------------------------------------
1 | #ifndef LIBPOSTAL_H
2 | #define LIBPOSTAL_H
3 |
4 | //#ifdef __cplusplus
5 | extern "C" {
6 | //#endif
7 |
8 | #include
9 | #include
10 | #include
11 | #include
12 |
13 | //added for making win32 DLL
14 | #ifdef _WIN32
15 | # define LIBPOSTAL_DLLEXPORT __declspec(dllexport)
16 | #elif __GNUC__ >= 4
17 | # define LIBPOSTAL_DLLEXPORT __attribute__ ((visibility("default")))
18 | #else
19 | # define LIBPOSTAL_DLLEXPORT
20 | #endif
21 |
22 | #define LIBPOSTAL_MAX_LANGUAGE_LEN 4
23 |
24 | /*
25 | Address dictionaries
26 | */
27 | // Bit set, should be able to keep it at a short (uint16_t)
28 | #define LIBPOSTAL_ADDRESS_NONE 0
29 | #define LIBPOSTAL_ADDRESS_ANY (1 << 0)
30 | #define LIBPOSTAL_ADDRESS_NAME (1 << 1)
31 | #define LIBPOSTAL_ADDRESS_HOUSE_NUMBER (1 << 2)
32 | #define LIBPOSTAL_ADDRESS_STREET (1 << 3)
33 | #define LIBPOSTAL_ADDRESS_UNIT (1 << 4)
34 | #define LIBPOSTAL_ADDRESS_LEVEL (1 << 5)
35 | #define LIBPOSTAL_ADDRESS_STAIRCASE (1 << 6)
36 | #define LIBPOSTAL_ADDRESS_ENTRANCE (1 << 7)
37 |
38 | #define LIBPOSTAL_ADDRESS_CATEGORY (1 << 8)
39 | #define LIBPOSTAL_ADDRESS_NEAR (1 << 9)
40 |
41 | #define LIBPOSTAL_ADDRESS_TOPONYM (1 << 13)
42 | #define LIBPOSTAL_ADDRESS_POSTAL_CODE (1 << 14)
43 | #define LIBPOSTAL_ADDRESS_PO_BOX (1 << 15)
44 | #define LIBPOSTAL_ADDRESS_ALL ((1 << 16) - 1)
45 |
46 |
47 | typedef struct libpostal_normalize_options {
48 | // List of language codes
49 | char **languages;
50 | size_t num_languages;
51 | uint16_t address_components;
52 |
53 | // String options
54 | bool latin_ascii;
55 | bool transliterate;
56 | bool strip_accents;
57 | bool decompose;
58 | bool lowercase;
59 | bool trim_string;
60 | bool drop_parentheticals;
61 | bool replace_numeric_hyphens;
62 | bool delete_numeric_hyphens;
63 | bool split_alpha_from_numeric;
64 | bool replace_word_hyphens;
65 | bool delete_word_hyphens;
66 | bool delete_final_periods;
67 | bool delete_acronym_periods;
68 | bool drop_english_possessives;
69 | bool delete_apostrophes;
70 | bool expand_numex;
71 | bool roman_numerals;
72 |
73 | } libpostal_normalize_options_t;
74 |
75 | LIBPOSTAL_DLLEXPORT libpostal_normalize_options_t libpostal_get_default_options(void);
76 |
77 | LIBPOSTAL_DLLEXPORT char **libpostal_expand_address(char *input, libpostal_normalize_options_t options, size_t *n);
78 |
79 | LIBPOSTAL_DLLEXPORT void libpostal_expansion_array_destroy(char **expansions, size_t n);
80 |
81 | /*
82 | Address parser
83 | */
84 |
85 | typedef struct libpostal_address_parser_response {
86 | size_t num_components;
87 | char **components;
88 | char **labels;
89 | } libpostal_address_parser_response_t;
90 |
91 | typedef struct libpostal_address_parser_options {
92 | char *language;
93 | char *country;
94 | } libpostal_address_parser_options_t;
95 |
96 | LIBPOSTAL_DLLEXPORT void libpostal_address_parser_response_destroy(libpostal_address_parser_response_t *self);
97 |
98 | LIBPOSTAL_DLLEXPORT libpostal_address_parser_options_t libpostal_get_address_parser_default_options(void);
99 |
100 | LIBPOSTAL_DLLEXPORT libpostal_address_parser_response_t *libpostal_parse_address(char *address, libpostal_address_parser_options_t options);
101 |
102 | // Setup/teardown methods
103 |
104 | LIBPOSTAL_DLLEXPORT bool libpostal_setup(void);
105 | LIBPOSTAL_DLLEXPORT bool libpostal_setup_datadir(char *datadir);
106 | LIBPOSTAL_DLLEXPORT void libpostal_teardown(void);
107 |
108 | LIBPOSTAL_DLLEXPORT bool libpostal_setup_parser(void);
109 | LIBPOSTAL_DLLEXPORT bool libpostal_setup_parser_datadir(char *datadir);
110 | LIBPOSTAL_DLLEXPORT void libpostal_teardown_parser(void);
111 |
112 | LIBPOSTAL_DLLEXPORT bool libpostal_setup_language_classifier(void);
113 | LIBPOSTAL_DLLEXPORT bool libpostal_setup_language_classifier_datadir(char *datadir);
114 | LIBPOSTAL_DLLEXPORT void libpostal_teardown_language_classifier(void);
115 |
116 | #ifdef __cplusplus
117 | }
118 | #endif
119 |
120 | #endif
121 |
--------------------------------------------------------------------------------
/LibPostalNet/libpostalpartial.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace LibPostalNet
9 | {
10 | public partial class LibpostalNormalizeOptions
11 | {
12 | public string[] Langs
13 | {
14 | get
15 | {
16 | IList _lang = new List();
17 |
18 | unsafe
19 | {
20 | for (int buc = 0; buc < (int)NumLanguages; buc++)
21 | {
22 | sbyte* pLang = Languages[buc];
23 | _lang.Add(Marshal.PtrToStringAnsi((IntPtr)pLang));
24 | }
25 | }
26 |
27 | return _lang.ToArray();
28 | }
29 | }
30 | }
31 |
32 | public partial class LibpostalAddressParserResponse
33 | {
34 | public List> Results
35 | {
36 | get
37 | {
38 | var _results = new List>();
39 |
40 | unsafe
41 | {
42 | for (int buc = 0; buc < (int)NumComponents; buc++)
43 | {
44 | sbyte* pLabel = Labels[buc];
45 | sbyte* pComponent = Components[buc];
46 |
47 | _results.Add(new KeyValuePair(Marshal.PtrToStringUTF8((IntPtr)pLabel), Marshal.PtrToStringUTF8((IntPtr)pComponent)));
48 | }
49 | }
50 |
51 | return _results;
52 | }
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/LibPostalNet/postal.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mapo80/LibPostalNet/9fadd63e81b8780cc91c9442590bb0bff8fced95/LibPostalNet/postal.dll
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LibPostalNet
2 |
3 | This library provides C# bindings for libpostal (https://github.com/openvenues/libpostal).
4 |
5 | We've included a compiled version of libpostal (postal.dll) for use in the demo (LibPostalConsole), however,
6 | you are free to compile your own. However, you will need to download libpostal's data and models at
7 | https://github.com/openvenues/libpostal/tree/master/data if you have not already.
8 |
9 | Once you have the files downloaded, compile and run LibPostalConsole on the command line with 1 argument -
10 | the path to the data directory.
11 |
12 | ```
13 | .\LibPostalConsole.exe C:\LibPostalData
14 | ```
15 |
16 | ### Compiling libpostal on Windows
17 |
18 | Follow the instructions here: https://github.com/openvenues/libpostal#installation-windows
19 |
20 | Essentially, you are using some MSys2/MinGW to compile libpostal on a windows machine. Once you install
21 | MSys, it will give you a number of shells to choose from (shortcuts), pick "MSYS2 MinGW 64-bit", in order
22 | to ensure that the final DLL is built against msvcrt.dll and not msys-2.x.dll, otherwise C# / .NET will complain.
23 |
24 | Credit to https://github.com/mapo80 and https://github.com/mapo80/LibPostalNet
25 |
--------------------------------------------------------------------------------
/Tests/Simple.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.VisualStudio.TestTools.UnitTesting;
2 | using LibPostalNet;
3 |
4 | namespace Tests
5 | {
6 | [TestClass]
7 | public class Simple
8 | {
9 | [ClassInitialize]
10 | public static void SetupSimpleTests(TestContext testContext)
11 | {
12 | var dataPath = "C:\\libpostal";
13 | Assert.IsTrue(libpostal.LibpostalSetupDatadir(dataPath));
14 | Assert.IsTrue(libpostal.LibpostalSetupParserDatadir(dataPath));
15 | Assert.IsTrue(libpostal.LibpostalSetupLanguageClassifierDatadir(dataPath));
16 | }
17 |
18 | [ClassCleanup]
19 | public static void TeardownSimpleTests()
20 | {
21 | libpostal.LibpostalTeardown();
22 | libpostal.LibpostalTeardownParser();
23 | libpostal.LibpostalTeardownLanguageClassifier();
24 | }
25 |
26 | [TestMethod]
27 | public void BasicTest()
28 | {
29 | var query = "Av. Beira Mar 1647 - Salgueiros, 4400-382 Vila Nova de Gaia";
30 |
31 | var response = libpostal.LibpostalParseAddress(query, new LibpostalAddressParserOptions());
32 | Assert.IsNotNull(response.Results, "Parse had a null response");
33 | Assert.AreEqual((ulong)5, response.NumComponents, "Number of parsed elements incorrect.");
34 |
35 | libpostal.LibpostalAddressParserResponseDestroy(response);
36 |
37 | var expansion = libpostal.LibpostalExpandAddress(query, libpostal.LibpostalGetDefaultOptions());
38 | Assert.IsNotNull(expansion, "Expansion result is null");
39 | Assert.IsNotNull(expansion.Expansions, "Expansion array is null");
40 | Assert.IsTrue(expansion.Expansions.Length > 0, "Expansion had empty set of results");
41 | }
42 |
43 | [TestMethod]
44 | public void APBasedNormalization()
45 | {
46 | var query = "123 main st apt 2";
47 |
48 | var options = libpostal.LibpostalGetDefaultOptions();
49 | var expansion = libpostal.LibpostalExpandAddress(query, options);
50 |
51 | options.AddressComponents = LibpostalNormalizeOptions.LIBPOSTAL_ADDRESS_HOUSE_NUMBER|LibpostalNormalizeOptions.LIBPOSTAL_ADDRESS_UNIT;
52 | var expansion2 = libpostal.LibpostalExpandAddress(query, options);
53 | Assert.IsNotNull(expansion, "Expansion result is null");
54 | Assert.IsNotNull(expansion.Expansions, "Expansion array is null");
55 | Assert.IsTrue(expansion.Expansions.Length != expansion2.Expansions.Length, "Expansions should be different.");
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Tests/Tests.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netcoreapp2.2
5 |
6 | false
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------