Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GPTGrammarParsing
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
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Contributor 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
Noah Heuser
GPTGrammarParsing
Commits
c13f018f
Commit
c13f018f
authored
11 months ago
by
Noah Heuser
Browse files
Options
Downloads
Patches
Plain Diff
added runType3Grammar
parent
8ef9e0f8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ChatGPTParsing/src/writer/Writer.java
+25
-2
25 additions, 2 deletions
ChatGPTParsing/src/writer/Writer.java
with
25 additions
and
2 deletions
ChatGPTParsing/src/writer/Writer.java
+
25
−
2
View file @
c13f018f
...
@@ -10,6 +10,7 @@ import java.util.Set;
...
@@ -10,6 +10,7 @@ import java.util.Set;
import
grammar.Grammar
;
import
grammar.Grammar
;
import
grammar.Type2Grammar
;
import
grammar.Type2Grammar
;
import
grammar.Type3Grammar
;
import
type2.Type2Parser
;
import
type2.Type2Parser
;
import
type3.Type3Parser
;
import
type3.Type3Parser
;
import
word_generator.WordGenerator
;
import
word_generator.WordGenerator
;
...
@@ -56,7 +57,7 @@ public class Writer {
...
@@ -56,7 +57,7 @@ public class Writer {
for
(
int
j
=
0
;
j
<
DISTINCT_WORDS
;
j
++)
{
for
(
int
j
=
0
;
j
<
DISTINCT_WORDS
;
j
++)
{
if
(
type
==
2
)
{
if
(
type
==
2
)
{
bw
.
write
(
t2p
.
isPartOfLanguage
(
g
.
getRules
(),
words
.
get
(
i
++),
g
.
getStart
())
?
"true"
:
"false"
);
bw
.
write
(
t2p
.
isPartOfLanguage
(
g
.
getRules
(),
words
.
get
(
i
++),
g
.
getStart
())
?
"true"
:
"false"
);
}
else
{
}
else
if
(
type
==
3
)
{
bw
.
write
(
t3p
.
isPartOfLanguage
(
g
.
getRules
(),
words
.
get
(
i
++),
g
.
getStart
())
?
"true"
:
"false"
);
bw
.
write
(
t3p
.
isPartOfLanguage
(
g
.
getRules
(),
words
.
get
(
i
++),
g
.
getStart
())
?
"true"
:
"false"
);
}
}
bw
.
newLine
();
bw
.
newLine
();
...
@@ -84,7 +85,6 @@ public class Writer {
...
@@ -84,7 +85,6 @@ public class Writer {
distinctWords
.
add
(
word
);
distinctWords
.
add
(
word
);
words
.
add
(
word
);
words
.
add
(
word
);
jsonGrammarWordPairs
.
add
(
createJSONGrammarWordPair
(
g
.
toJSON
(),
word
));
jsonGrammarWordPairs
.
add
(
createJSONGrammarWordPair
(
g
.
toJSON
(),
word
));
j
++;
j
++;
}
}
}
}
...
@@ -93,6 +93,29 @@ public class Writer {
...
@@ -93,6 +93,29 @@ public class Writer {
writeJSONToFile
(
jsonGrammarWordPairs
);
writeJSONToFile
(
jsonGrammarWordPairs
);
}
}
public
void
runType3Grammar
(
String
[]
vars
,
int
alphaSize
,
int
maxConclusios
,
String
start
,
int
mode
,
int
n
)
{
List
<
String
>
jsonGrammarWordPairs
=
new
LinkedList
<>();
List
<
Grammar
>
grammars
=
new
LinkedList
<>();
List
<
String
>
words
=
new
LinkedList
<>();
for
(
int
i
=
0
;
i
<
n
;
i
++)
{
Type3Grammar
g
=
new
Type3Grammar
(
vars
,
alphaSize
,
start
,
maxConclusios
,
mode
);
grammars
.
add
(
g
);
Set
<
String
>
distinctWords
=
new
HashSet
<>();
int
j
=
0
;
while
(
j
<
DISTINCT_WORDS
)
{
String
word
=
wg
.
wordGenerator
(
MAX_LENGTH
,
alphaSize
);
if
(!
distinctWords
.
contains
(
word
))
{
distinctWords
.
add
(
word
);
words
.
add
(
word
);
jsonGrammarWordPairs
.
add
(
createJSONGrammarWordPair
(
g
.
toJSON
(),
word
));
j
++;
}
}
}
writeResultToFile
(
grammars
,
words
,
3
);
writeJSONToFile
(
jsonGrammarWordPairs
);
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
Writer
w
=
new
Writer
();
Writer
w
=
new
Writer
();
String
[]
vars
=
{
"S"
,
"A"
,
"B"
};
String
[]
vars
=
{
"S"
,
"A"
,
"B"
};
...
...
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