Skip to content

Commit a1f1452

Browse files
author
dlutz2
committed
Removed unneeded bits, some cleanup and formatting
1 parent 2545306 commit a1f1452

File tree

15 files changed

+102
-153
lines changed

15 files changed

+102
-153
lines changed

src/org/opensextant/howler/abstraction/words/enumerated/DataFacet.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.semanticweb.owlapi.model.IRI;
88

99
public enum DataFacet implements Word {
10+
//@formatter:off
1011
LENGTH_FACET("length of", Vocabulary.XSDNamespace, "length"),
1112
MIN_LENGTH_FACET("minimum length of", Vocabulary.XSDNamespace,"minLength"),
1213
MAX_LENGTH_FACET("maximum length of", Vocabulary.XSDNamespace, "maxLength"),
@@ -19,6 +20,7 @@ public enum DataFacet implements Word {
1920
FRACTION_DIGITS_FACET("fractional digits of", Vocabulary.XSDNamespace,"fractionDigits"),
2021
LANG_RANGE_FACET("language range of", Vocabulary.RDFNamespace,"langRange"),
2122
ERROR_FACET("unknown relation to", Vocabulary.BUILTIN_NS, "error");
23+
//@formatter:on
2224

2325
private IRI namespace;
2426
private String logicalform;

src/org/opensextant/howler/abstraction/words/enumerated/PredicateCharacteristic.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
import org.semanticweb.owlapi.model.IRI;
99

1010
public enum PredicateCharacteristic implements Word {
11+
//@formatter:off
1112
FUNCTIONAL("functional"),
1213
SYMMETRIC("symmetric"),
1314
ASYMMETRIC("asymmetric"),
1415
REFLEXIVE("reflexive"),
1516
TRANSITIVE("transitive"),
1617
INVERSE_FUNCTIONAL("inverse functional"),
1718
IRREFLEXIVE("irreflexive");
19+
//@formatter:on
1820

1921
private final String logicalform;
2022
private String normalform;
@@ -84,5 +86,5 @@ public String getPrefix() {
8486
public void setPrefix(String prefix) {
8587
// ignore
8688
}
87-
89+
8890
}

src/org/opensextant/howler/abstraction/words/enumerated/Quantifier.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.semanticweb.owlapi.model.IRI;
88

99
public enum Quantifier implements Word {
10+
//@formatter:off
1011
NULL("", false),
1112
EVERY("every", false),
1213
SOME("some", false),
@@ -18,6 +19,7 @@ public enum Quantifier implements Word {
1819
LESS_THAN("less than",true),
1920
MORE_THAN_OR_EQUAL("at least", true),
2021
LESS_THAN_OR_EQUAL("at most", true);
22+
//@formatter:on
2123

2224
private boolean numeric;
2325
private String normalform;

src/org/opensextant/howler/abstraction/words/enumerated/WordType.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import org.opensextant.howler.utils.TextUtils;
88
import org.semanticweb.owlapi.model.IRI;
99

10-
public enum WordType implements Word {
10+
public enum WordType implements Word {
11+
//@formatter:off
1112
GENERIC_WORD("generic word",false,false),
1213
BADWORD("badword",false,false),
1314
ADJECTIVE("adjective",false,false),
@@ -32,6 +33,7 @@ public enum WordType implements Word {
3233
PREDICATE("predicate",true,false),
3334
SCOPE("scope",false,true),
3435
WORD_TYPE("word type",false,true);
36+
//@formatter:on
3537

3638
private final String logicalform;
3739
private String normalForm;

src/org/opensextant/howler/kanban/Kanban.java

Lines changed: 10 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,7 @@ public class Kanban {
9292

9393
// the primary kanban elements indexed by their IDs
9494
private Map<String, Board> boards = new HashMap<String, Board>();
95-
//private Map<String, CardList> lists = new HashMap<String, CardList>();
96-
//private Map<String, Card> cards = new HashMap<String, Card>();
9795
private Map<String, KanbanSentence> sentences = new HashMap<String, KanbanSentence>();
98-
//private Map<String, RawText> rawTexts = new HashMap<String, RawText>();
9996

10097
// sentences indexed by their content and board to avoid duplicates
10198
private Map<String, KanbanSentence> sentencesByText = new HashMap<String, KanbanSentence>();
@@ -161,9 +158,9 @@ public Kanban(Howler howler, String configPath) {
161158

162159
}
163160

164-
//added a board -> create an ontology
161+
// added a board -> create an ontology
165162
public void addBoard(Board board) {
166-
163+
167164
this.boards.put(board.getId(), board);
168165
LOGGER.info("Added Board:" + board.getTitle());
169166

@@ -190,52 +187,16 @@ public void addBoard(Board board) {
190187
}
191188

192189
}
193-
/*
194-
* private Board getBoard(String id) { return this.boards.get(id); }
195-
*/
196-
190+
197191
public void addList(CardList list) {
198192
// add the list to the board it is part of
199193
this.boards.get(list.getBoardId()).addList(list);
200-
LOGGER.info("Added List:" + list.getTitle() + " to board " + this.boards.get(list.getBoardId()).getTitle() );
201-
}
202-
203-
/*
204-
* private CardList getList(String id) { return this.lists.get(id); }
205-
*/
206-
/*
207-
public void addCard(Card card) {
208-
// this.cards.put(card.get_id(), card);
209-
// add the card to the board it is part of
210-
boards.get(card.getBoardId()).addCard(card);
211-
this.cardsByKey.put(card.getKey(), card);
212-
// add the card to the list it is part of
213-
lists.get(card.getListId()).addCard(card);
214-
LOGGER.info("Added Card:" + card.getTitle());
194+
LOGGER.info("Added List:" + list.getTitle() + " to board " + this.boards.get(list.getBoardId()).getTitle());
215195
}
216-
*/
217-
/*
218-
* private Card getCard(String id) { return this.cards.get(id); } private Card getCardByKey(String key) { return
219-
* this.cardsByKey.get(key); } private KanbanSentence getSentence(String id) { return sentences.get(id); }
220-
*/
221-
/*
222-
private void addSentence(KanbanSentence sentence) {
223-
224-
LOGGER.info("Added Sentence:" + sentence.getText());
225-
// create any cards needed to match words used in sentence
226-
this.addCards(sentence);
227-
// create axiom(s) that corresponds to sentence and add to ontology
228-
this.addAxioms(sentence);
229196

230-
}
231-
*/
232-
233-
/*
234-
* private RawText getRawText(String id) { return rawTexts.get(id); }
235-
*/
236197
public void addRawText(RawText rawText) {
237198

238-
//rawTexts.put(rawText.get_id(), rawText);
199+
// rawTexts.put(rawText.get_id(), rawText);
239200

240201
// rawtext to abstraction Document
241202
Document doc = howler.convertText("dummy", rawText.getText());
@@ -279,7 +240,8 @@ public void addRawText(RawText rawText) {
279240
for (Word w : sent.getWords()) {
280241
WordType wt = w.getWordType();
281242
// dont create cards for generic, quantifiers or WordTypes
282-
if (!wt.equals(WordType.GENERIC_WORD) && !wt.equals(WordType.QUANTIFIER) && !wt.equals(WordType.NEGATIVE) && !wt.equals(WordType.WORD_TYPE)) {
243+
if (!wt.equals(WordType.GENERIC_WORD) && !wt.equals(WordType.QUANTIFIER) && !wt.equals(WordType.NEGATIVE)
244+
&& !wt.equals(WordType.WORD_TYPE)) {
283245
if (w instanceof Predicate) {
284246
Predicate pred = (Predicate) w;
285247
// don't create card for builtin predicates
@@ -296,21 +258,19 @@ public void addRawText(RawText rawText) {
296258
this.addCard(wrd, rawText.getBoardId(), rawText.getSwimlaneId(), rawText.getUserId());
297259
kbSent.addKey(wrd.getKey().toString());
298260
}
299-
261+
300262
// add sentence to index
301263
this.sentences.put(kbSent.get_id(), kbSent);
302-
264+
303265
// add inferences
304266
this.addAxioms(kbSent);
305-
267+
306268
kbSents.add(kbSent);
307269
}
308270

309271
// send the sentences to the Wekan system
310272
this.sendSentences(kbSents, false);
311273

312-
313-
314274
// remove the rawtext
315275
client.collectionDelete("rawtext", rawText.get_id());
316276

@@ -328,11 +288,6 @@ private void addToOntology(Document doc, OWLOntology onto) {
328288

329289
}
330290

331-
/*
332-
private boolean isSynched() {
333-
return synched;
334-
}
335-
*/
336291
private void setSynched(boolean synched) {
337292
this.synched = synched;
338293
if (synched) {
@@ -437,49 +392,6 @@ private void addCard(Word wrd, String boardID, String swimlaneID, String userID)
437392

438393
}
439394

440-
/*
441-
// create any new cards needed to represent words used in the sentence
442-
private void addCards(KanbanSentence sent) {
443-
444-
String userID = sent.getUserId();
445-
String boardID = sent.getBoardId();
446-
447-
for (String key : sent.getKeys()) {
448-
449-
// seen key before?
450-
if (!this.cardsByKey.keySet().contains(key)) {
451-
452-
// keys look like:logicalForm|WordType|boardID
453-
String[] pieces = key.split("\\|");
454-
455-
// title is the words logical form with part of speech following
456-
String title = pieces[0].replaceAll("_", " ") + " (" + pieces[1].toLowerCase() + ")";
457-
458-
// create and populate new card
459-
Card card = new Card();
460-
461-
card.setTitle(title);
462-
card.setKey(key);
463-
card.setEntityType(WordType.valueOf(pieces[1]));
464-
card.setBoardId(boardID);
465-
// TODO list selected is first list in board. Better choice?
466-
card.setListId(boards.get(boardID).getLists().get(0).getId());
467-
card.setUserid(userID);
468-
469-
// create field map and send to Wekan
470-
String json = gson.toJson(card);
471-
Map<String, Object> fields = gson.fromJson(json, Map.class);
472-
473-
int id = client.collectionInsert("cards", fields);
474-
LOGGER.info("Inserting new Card. ID=" + id + ". " + card.getTitle());
475-
476-
this.cardsByKey.put(key, card);
477-
}
478-
479-
}
480-
}
481-
*/
482-
483395
// create a axiom(s) from a sentence and add to appropriate ontology
484396
private void addAxioms(KanbanSentence sent) {
485397

src/org/opensextant/howler/kanban/Syncher.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void update(Observable obs, Object msg) {
100100
KanbanSentence sent = KanbanSentence.fromMap(fields);
101101
sent.set_id(id);
102102
LOGGER.debug("Got a " + msgtype + " message for collection " + collName + ":" + sent);
103-
//kanban.addSentence(sent);
103+
// kanban.addSentence(sent);
104104
return;
105105
}
106106

@@ -127,7 +127,7 @@ public void update(Observable obs, Object msg) {
127127
Card card = Card.fromMap(fields);
128128
card.set_id(id);
129129
LOGGER.debug("Got a " + msgtype + " message for collection " + collName + ":" + card);
130-
//kanban.addCard(card);
130+
// kanban.addCard(card);
131131
return;
132132
}
133133

src/org/opensextant/howler/owl/ToOWL.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,22 +554,22 @@ private List<OWLAxiom> convertObject(FactStatement<ObjectPredicate, ProperNoun>
554554

555555
OWLClassExpression predObjCE = convertObject(predPhrase);
556556

557-
// OWLClassExpression objCE = convertObject(predPhrase.getObject());
557+
// OWLClassExpression objCE = convertObject(predPhrase.getObject());
558558

559559
if (pExp.getPredicate().isBuiltinPredicate()) {
560560

561561
PredicateType predType = pExp.getPredicate().getPredicateType();
562562

563563
if (predType == PredicateType.IS) {
564-
axs.add(owlDataFactory.getOWLClassAssertionAxiom(predObjCE, subject, annos));
564+
axs.add(owlDataFactory.getOWLClassAssertionAxiom(predObjCE, subject, annos));
565565
}
566566

567567
if (predType == PredicateType.SAME_AS) {
568568
OWLObjectOneOf subjOneOf = owlDataFactory.getOWLObjectOneOf(subject);
569569
axs.add(owlDataFactory.getOWLEquivalentClassesAxiom(subjOneOf, predObjCE, annos));
570570
}
571571
} else {// must be VERB type predicate
572-
axs.add(owlDataFactory.getOWLClassAssertionAxiom(predObjCE, subject, annos));
572+
axs.add(owlDataFactory.getOWLClassAssertionAxiom(predObjCE, subject, annos));
573573
}
574574

575575
return axs;

src/org/opensextant/howler/test/OWL2Text.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.commons.io.filefilter.SuffixFileFilter;
3434
import org.opensextant.howler.abstraction.WordManager;
3535
import org.opensextant.howler.owl.FromOWL;
36+
import org.opensextant.howler.text.DocumentFactory.FileStructure;
3637
import org.opensextant.howler.text.TextDocument;
3738
import org.opensextant.howler.text.ToText;
3839

@@ -46,7 +47,16 @@ public static void main(String[] args) throws IOException {
4647

4748
File inputDirsFile = new File(args[0]);
4849
File resultsDir = new File(args[1]);
49-
boolean ignoreBadImports = Boolean.valueOf(args[2]);
50+
51+
FileStructure outFormat = FileStructure.DOCUMENT_PER_LINE;
52+
53+
try {
54+
outFormat = FileStructure.valueOf(args[2]);
55+
} catch (Exception e) {
56+
System.err.println("Bad value for format:" + args[2]);
57+
}
58+
59+
boolean ignoreBadImports = Boolean.valueOf(args[3]);
5060

5161
// the to and from converters
5262
FromOWL fromOWL = new FromOWL(ignoreBadImports);
@@ -91,7 +101,7 @@ public static void main(String[] args) throws IOException {
91101
// create a name from the input ontology file
92102
String ontoNameBase = ontoFile.getName().split("\\.")[0];
93103
File outText = new File(byOntoDir, ontoNameBase + ".txt");
94-
FileUtils.writeStringToFile(outText, backText.toString(), "UTF-8");
104+
FileUtils.writeStringToFile(outText, backText.toString(outFormat,true), "UTF-8");
95105
}
96106
}
97107

src/org/opensextant/howler/test/OWL2Text2OWLTest.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,21 @@ public static void main(String[] args) throws IOException, OWLOntologyCreationEx
139139
for (OWLAxiom originalAx : OWLAPIStreamUtils.asList(originalOnto.axioms())) {
140140
if (!compare(backOnto, originalAx)) {
141141

142+
String axString = originalAx.toString().replaceAll("[\\n\\r\\t]", "<WHITE_SPACE>");
142143
if (nyi(originalAx)) {
143144
axiomErrorsNYI++;
144-
FileUtils.writeStringToFile(results, ontoName + "\t" + "NYI" + "\t" + originalAx.getAxiomType() + "\t"
145-
+ originalAx.toString().replaceAll("[\\n\\r\\t]", "<WHITE_SPACE>") + "\n", "UTF-8", true);
146-
FileUtils.writeStringToFile(totalResults, ontoName + "\t" + "NYI" + "\t" + originalAx.getAxiomType()
147-
+ "\t" + originalAx.toString().replaceAll("[\\n\\r\\t]", " ") + "\n", "UTF-8", true);
145+
FileUtils.writeStringToFile(results,
146+
ontoName + "\t" + "NYI" + "\t" + originalAx.getAxiomType() + "\t" + axString + "\n", "UTF-8", true);
147+
FileUtils.writeStringToFile(totalResults,
148+
ontoName + "\t" + "NYI" + "\t" + originalAx.getAxiomType() + "\t" + axString + "\n", "UTF-8", true);
148149
} else {
149150
axiomErrorsMissing++;
150-
FileUtils.writeStringToFile(results, ontoName + "\t" + "Missing" + "\t" + originalAx.getAxiomType() + "\t"
151-
+ originalAx.toString().replaceAll("[\\n\\r\\t]", "<WHITE_SPACE>") + "\n", "UTF-8", true);
152-
FileUtils.writeStringToFile(totalResults, ontoName + "\t" + "Missing" + "\t" + originalAx.getAxiomType()
153-
+ "\t" + originalAx.toString().replaceAll("[\\n\\r\\t]", "<WHITE_SPACE>") + "\n", "UTF-8", true);
151+
FileUtils.writeStringToFile(results,
152+
ontoName + "\t" + "Missing" + "\t" + originalAx.getAxiomType() + "\t" + axString + "\n", "UTF-8",
153+
true);
154+
FileUtils.writeStringToFile(totalResults,
155+
ontoName + "\t" + "Missing" + "\t" + originalAx.getAxiomType() + "\t" + axString + "\n", "UTF-8",
156+
true);
154157
}
155158
}
156159
}
@@ -160,11 +163,11 @@ public static void main(String[] args) throws IOException, OWLOntologyCreationEx
160163
for (OWLAxiom backAx : OWLAPIStreamUtils.asList(backOnto.axioms())) {
161164
if (!compare(originalOnto, backAx)) {
162165
axiomErrorsExtra++;
163-
164-
FileUtils.writeStringToFile(results, ontoName + "\t" + "Extra" + "\t" + backAx.getAxiomType() + "\t"
165-
+ backAx.toString().replaceAll("[\\n\\r\\t]", "<WHITE_SPACE>") + "\n", "UTF-8", true);
166-
FileUtils.writeStringToFile(totalResults, ontoName + "\t" + "Extra" + "\t" + backAx.getAxiomType() + "\t"
167-
+ backAx.toString().replaceAll("[\\n\\r\\t]", "<WHITE_SPACE>") + "\n", "UTF-8", true);
166+
String axString = backAx.toString().replaceAll("[\\n\\r\\t]", "<WHITE_SPACE>");
167+
FileUtils.writeStringToFile(results,
168+
ontoName + "\t" + "Extra" + "\t" + backAx.getAxiomType() + "\t" + axString + "\n", "UTF-8", true);
169+
FileUtils.writeStringToFile(totalResults,
170+
ontoName + "\t" + "Extra" + "\t" + backAx.getAxiomType() + "\t" + axString + "\n", "UTF-8", true);
168171
}
169172
}
170173

@@ -229,7 +232,7 @@ private static boolean compare(OWLOntology onto, OWLAxiom ax) {
229232
String litString = "";
230233
if (value.isPresent()) {
231234
OWLLiteral lit = value.get();
232-
litString = lit.getLiteral();
235+
litString = lit.getLiteral().replaceAll("\n", " ");;
233236
} else {
234237
return false;
235238
}
@@ -241,7 +244,7 @@ private static boolean compare(OWLOntology onto, OWLAxiom ax) {
241244
for (OWLAnnotationAssertionAxiom annoAx : annos) {
242245
if (annoAx.literalValue().isPresent()) {
243246
OWLLiteral axLit = annoAx.literalValue().get();
244-
String axLitString = axLit.getLiteral();
247+
String axLitString = axLit.getLiteral().replaceAll("\n", " ");
245248
if (axLitString.equals(litString)) {
246249
return true;
247250
}

0 commit comments

Comments
 (0)