2017 © Pedro Pelรกez
 

library mecab

OOP Mecab Wrapper

image

wandu/mecab

OOP Mecab Wrapper

  • Sunday, December 4, 2016
  • by wan2land
  • Repository
  • 2 Watchers
  • 4 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 13 % Grown

The README.md

PHP Mecab

Latest Stable Version Latest Unstable Version Total Downloads License, (*1)

OOP Mecab Wrapper., (*2)

Installation

composer require wandu/mecab

How to use

Example ๋ถ„์„ํ•˜๊ธฐ parse, parseToString, parseToGenerator, (*3)

<?php
use Wandu\Mecab\Mecab;

$mecab = new Mecab('/usr/local/lib/mecab/dic/mecab-ko-dic');

$mecab->parseToString('๋™ํ•ด๋ฌผ๊ณผ ๋ฐฑ๋‘์‚ฐ์ด ๋งˆ๋ฅด๊ณ  ๋‹ณ๋„๋ก ํ•˜๋А๋‹˜์ด ๋ณด์šฐํ•˜์‚ฌ'); // return string

Result, (*4)

BOS
NOD (NNP,์ง€๋ช…,F,๋™ํ•ด,*,*,*,*): ๋™ํ•ด
NOD (NNG,*,T,๋ฌผ,*,*,*,*): ๋ฌผ
NOD (JC,*,F,๊ณผ,*,*,*,*): ๊ณผ
NOD (NNP,์ง€๋ช…,T,๋ฐฑ๋‘์‚ฐ,Compound,*,*,๋ฐฑ๋‘/NNG/*+์‚ฐ/NNG/*): ๋ฐฑ๋‘์‚ฐ
NOD (JKS,*,F,์ด,*,*,*,*): ์ด
NOD (VV,*,F,๋งˆ๋ฅด,*,*,*,*): ๋งˆ๋ฅด
NOD (EC,*,F,๊ณ ,*,*,*,*): ๊ณ 
NOD (VV,*,T,๋‹ณ,*,*,*,*): ๋‹ณ
NOD (EC,*,T,๋„๋ก,*,*,*,*): ๋„๋ก
NOD (NNG,*,T,ํ•˜๋А๋‹˜,Compound,*,*,ํ•˜๋А/NNG/*+๋‹˜/NNG/*): ํ•˜๋А๋‹˜
NOD (JKS,*,F,์ด,*,*,*,*): ์ด
NOD (NNG,*,F,๋ณด์šฐ,*,*,*,*): ๋ณด์šฐ
NOD (NNG,*,F,ํ•˜์‚ฌ,*,*,*,*): ํ•˜์‚ฌ
EOS

Example ํ’ˆ์‚ฌํƒœ๊ทธ๋กœ ํ•„ํ„ฐ๋งํ•˜๊ธฐ, (*5)

KoreaEunjeon์˜ ํƒœ๊ทธ๋Š” ์—ฌ๊ธฐ์— ์ž˜ ์ •๋ฆฌ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค., (*6)

<?php
use Wandu\Mecab\Mecab;
use Wandu\Mecab\Node;
use Wandu\Mecab\Tag\KoreaEunjeon;

$mecab = new Mecab('/usr/local/lib/mecab/dic/mecab-ko-dic');

$nodes = array_filter($mecab->parse('๋™ํ•ด๋ฌผ๊ณผ ๋ฐฑ๋‘์‚ฐ์ด ๋งˆ๋ฅด๊ณ  ๋‹ณ๋„๋ก ํ•˜๋А๋‹˜์ด ๋ณด์šฐํ•˜์‚ฌ'), function (Node $node) {
    return
        $node->hasTag(KoreaEunjeon::TAG_NNP) ||
        $node->hasTag(KoreaEunjeon::TAG_NNB) ||
        $node->hasTag(KoreaEunjeon::TAG_NNG);
});

Example ํ˜•ํƒœ์†Œ๋กœ ๋ถ„๋ฆฌํ•˜๊ธฐ split, (*7)

<?php
use Wandu\Mecab\Mecab;

$mecab = new Mecab('/usr/local/lib/mecab/dic/mecab-ko-dic');
$mecab->split('๋™ํ•ด๋ฌผ๊ณผ ๋ฐฑ๋‘์‚ฐ์ด ๋งˆ๋ฅด๊ณ  ๋‹ณ๋„๋ก ํ•˜๋А๋‹˜์ด ๋ณด์šฐํ•˜์‚ฌ'); // return array

Result, (*8)

[
    '๋™ํ•ด',
    '๋ฌผ',
    '๊ณผ',
    '๋ฐฑ๋‘์‚ฐ',
    '์ด',
    '๋งˆ๋ฅด',
    '๊ณ ',
    '๋‹ณ',
    '๋„๋ก',
    'ํ•˜๋А๋‹˜',
    '์ด',
    '๋ณด์šฐ',
    'ํ•˜์‚ฌ',
]

Reference

The Versions

04/12 2016

dev-master

9999999-dev

OOP Mecab Wrapper

  Sources   Download

MIT

The Requires

  • php >=5.6
  • ext-mecab *

 

The Development Requires

mecab

04/12 2016

v0.2.0

0.2.0.0

OOP Mecab Wrapper

  Sources   Download

MIT

The Requires

  • php >=5.6
  • ext-mecab *

 

The Development Requires

mecab

22/11 2016

v0.1.0

0.1.0.0

OOP Mecab Wrapper

  Sources   Download

MIT

The Requires

  • php >=5.6
  • ext-mecab *

 

The Development Requires

mecab