Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
markov
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Patrick Friedel
markov
Commits
99257c27
Commit
99257c27
authored
Feb 16, 2018
by
Hut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trigger gitlab CI
parent
e03e6f08
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
154 additions
and
52 deletions
+154
-52
Main.java
Markov/src/directory/passive/markov/Main.java
+4
-1
Parser.java
Markov/src/directory/passive/markov/Parser.java
+1
-49
ParserStreamStyle.java
Markov/src/directory/passive/markov/ParserStreamStyle.java
+5
-0
Parser_first_version.java
...ov/src/directory/passive/markov/Parser_first_version.java
+52
-0
Prefix.java
Markov/src/directory/passive/markov/Prefix.java
+15
-2
pom.xml
pom.xml
+77
-0
oldstyle
src/main/resources/oldstyle
+0
-0
No files found.
Markov/src/directory/passive/markov/Main.java
View file @
99257c27
...
@@ -3,8 +3,11 @@ package directory.passive.markov;
...
@@ -3,8 +3,11 @@ package directory.passive.markov;
public
class
Main
{
public
class
Main
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
input
);
System
.
exit
(
0
);
int
prefixLength
=
2
;
int
prefixLength
=
2
;
Data
data
=
new
Parser
(
prefixLength
).
parse
(
input
);
Data
data
=
new
Parser
_first_version
(
prefixLength
).
parse
(
input
);
Builder
b
=
new
Builder
(
prefixLength
,
data
);
Builder
b
=
new
Builder
(
prefixLength
,
data
);
Renderer
r
=
new
Renderer
(
data
,
Renderer
.
Options
.
FULL
);
Renderer
r
=
new
Renderer
(
data
,
Renderer
.
Options
.
FULL
);
for
(
int
i
=
0
;
i
<
25
;
i
++)
{
for
(
int
i
=
0
;
i
<
25
;
i
++)
{
...
...
Markov/src/directory/passive/markov/Parser.java
View file @
99257c27
package
directory
.
passive
.
markov
;
package
directory
.
passive
.
markov
;
public
class
Parser
{
public
interface
Parser
{
private
final
int
prefix_length
;
public
Parser
(
int
prefix_length
)
{
super
();
this
.
prefix_length
=
prefix_length
;
}
public
Data
parse
(
String
input
)
{
Data
data
=
new
Data
();
for
(
String
line
:
input
.
split
(
"\n"
))
{
line
=
line
.
replace
(
"Kai☺UWE empfiehlt "
,
""
);
Token
[]
tokens
=
tokenize
(
line
);
for
(
int
i
=
0
+
prefix_length
;
i
<
tokens
.
length
;
i
++)
{
Prefix
p
=
getPrefix
(
tokens
,
i
);
Token
t
=
getToken
(
tokens
,
i
);
data
.
add
(
p
,
t
);
}
}
return
data
;
}
private
Token
[]
tokenize
(
String
line
)
{
String
[]
strings
=
line
.
split
(
" "
);
Token
[]
tokens
=
new
Token
[
strings
.
length
+
prefix_length
+
1
];
int
i
=
0
;
for
(;
i
<
prefix_length
;
i
++)
{
tokens
[
i
]
=
Token
.
START
;
}
for
(;
i
<
strings
.
length
+
prefix_length
;
i
++)
{
tokens
[
i
]
=
new
Token
(
strings
[
i
-
prefix_length
]);
}
tokens
[
i
]
=
Token
.
END
;
return
tokens
;
}
private
Prefix
getPrefix
(
Token
[]
tokens
,
int
index
)
{
Token
[]
prefixTokens
=
new
Token
[
prefix_length
];
for
(
int
i
=
0
;
i
<
prefix_length
;
i
++)
{
prefixTokens
[
i
]
=
tokens
[
index
-
prefix_length
+
i
];
}
return
new
Prefix
(
prefixTokens
);
}
private
Token
getToken
(
Token
[]
tokens
,
int
i
)
{
return
tokens
[
i
];
}
}
}
Markov/src/directory/passive/markov/ParserStreamStyle.java
0 → 100644
View file @
99257c27
package
directory
.
passive
.
markov
;
public
class
ParserStreamStyle
{
}
Markov/src/directory/passive/markov/Parser_first_version.java
0 → 100644
View file @
99257c27
package
directory
.
passive
.
markov
;
public
class
Parser_first_version
{
private
final
int
prefix_length
;
public
Parser_first_version
(
int
prefix_length
)
{
super
();
this
.
prefix_length
=
prefix_length
;
}
public
Data
parse
(
String
input
)
{
Data
data
=
new
Data
();
for
(
String
line
:
input
.
split
(
"\n"
))
{
line
=
line
.
replace
(
"Kai☺UWE empfiehlt "
,
""
);
Token
[]
tokens
=
tokenize
(
line
);
for
(
int
i
=
0
+
prefix_length
;
i
<
tokens
.
length
;
i
++)
{
Prefix
p
=
getPrefix
(
tokens
,
i
);
Token
t
=
getToken
(
tokens
,
i
);
data
.
add
(
p
,
t
);
}
}
return
data
;
}
private
Token
[]
tokenize
(
String
line
)
{
String
[]
strings
=
line
.
split
(
" "
);
Token
[]
tokens
=
new
Token
[
strings
.
length
+
prefix_length
+
1
];
int
i
=
0
;
for
(;
i
<
prefix_length
;
i
++)
{
tokens
[
i
]
=
Token
.
START
;
}
for
(;
i
<
strings
.
length
+
prefix_length
;
i
++)
{
tokens
[
i
]
=
new
Token
(
strings
[
i
-
prefix_length
]);
}
tokens
[
i
]
=
Token
.
END
;
return
tokens
;
}
private
Prefix
getPrefix
(
Token
[]
tokens
,
int
index
)
{
Token
[]
prefixTokens
=
new
Token
[
prefix_length
];
for
(
int
i
=
0
;
i
<
prefix_length
;
i
++)
{
prefixTokens
[
i
]
=
tokens
[
index
-
prefix_length
+
i
];
}
return
new
Prefix
(
prefixTokens
);
}
private
Token
getToken
(
Token
[]
tokens
,
int
i
)
{
return
tokens
[
i
];
}
}
Markov/src/directory/passive/markov/Prefix.java
View file @
99257c27
...
@@ -9,11 +9,11 @@ public class Prefix {
...
@@ -9,11 +9,11 @@ public class Prefix {
private
final
List
<
Token
>
tokens
;
private
final
List
<
Token
>
tokens
;
public
Prefix
(
Token
[]
tokens
)
{
public
Prefix
(
Token
[]
tokens
)
{
this
.
tokens
=
Arrays
.
asList
(
tokens
);
this
.
tokens
=
compressLeadingStarts
(
Arrays
.
asList
(
tokens
)
);
}
}
public
Prefix
(
List
<
Token
>
tokens
)
{
public
Prefix
(
List
<
Token
>
tokens
)
{
this
.
tokens
=
tokens
;
this
.
tokens
=
compressLeadingStarts
(
tokens
)
;
}
}
public
Prefix
slide
(
Token
newToken
)
{
public
Prefix
slide
(
Token
newToken
)
{
...
@@ -23,6 +23,19 @@ public class Prefix {
...
@@ -23,6 +23,19 @@ public class Prefix {
return
new
Prefix
(
newTokens
);
return
new
Prefix
(
newTokens
);
}
}
private
List
<
Token
>
compressLeadingStarts
(
List
<
Token
>
tokens
)
{
if
(
tokens
.
get
(
0
)
==
Token
.
START
)
{
for
(
int
i
=
1
;
i
<
tokens
.
size
();
i
++)
{
if
(
tokens
.
get
(
i
)
==
Token
.
START
)
{
tokens
.
remove
(
i
);
}
else
{
break
;
}
}
}
return
tokens
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"P="
+
tokens
;
return
"P="
+
tokens
;
...
...
pom.xml
0 → 100644
View file @
99257c27
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
passive.directory
</groupId>
<artifactId>
markov
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<java.version>
1.8
</java.version>
<junit.version>
4.12
</junit.version>
<junit.jupiter.version>
5.0.3
</junit.jupiter.version>
<junit.vintage.version>
${junit.version}.3
</junit.vintage.version>
<junit.platform.version>
1.1.0-RC1
</junit.platform.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.1
</version>
<configuration>
<source>
${java.version}
</source>
<target>
${java.version}
</target>
</configuration>
</plugin>
<plugin>
<artifactId>
maven-surefire-plugin
</artifactId>
<version>
2.19.1
</version>
<configuration>
<includes>
<include>
**/Test*.java
</include>
<include>
**/*Test.java
</include>
<include>
**/*Tests.java
</include>
<include>
**/*TestCase.java
</include>
</includes>
<properties>
<!-- <includeTags>fast</includeTags> -->
<excludeTags>
slow
</excludeTags>
<!--
<configurationParameters>
junit.jupiter.conditions.deactivate = *
</configurationParameters>
-->
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>
org.junit.platform
</groupId>
<artifactId>
junit-platform-surefire-provider
</artifactId>
<version>
${junit.platform.version}
</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>
org.junit.jupiter
</groupId>
<artifactId>
junit-jupiter-api
</artifactId>
<version>
${junit.jupiter.version}
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
${junit.version}
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
src/main/resources/oldstyle
0 → 100644
View file @
99257c27
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment