-
Notifications
You must be signed in to change notification settings - Fork 35
/
MiscUtilities.jsp
158 lines (137 loc) · 5.45 KB
/
MiscUtilities.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<%@ include file="Prelude.jsp" %>
<html>
<head>
<title>Sigma KB Browse - Misc Utilities</title>
</head>
<body BGCOLOR=#FFFFFF>
<%
/** This code is copyright Teknowledge (c) 2003, Articulate Software (c) 2003-2017,
Infosys (c) 2017-present.
This software is released under the GNU Public License
<http://www.gnu.org/copyleft/gpl.html>.
Please cite the following article in any publication with references:
Pease A., and Benzmüller C. (2013). Sigma: An Integrated Development Environment
for Logical Theories. AI Communications 26, pp79-97. See also
http://github.com/ontologyportal
*/
String sigmaHome = System.getenv("SIGMA_HOME");
if (StringUtil.emptyString(sigmaHome))
sigmaHome = "SIGMA_HOME";
String kbDir = KBmanager.getMgr().getPref("kbDir");
String graphDir = KBmanager.getMgr().getPref("graphDir");
File kbDirFile = new File(kbDir);
String namespace = "";
String relation = "";
String ontology = "";
String filename = "";
String action = "";
String status = "";
if (role == null || !role.equalsIgnoreCase("admin")) {
response.sendRedirect("KBs.jsp");
}
else {
namespace = request.getParameter("namespace");
if (namespace == null)
namespace = "";
if (StringUtil.emptyString(kbName) || (KBmanager.getMgr().getKB(kbName) == null)) {
System.out.println(" no such knowledge base " + kbName);
Set<String> names = KBmanager.getMgr().getKBnames();
if (names != null && !names.isEmpty()) {
for (String kbName : names) {
System.out.println("kbName == " + kbName);
}
}
}
ontology = request.getParameter("ontology");
if (StringUtil.emptyString(ontology) || ontology.equalsIgnoreCase("null"))
ontology = "";
relation = request.getParameter("relation");
filename = request.getParameter("filename");
action = request.getParameter("action");
String writeOWL = request.getParameter("writeOWL");
if (StringUtil.emptyString(action) || action.equalsIgnoreCase("null"))
action = "";
if (writeOWL != null)
OMWordnet.generateOMWOWLformat(kb);
if (StringUtil.isNonEmptyString(action)) {
if (kb != null) {
if (action.equals("dotGraph")) {
Graph g = new Graph();
g.createDotGraph(kb, term, relation, 2, 2, 100, filename, "");
}
}
}
}
%>
<form action="MiscUtilities.jsp">
<%
String pageName = "MiscUtilities";
String pageString = "MiscUtilities";
%>
<%@include file="CommonHeader.jsp" %>
<table align="left" width="80%"><tr><td bgcolor="#AAAAAA">
<img src="pixmaps/1pixel.gif" width="1" height="1" border="0"></td></tr></table><br><p>
<%
if (action.equalsIgnoreCase("generateDocs")
|| action.equalsIgnoreCase("generateSingle")) {
if (StringUtil.isNonEmptyString(status)) {
if (!status.trim().startsWith("Error"))
out.println("HTML files have been written to " + status);
else
out.println(status);
out.println("<br><br>");
}
}
%>
<b>Create dotted graph format (for <a href="http://www.graphviz.org">GraphViz</a>)</b><P>
<table>
<tr><td align="right">Term: </td><td><input type="text" name="term" size=20 value=""></td></tr>
<tr><td align="right">Relation: </td><td><input type="text" name="relation" size=20 value=""></td></tr>
<tr><td align="right">Filename: </td><td><input type="text" name="filename" size=20 value="<%=kbName + "-graph.dot"%>">(saved in <%=graphDir%>)</td></tr>
<tr><td align="right"><input type="submit" name="action" value="dotGraph"> </td><td>Generate graph file</td></tr>
</table>
<table align="left" width="80%"><tr><td bgcolor="#AAAAAA">
<img src="pixmaps/1pixel.gif" width="1" height="1" border="0"></td></tr></table><br><p>
Write OMW in OWL: <INPUT type="submit" NAME="writeOWL" VALUE="writeOWL">
</form><p>
<table align="left" width="80%"><tr><td bgcolor="#AAAAAA">
<img src="pixmaps/1pixel.gif" width="1" height="1" border="0"></td></tr></table><br><p>
<b>Generate KIF from a DIF (.dif) or CSV (.csv) file</b>
<p>
<form action="ProcessFile.jsp" id="misc" method="POST" enctype="multipart/form-data">
<table>
<tr>
<td align="right">KB: </td>
<td><input type="text" size="30" name="kb" value=<%=kbName %> ></td>
</tr>
<tr>
<td align="right">Ontology: </td>
<td><input type="text" size="30" name="ontology" value=<%=ontology %> ></td>
</tr>
<tr>
<td align="right">Data file: </td>
<td><input type="file" name="dataFile"></td>
</tr>
<tr>
<td> </td>
<td>
<input type="checkbox" name="load" value="yes"> Load the generated KIF file
</td>
</tr>
<tr>
<td align="right"><input type="submit" name="action" value="kifFromDataFile"> </td>
<td>
<small>
The KIF file will have the same base name as the data
file, but with the extension .kif and maybe with an
infixed integer. It will be saved in the directory
<%=kbDirFile.getCanonicalPath()%>.
</small>
</td>
</tr>
</table>
</form>
<p>
<%@ include file="Postlude.jsp" %>
</body>
</html>