Skip to content

Commit

Permalink
Update for php7.
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleigh committed Apr 27, 2016
1 parent 411f9ec commit c1a8d43
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 69 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
Before installing Limelight, you must install both mecab and the php extension php-mecab on your system.

###### Linux Ubuntu Users
Use the install script included in this repository.
Use the install script included in this repository. The script only works for and php7.
Download the script:
```
curl -O https://raw.githubusercontent.com/nihongodera/limelight/master/install_mecab_php-mecab.sh
Expand All @@ -43,6 +43,8 @@ Execute the script:
```
./install_mecab_php-mecab.sh
```
You may need to restart your server to complete the process.

For information about what the script does, see [here](https://github.com/nihongodera/limelight/wiki/Install-Script).

###### Other Systems
Expand Down
16 changes: 12 additions & 4 deletions install_mecab_php-mecab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,29 @@ START=$PWD

HASMECAB=$(php -r 'echo extension_loaded("mecab");')

OUTPUT=$(php --version)

LONGVERSION=$(echo $OUTPUT | cut -d ' ' -f2 | cut -d '-' -f1)

SHORTVERSION=${LONGVERSION%??}

echo $SHORTVERSION

echo "${GREEN}Installing dependencies...${NC}"
sudo apt-get install mecab mecab-ipadic-utf8 mecab-utils libmecab-dev unzip build-essential php5-dev
sudo apt-get install mecab mecab-ipadic-utf8 mecab-utils libmecab-dev unzip build-essential php7.0-dev

if [ $HASMECAB ] ; then
echo "${BLUE}php-mecab is already installed.${NC}"

elif [ -d /etc/php5/mods-available ] ; then
elif [ -d /etc/php/$SHORTVERSION/mods-available ] ; then
echo "${GREEN}Installing php-mecab...${NC}"
wget https://github.com/nihongodera/php-mecab/archive/master.zip
unzip master.zip
cd php-mecab-master/mecab && phpize && ./configure --with-php-config=/usr/bin/php-config --with-mecab-config=/usr/bin/mecab-config && make && sudo make install
cd /etc/php5/mods-available/
cd /etc/php/$SHORTVERSION/mods-available
sudo touch mecab.ini
echo "extension=mecab.so" | sudo tee -a mecab.ini
sudo php5enmod mecab
sudo phpenmod -v $SHORTVERSION mecab

echo "${BLUE}Cleaning up...${NC}"

Expand Down
9 changes: 0 additions & 9 deletions src/Mecab/Mecab.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,4 @@ public function parseToMecabNode($string);
* @return string
*/
public function parseToString($string);

/**
* Split string into array.
*
* @param string $string
*
* @return array
*/
public function split($string);
}
16 changes: 0 additions & 16 deletions src/Mecab/PhpMecab/PhpMecab.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,6 @@ public function parseToString($string)
return $this->mecab->parseToString($string);
}

/**
* Split string into array.
*
* @param string $string
*
* @return array
*/
public function split($string)
{
if (isset($this->options['dictionary'])) {
return mecab_split($string, $this->options['dictionary']);
}

return mecab_split($string);
}

/**
* Make instance of MeCab_Tagger.
*
Expand Down
14 changes: 0 additions & 14 deletions tests/Integration/LimelightTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,6 @@ public function it_can_access_mecab_parseToString_method()
$this->assertContains('形容詞,自立,*,*,形容詞・イ段,基本形,美味しい,オイシイ,オイシイ', $results);
}

/**
* @test
*/
public function it_can_access_mecab_split_method()
{
$results = self::$limelight->mecabSplit('めっちゃ眠い。');

$this->assertEquals('めっちゃ', $results[0]);

$this->assertEquals('眠い', $results[1]);

$this->assertEquals('', $results[2]);
}

/**
* @test
*/
Expand Down
14 changes: 0 additions & 14 deletions tests/Integration/Mecab/PhpMecabTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,4 @@ public function it_can_access_mecab_parseToString_method()

$this->assertContains('形容詞,自立,*,*,形容詞・イ段,基本形,美味しい,オイシイ,オイシイ', $results);
}

/**
* @test
*/
public function it_can_access_mecab_split_method()
{
$results = self::$phpmecab->split('めっちゃ眠い。');

$this->assertEquals('めっちゃ', $results[0]);

$this->assertEquals('眠い', $results[1]);

$this->assertEquals('', $results[2]);
}
}
11 changes: 0 additions & 11 deletions tests/Unit/MecabTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,4 @@ public function it_has_parseToString_method()
'Mecab does not have method parseToString.'
);
}

/**
* @test
*/
public function it_has_split_method()
{
$this->assertTrue(
method_exists(self::$mecab, 'split'),
'Mecab does not have method split.'
);
}
}

0 comments on commit c1a8d43

Please sign in to comment.