Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ACMclassifier
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
cs_nmohu001
ACMclassifier
Commits
63ab67f3
Commit
63ab67f3
authored
2 years ago
by
Marcelo
Browse files
Options
Downloads
Patches
Plain Diff
normalize class working, 3 tests pass testing
Parser.normalize
parent
edb3c003
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/edu/odu/cs/cs350/acmClassifier/Parser.java
+14
-2
14 additions, 2 deletions
src/main/java/edu/odu/cs/cs350/acmClassifier/Parser.java
src/test/java/edu/odu/cs/cs350/acmClassifier/TestParser.java
+43
-36
43 additions, 36 deletions
src/test/java/edu/odu/cs/cs350/acmClassifier/TestParser.java
with
57 additions
and
38 deletions
src/main/java/edu/odu/cs/cs350/acmClassifier/Parser.java
+
14
−
2
View file @
63ab67f3
package
edu.odu.cs.cs350.acmClassifier
;
import
java.util.ArrayList
;
//
import java.util.ArrayList;
public
class
Parser
{
...
...
@@ -19,17 +19,29 @@ public class Parser {
* @param Document object
**/
//public ArrayList<Integer> normalize(ArrayList<Integer> signatures){
/*
public static ArrayList<Integer > normalize(Document d){
for (int i = 0; i < d.wordCounts.size(); i++) {
if (d.wordCounts.get(i) >= 4){
d.wordCounts.set(i, 1);
}
}
else{
d.wordCounts.set(i, 0);
}
}
return d.wordCounts;
}
*/
public
static
void
normalize
(
Document
d
){
for
(
int
i
=
0
;
i
<
d
.
wordCounts
.
size
();
i
++){
if
(
d
.
wordCounts
.
get
(
i
)
>=
4
){
d
.
normalizedWordCounts
.
add
(
1.0
);
}
else
{
d
.
normalizedWordCounts
.
add
(
0.0
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/test/java/edu/odu/cs/cs350/acmClassifier/TestParser.java
+
43
−
36
View file @
63ab67f3
package
edu.odu.cs.cs350.acmClassifier
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
import
org.junit.jupiter.api.BeforeAll
;
import
org.junit.jupiter.api.Test
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
public
class
TestParser
{
/*
* expected normalized word counts
*/
private
Double
[]
normalized1
=
{
1.0
,
1.0
,
1.0
,
1.0
};
private
Double
[]
normalized2
=
{
0.0
,
0.0
,
0.0
,
0.0
};
private
Double
[]
normalized3
=
{
1.0
,
1.0
,
0.0
,
0.0
};
/*
* sample word counts
*/
private
Integer
[]
sampleWC1
=
{
4
,
5
,
7
,
9
};
private
Integer
[]
sampleWC2
=
{
3
,
2
,
1
,
2
};
private
Integer
[]
sampleWC3
=
{
6
,
5
,
1
,
1
};
@Test
void TestParser(){
fail("Not yet implemented");
}
*/
public
void
testNormalize1
(){
Document
test1
;
Document
test1
=
new
Document
()
;
@BeforeAll
public
void
init
(){
test1
=
new
Document
();
//ArrayList<Integer> this.wordCounts = new ArrayList<Integer>();
test1
.
wordCounts
=
new
ArrayList
<
Integer
>(
Arrays
.
asList
(
sampleWC1
));
Parser
.
normalize
(
test1
);
ArrayList
<
Double
>
expected
=
new
ArrayList
<
Double
>(
Arrays
.
asList
(
normalized1
));
assertEquals
(
expected
,
test1
.
normalizedWordCounts
);
}
@Test
public
void
testNormalize1
(){
public
void
testNormalize2
(){
Document
test2
=
new
Document
();
test2
.
wordCounts
=
new
ArrayList
<
Integer
>(
Arrays
.
asList
(
sampleWC2
));
//Document test1 = new Document();
//test1 = new Document();
Parser
.
normalize
(
test2
);
//
ArrayList<
String> test1.wordCounts = new ArrayList<String>(
);
ArrayList
<
Double
>
expected
=
new
ArrayList
<
Double
>(
Arrays
.
asList
(
normalized2
)
);
//test1.wordCounts = new ArrayList<>(
);
assertEquals
(
expected
,
test2
.
normalizedWordCounts
);
test1
.
wordCounts
.
add
(
4
);
test1
.
wordCounts
.
add
(
3
);
test1
.
wordCounts
.
add
(
5
);
test1
.
wordCounts
.
add
(
2
);
test1
.
wordCounts
.
add
(
1
);
}
@Test
public
void
testNormalize3
(){
Document
test3
=
new
Document
(
);
ArrayList
<
Integer
>
expected
=
new
ArrayList
<
Integer
>();
test3
.
wordCounts
=
new
ArrayList
<
Integer
>(
Arrays
.
asList
(
sampleWC3
)
);
for
(
int
i
=
0
;
i
<
5
;
i
++){
expected
.
add
(
1
);
}
Parser
.
normalize
(
test3
);
assertEquals
(
expected
,
Parser
.
normalize
(
test1
));
//assertArrayEquals(expected, Parser.normalize(test1));
ArrayList
<
Double
>
expected
=
new
ArrayList
<
Double
>(
Arrays
.
asList
(
normalized3
));
assertEquals
(
expected
,
test3
.
normalizedWordCounts
);
}
}
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