Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eecs398-search
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vcday
eecs398-search
Commits
21ea7013
Commit
21ea7013
authored
6 years ago
by
vcday
Browse files
Options
Downloads
Patches
Plain Diff
parser2test
parent
9d6ff5d8
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
crawler/Readers/LocalReader.cpp
+1
-1
1 addition, 1 deletion
crawler/Readers/LocalReader.cpp
tests/plaintext.txt
+6
-2
6 additions, 2 deletions
tests/plaintext.txt
util/Stemmer.cpp
+56
-3
56 additions, 3 deletions
util/Stemmer.cpp
util/tests/stemmerTest.cpp
+2
-0
2 additions, 0 deletions
util/tests/stemmerTest.cpp
with
65 additions
and
6 deletions
crawler/Readers/LocalReader.cpp
+
1
−
1
View file @
21ea7013
...
...
@@ -31,7 +31,7 @@ string LocalReader::PageToString ( )
ParsedUrl
LocalReader
::
getUrl
(
)
{
ParsedUrl
url
(
fileName
);
//Fixme
ParsedUrl
url
(
test_url
);
return
url
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/plaintext.txt
+
6
−
2
View file @
21ea7013
...
...
@@ -2,7 +2,11 @@
<title>
Apple Ardvark Anteater Alligator
</title>
<
body
>
<
p class="text-muted"
>
Basement Battle Bridge Bottle
</body>
</p>
<p class="text-muted">
Hello Goodbye <a href="http://veronicaday.com/" class="btn btn-yes">
Cat Cradle
</p>
</html>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
util/Stemmer.cpp
+
56
−
3
View file @
21ea7013
...
...
@@ -49,6 +49,12 @@ int Stemmer::measure ( std::string word )
int
m
=
0
;
unsigned
long
wordIt
=
0
;
unsigned
long
wordEnd
=
word
.
size
(
)
-
1
;
if
(
word
.
empty
(
)
)
{
return
0
;
}
// Looking for CVC pattern
while
(
wordIt
<=
wordEnd
)
{
...
...
@@ -108,6 +114,12 @@ int Stemmer::measure ( std::string word )
*/
bool
Stemmer
::
isVowelPresent
(
unsigned
long
wordBeg
,
unsigned
long
wordEnd
,
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
false
;
}
while
(
wordBeg
!=
wordEnd
&&
wordBeg
<
word
.
size
(
)
)
{
if
(
!
isConsonant
(
wordBeg
,
word
)
)
...
...
@@ -159,6 +171,11 @@ bool Stemmer::isConsonant ( unsigned long wordIt, string word )
*/
bool
Stemmer
::
addE
(
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
false
;
}
// AT -> ATE
// BL -> BLE
// IZ -> IZE
...
...
@@ -182,6 +199,11 @@ bool Stemmer::addE ( string word )
*/
bool
Stemmer
::
doubleCon
(
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
false
;
}
unsigned
long
endWord
=
word
.
size
(
)
-
1
;
if
(
word
.
size
(
)
>
2
&&
word
[
endWord
]
==
word
[
endWord
-
1
]
)
...
...
@@ -209,6 +231,12 @@ bool Stemmer::doubleCon ( string word )
*/
bool
Stemmer
::
endCVC
(
std
::
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
false
;
}
unsigned
long
endWord
=
word
.
size
(
)
-
1
;
if
(
word
.
size
(
)
>
2
)
...
...
@@ -236,6 +264,11 @@ bool Stemmer::endCVC ( std::string word )
std
::
string
Stemmer
::
step1a
(
std
::
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
word
;
}
// check S at end
if
(
word
[
word
.
size
(
)
-
1
]
==
's'
&&
word
.
size
()
!=
1
)
{
...
...
@@ -286,6 +319,12 @@ std::string Stemmer::step1a ( std::string word )
*/
std
::
string
Stemmer
::
step1b
(
std
::
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
word
;
}
unsigned
long
end
=
word
.
size
(
)
-
1
;
auto
begPtr
=
word
.
begin
(
);
auto
endPtr
=
begPtr
+
end
;
...
...
@@ -349,6 +388,10 @@ std::string Stemmer::step1b ( std::string word )
string
Stemmer
::
step1c
(
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
word
;
}
// Y -> I
// happy -> happi
// sky -> sky
...
...
@@ -371,7 +414,7 @@ string Stemmer::step1c ( string word )
*/
string
Stemmer
::
step2
(
std
::
string
word
)
{
if
(
measure
(
word
)
==
0
)
if
(
measure
(
word
)
==
0
||
word
.
empty
(
)
)
{
return
word
;
}
...
...
@@ -528,7 +571,7 @@ string Stemmer::step2 ( std::string word )
std
::
string
Stemmer
::
step3
(
std
::
string
word
)
{
if
(
measure
(
word
)
==
0
)
if
(
measure
(
word
)
==
0
||
word
.
empty
(
)
)
{
return
word
;
}
...
...
@@ -592,7 +635,7 @@ std::string Stemmer::step3 ( std::string word )
*/
std
::
string
Stemmer
::
step4
(
std
::
string
word
)
{
if
(
measure
(
word
)
<=
2
)
if
(
measure
(
word
)
<=
2
||
word
.
empty
(
)
)
{
return
word
;
}
...
...
@@ -730,6 +773,11 @@ std::string Stemmer::step4 ( std::string word )
*/
std
::
string
Stemmer
::
step5a
(
std
::
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
word
;
}
auto
m
=
measure
(
word
);
// E ->
// probabte -> probat
...
...
@@ -757,6 +805,11 @@ std::string Stemmer::step5a ( std::string word )
*/
std
::
string
Stemmer
::
step5b
(
std
::
string
word
)
{
if
(
word
.
empty
(
)
)
{
return
word
;
}
if
(
word
.
size
(
)
>
2
&&
measure
(
word
)
>
1
&&
word
[
word
.
size
(
)
-
1
]
==
'l'
&&
word
[
word
.
size
(
)
-
2
]
==
'l'
)
{
word
=
subStr
(
word
,
0
,
word
.
size
(
)
-
1
);
...
...
This diff is collapsed.
Click to expand it.
util/tests/stemmerTest.cpp
+
2
−
0
View file @
21ea7013
...
...
@@ -110,6 +110,8 @@ int main ( )
assert
(
stem
.
execute
(
"are"
)
==
"ar"
);
assert
(
stem
.
execute
(
"terrible"
)
==
"terribl"
);
assert
(
stem
.
execute
(
""
)
==
""
);
assert
(
stem
.
execute
(
"s"
)
==
"s"
);
cout
<<
"
\n
Tests passed for Stemmer :D"
<<
endl
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment