Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
opennars_googlecode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
We are moving to Forgejo!
You are on a read-only GitLab instance.
Show more breadcrumbs
opennars
opennars_googlecode
Commits
81e2b64d
Commit
81e2b64d
authored
17 years ago
by
jgeldart
Browse files
Options
Downloads
Patches
Plain Diff
Forgot to delete the Actuary tool. The new library won't use the same structure.
parent
c426293e
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
open-nars/tools/com/googlecode/opennars/tools/actuary/Actuary.java
+0
-151
0 additions, 151 deletions
.../tools/com/googlecode/opennars/tools/actuary/Actuary.java
with
0 additions
and
151 deletions
open-nars/tools/com/googlecode/opennars/tools/actuary/Actuary.java
deleted
100644 → 0
+
0
−
151
View file @
c426293e
package
com.googlecode.opennars.tools.actuary
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.net.MalformedURLException
;
import
java.net.URI
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.net.URLConnection
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Observable
;
import
java.util.Observer
;
import
com.googlecode.opennars.entity.Sentence
;
import
com.googlecode.opennars.entity.Task
;
import
com.googlecode.opennars.main.Reasoner
;
import
com.googlecode.opennars.parser.InvalidInputException
;
import
com.googlecode.opennars.parser.Parser
;
import
com.googlecode.opennars.parser.loan.LoanParser
;
import
com.googlecode.opennars.parser.loan.Loan.PrettyPrinter
;
import
com.googlecode.opennars.parser.loan.Loan.Absyn.BaseR
;
import
com.googlecode.opennars.parser.loan.Loan.Absyn.NSPrefix1
;
import
com.googlecode.opennars.parser.loan.Loan.Absyn.SentPrefix
;
import
com.martiansoftware.jsap.FlaggedOption
;
import
com.martiansoftware.jsap.JSAP
;
import
com.martiansoftware.jsap.JSAPResult
;
import
com.martiansoftware.jsap.Parameter
;
import
com.martiansoftware.jsap.SimpleJSAP
;
import
com.martiansoftware.jsap.UnflaggedOption
;
public
class
Actuary
implements
Observer
{
private
SimpleJSAP
jsap
;
private
Parser
parser
;
private
Reasoner
reasoner
;
private
int
verbosity
;
public
Actuary
()
{
try
{
jsap
=
new
SimpleJSAP
(
"actuary"
,
"Reads in LOAN ontologies and performs inferences upon them."
,
new
Parameter
[]
{
//new Switch("displayhelp", 'h', "help", "Display this help message."),
new
FlaggedOption
(
"verbosity"
,
JSAP
.
INTEGER_PARSER
,
"0"
,
true
,
'v'
,
"verbosity"
,
"The higher the verbosity, the more the system will output"
),
new
UnflaggedOption
(
"files"
,
JSAP
.
STRING_PARSER
,
null
,
true
,
true
,
"The files to load."
)
}
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
void
update
(
final
Observable
o
,
final
Object
arg
)
{
Sentence
sent
=
(
Sentence
)
arg
;
System
.
out
.
println
(
parser
.
serialiseSentence
(
sent
,
reasoner
.
getMemory
()));
}
public
void
run
(
final
String
[]
args
)
{
if
(
jsap
==
null
)
return
;
JSAPResult
config
=
jsap
.
parse
(
args
);
if
(!
config
.
success
())
{
System
.
err
.
println
();
System
.
err
.
println
(
"Usage: java "
+
Actuary
.
class
.
getName
());
System
.
err
.
println
(
" "
+
jsap
.
getUsage
());
System
.
err
.
println
();
System
.
err
.
println
(
jsap
.
getHelp
());
System
.
exit
(
1
);
}
// Configure the parameters
verbosity
=
config
.
getInt
(
"verbosity"
);
// Create ourselves a parser and reasoner
parser
=
new
LoanParser
();
reasoner
=
new
Reasoner
(
parser
);
reasoner
.
addObserver
(
this
);
reasoner
.
getParameters
().
SILENT_LEVEL
=
(
verbosity
>=
0
&&
verbosity
<=
100
?
100
-
verbosity
:
100
);
// Get the list of files to load
String
[]
files
=
config
.
getStringArray
(
"files"
);
for
(
int
i
=
0
;
i
<
files
.
length
;
i
++)
{
String
content
=
""
;
// Try treating them as URLs first
try
{
URL
ctx
=
new
File
(
"."
).
toURL
();
URL
u
=
new
URL
(
ctx
,
files
[
i
]);
((
LoanParser
)
parser
).
setBaseURI
(
u
.
toURI
());
BufferedReader
input
=
new
BufferedReader
(
new
InputStreamReader
(
u
.
openStream
()));
StringBuilder
builder
=
new
StringBuilder
();
String
line
;
while
((
line
=
input
.
readLine
())
!=
null
)
builder
.
append
(
line
);
content
=
builder
.
toString
();
}
catch
(
MalformedURLException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
URISyntaxException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
try
{
Iterator
<
Task
>
tasks
=
parser
.
parseTasks
(
content
,
reasoner
.
getMemory
()).
iterator
();
while
(
tasks
.
hasNext
())
{
reasoner
.
tellTask
(
tasks
.
next
());
}
}
catch
(
InvalidInputException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
// Write the header of the file
BaseR
br
=
new
BaseR
(
"<"
+
((
LoanParser
)
parser
).
getBaseURI
().
toString
()
+
">"
);
System
.
out
.
println
(
PrettyPrinter
.
print
(
br
));
Map
<
String
,
URI
>
ns
=
((
LoanParser
)
parser
).
getNamespaces
();
Iterator
<
String
>
iter
=
ns
.
keySet
().
iterator
();
while
(
iter
.
hasNext
())
{
String
pre
=
iter
.
next
();
SentPrefix
n
=
new
SentPrefix
(
new
NSPrefix1
(
pre
),
"<"
+
ns
.
get
(
pre
).
toString
()
+
">"
);
System
.
out
.
println
(
PrettyPrinter
.
print
(
n
));
}
System
.
out
.
println
();
// Start reasoning
reasoner
.
start
();
}
/**
* @param args
*/
public
static
void
main
(
String
[]
args
)
{
Actuary
c
=
new
Actuary
();
c
.
run
(
args
);
}
}
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