Skip to content

Commit

Permalink
Add company names.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pag-Man committed Aug 19, 2018
1 parent 4717b76 commit 64c1ff8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ $extractor = new \einfachArchiv\Extractor\Extractor($text, ['de', 'en']);
// Available methods
$extractor->findAmounts();
$extractor->findBics();
$extractor->findCompanyNames();
$extractor->findCompanyRegisterIds();
$extractor->findCustomerIds();
$extractor->findDates();
Expand Down Expand Up @@ -108,7 +109,6 @@ The method `->findTypes()` returns the following types:
'contract',
'balance-sheet',
'tax-assessment-note',
...
];
```

Expand Down
7 changes: 7 additions & 0 deletions src/CompanyName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace einfachArchiv\Extractor;

class CompanyName extends Extraction
{
}
20 changes: 20 additions & 0 deletions src/CompanyName/De.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace einfachArchiv\Extractor\CompanyName;

use einfachArchiv\Extractor\Extraction;

class De extends Extraction
{
/**
* Extracts company names from the text.
*
* @return array
*/
public function handle()
{
preg_match_all('/\b[A-ZÄÖÜßa-zäöü ]+ (?:GbR\b|OHG\b|GmbH & Co. KG\b|KG\b|Unternehmergesellschaft \(haftungsbeschränkt\)|UG \(haftungsbeschränkt\)|UG\b|GmbH\b|AG\b)/', $this->text, $matches);

return $matches[0];
}
}
20 changes: 20 additions & 0 deletions src/CompanyName/En.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace einfachArchiv\Extractor\CompanyName;

use einfachArchiv\Extractor\Extraction;

class En extends Extraction
{
/**
* Extracts company names from the text.
*
* @return array
*/
public function handle()
{
preg_match_all('/\b[A-Za-z ]+ (?:GP\b|LLP\b|LP\b|Corp\.|Inc\.|Ltd\.|LC\b|LLC\b)/', $this->text, $matches);

return $matches[0];
}
}
10 changes: 10 additions & 0 deletions src/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public function findBics()
return (new Bic($this->text))->handle();
}

/**
* Extracts company names from the text.
*
* @return array
*/
public function findCompanyNames()
{
return (new CompanyName($this->text, $this->locales))->handle();
}

/**
* Extracts company register IDs from the text.
*
Expand Down

0 comments on commit 64c1ff8

Please sign in to comment.