/    Sign up×
Community /Pin to ProfileBookmark

Stemming algorithm like porter for php

[FONT=Arial]hi [/FONT]?

i use porter algorithm for stemming words (stemming is the process of reducing inflected (or sometimes derived) words to their word stem, base or root form—generally a written word form. The stem need not be identical to the morphological root of the word; it is usually sufficient that related words map to the same stem, even if this stem is not in itself a valid root. for example, should identify the string
“cats” (and possibly “catlike”, “catty” etc.) as based on the root
“cat”, and “stems”, “stemmer”, “stemming”, “stemmed” as based on “stem”.) i hope you understand stemming now,,,
my porter algorithm have some problem,,,like Germany should remain Germany but its turn to “Germani” and family should remain same but changes to “famili” and military and beauty ,,,or “friendly” should turn to “friend” but its change to “friendli” or its make “uniqu” or “awesom” the letter “E” is deleted,,,and many problem like this,,, is there any porter better than this porter algorithm or other algorithm?
its current porter algorithm that i am using:
is exist in this link “http://tartarus.org/~martin/PorterStemmer/php.txt“;

and with this example you can use this class in other files ?

[code=php]
require_once ‘porter.php’;

$stem = PorterStemmer::Stem($word);
$stem_words[] = $stem;
[/code]

i am waiting for your valuable helps…

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmApr 23.2016 — Are you kidding me?
Copy linkTweet thisAlerts:
@NogDogApr 23.2016 — Well, here's what is changing the 'y' to an 'i':
[code=php]
/**
* Step 1c
*
* @param string $word Word to stem
*/
private static function step1c($word)
{
$v = self::$regex_vowel;

if (substr($word, -1) == 'y' && preg_match("#$v+#", substr($word, 0, -1))) {
self::replace($word, 'y', 'i');
}

return $word;
}
[/code]

I'm wondering if the author meant for it to be reversed: changing something ending in "i" to end in "y", in particular as a result of this earlier case:
[code=php]
/**
* Step 1
*/
private static function step1ab($word)
{
// Part a
if (substr($word, -1) == 's') {

self::replace($word, 'sses', 'ss')
OR self::replace($word, 'ies', 'i') // <<----- this one
OR self::replace($word, 'ss', 'ss')
OR self::replace($word, 's', '');
}
[/code]

If so, you could try changing that first snippet to change the order of the replace() call to:
[code=php]
self::replace($word, 'i', 'y');
[/code]
Copy linkTweet thisAlerts:
@labourauthorApr 23.2016 — Are you kidding me?[/QUOTE]

@ginerjm

no,, why you telling this?
Copy linkTweet thisAlerts:
@labourauthorApr 23.2016 — thanks,,,but some problems still remains,,,is there any better algorithm for do this job better?
Copy linkTweet thisAlerts:
@NogDogApr 23.2016 — thanks,,,but some problems still remains,,,is there any better algorithm for do this job better?[/QUOTE]

I do not know: i'd have to Google to find out, and I'm sure you could do that as well as I could. ?
×

Success!

Help @labour spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...