diff --git a/TermoPL.jar b/TermoPL.jar index 4b1194a233ae90eb7f7c00fb2370594d8264c84d..e030fd68a651370f1b4fcb5a4eef8385029844ec 100644 Binary files a/TermoPL.jar and b/TermoPL.jar differ diff --git a/packages/TermoPL_Mac_OS_X.zip b/packages/TermoPL_Mac_OS_X.zip old mode 100644 new mode 100755 index bc66450e8a675d9e6df2ffa88f297275cecab44d..5c7667d95fc69b297ba7fddcf8652f2eca80eefa Binary files a/packages/TermoPL_Mac_OS_X.zip and b/packages/TermoPL_Mac_OS_X.zip differ diff --git a/packages/TermoPL_Ubuntu.zip b/packages/TermoPL_Ubuntu.zip old mode 100644 new mode 100755 index f79ee73da63197f26df765e87a46f517bc25e2df..5f854d8f35bf9d3555aa8e5aa1e14713696c6de1 Binary files a/packages/TermoPL_Ubuntu.zip and b/packages/TermoPL_Ubuntu.zip differ diff --git a/packages/TermoPL_Win64.zip b/packages/TermoPL_Win64.zip old mode 100644 new mode 100755 index 6f603212ee33f77825e545d7913251a15ba831ed..a1cf03dae50bab03ece44b8be0df1fc8bf90c250 Binary files a/packages/TermoPL_Win64.zip and b/packages/TermoPL_Win64.zip differ diff --git a/src/About.java b/src/About.java index 10a5d150fd4b40d2191e1a602bf26c0262c75883..c61fe7cb5f50dcb9f5f494ae9389c857555107c3 100644 --- a/src/About.java +++ b/src/About.java @@ -57,7 +57,7 @@ public class About extends JPanel vbox.add(Box.createVerticalStrut(16)); hbox = Box.createHorizontalBox(); hbox.add(Box.createHorizontalGlue()); - label = new JLabel("Version 6.0.0"); + label = new JLabel("Version 6.0.1"); label.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 12)); hbox.add(label); hbox.add(Box.createHorizontalGlue()); diff --git a/src/ExtractorEngine.java b/src/ExtractorEngine.java index 213971e1e449076561047a51cf5e9ec1009476c7..6e08827bc3d470660650ffd682b3010f59c55d0a 100644 --- a/src/ExtractorEngine.java +++ b/src/ExtractorEngine.java @@ -48,7 +48,14 @@ public class ExtractorEngine extends Thread cancelled = false; ntok = nsent = nbigrams = 0; fileID = 0; - termID = 0; + terms = doc.getTerms(); + if (terms != null) { + Term t = terms[terms.length - 1]; + + if (t instanceof TermEx) termID = ((TermEx)t).id; + else termID = 0; + } + else termID = 0; matcher = new TermMatcher(doc.getSearchTemplate(), tagset); if (compPreps != null) compprepMatcher = new TermMatcher(doc.getCompoundPrepositions(), tagset); diff --git a/src/MatchedFragment.java b/src/MatchedFragment.java index 0054c114fea0cb23919a24937197cc63a2c449ab..830d916376dd57c19ea43ca71ece7c8d20de65eb 100644 --- a/src/MatchedFragment.java +++ b/src/MatchedFragment.java @@ -200,6 +200,7 @@ public class MatchedFragment implements MatchedElement, Cloneable public class Handle { + private MatchedFragment fragment; public Handle(MatchedFragment fragment) @@ -217,7 +218,6 @@ public class MatchedFragment implements MatchedElement, Cloneable return fragment; } - } } diff --git a/src/Options.java b/src/Options.java index a8a47638ace3c8e48ae1df9aa0b90e874b9a0a5d..c892201091bf608488e9862657297fdc7083cbf9 100644 --- a/src/Options.java +++ b/src/Options.java @@ -1794,6 +1794,7 @@ public class Options extends JPanel wordNetPath = chooser.getSelectedFile().getAbsolutePath(); wordNetFile.setText(chooser.getSelectedFile().getName()); } + else if (wordNetPath == null) useWordNet.setSelected(false); } } diff --git a/src/Rule.java b/src/Rule.java deleted file mode 100644 index 5bde3b612dbfa004e3a8eb9ec4353a8ca6b57a26..0000000000000000000000000000000000000000 --- a/src/Rule.java +++ /dev/null @@ -1,21 +0,0 @@ -package termopl; - -public class Rule -{ - - public String id; - public QList subst; - - public Rule() - { - id = null; - subst = null; - } - - public Rule(String id) - { - this.id = id; - subst = null; - } - -} diff --git a/src/TermEx.java b/src/TermEx.java index 109358aae3f0be39ccf301c62058d919545dacdb..2263ae3c370810b96ba4d44f42019b273db352c0 100644 --- a/src/TermEx.java +++ b/src/TermEx.java @@ -7,7 +7,7 @@ import java.util.LinkedList; public class TermEx extends Term { - private int id; + public int id; private LinkedList<TermEx> parents; private LinkedList<TermEx> children; private LinkedList<TermEx> equivTerms; @@ -217,6 +217,13 @@ public class TermEx extends Term return relatedTerms; } + public void clean() + { + parents = children = equivTerms = null; + relatedTerms = null; + + } + public static boolean containedInRelated(TermEx term, LinkedList<Pair<TermEx, LinkedList<WordReplacement>>> relatedTerms) { if (relatedTerms == null) return false; diff --git a/src/TermMatcher.java b/src/TermMatcher.java index 950a3186ed3137a666013df51531577da0f0451e..694a741d12f7980075f0587443b08c0fc0bc9ab3 100644 --- a/src/TermMatcher.java +++ b/src/TermMatcher.java @@ -114,6 +114,7 @@ public class TermMatcher System.out.println(); System.out.print("["); printTemplate(t); + System.out.print(" --- " + f.getMatchedFragment().toString()); System.out.print("]"); } System.out.println(); @@ -155,11 +156,6 @@ public class TermMatcher public boolean lookingAt(Chain<TestedFragment> fragments, Chain<Token> tokens, SetOfMarkedTemplates smt) { - /* System.out.println(); - trace1(fragments); - trace2(tokens); - trace3(smt); - System.out.println("MATCHED: " + matched.toString());*/ if (fragments == null) return true; TestedFragment tf = fragments.head(); @@ -185,7 +181,6 @@ public class TermMatcher else if (temp instanceof OrTemplate) { OrTemplate ot = (OrTemplate)temp; LinkedList<LinkedList<MatchedElement>> mfList = null; - for (Template tp : ot.getElements()) { MatchedFragment matched = tf.getMatchedFragment(); MatchedFragment newMF = new MatchedFragment(temp.computeBaseForm || matched.computeBaseForm(), temp); @@ -196,7 +191,7 @@ public class TermMatcher newTF.handle = newMF.getHandle(); matched.add(newMF); if (lookingAt(newFragments, tokens, smt)) { - LinkedList<MatchedElement> lst = this.matched.remove(newMF); + LinkedList<MatchedElement> lst = matched.remove(newMF); if (mfList == null) mfList = new LinkedList<LinkedList<MatchedElement>>(); mfList.add(lst); @@ -219,7 +214,7 @@ public class TermMatcher maxLen = len; } } - this.matched.append(lst); + tf.getMatchedFragment().append(lst); return true; } } @@ -280,7 +275,7 @@ public class TermMatcher newTF.handle = newMF.getHandle(); matched.add(newMF); if (lookingAt(newFragments, tokens, smt)) { - LinkedList<MatchedElement> lst = this.matched.remove(newMF); + LinkedList<MatchedElement> lst = matched.remove(newMF); if (mfList == null) mfList = new LinkedList<LinkedList<MatchedElement>>(); mfList.add(lst); @@ -306,7 +301,7 @@ public class TermMatcher maxLen = len; } } - this.matched.append(lst); + tf.getMatchedFragment().append(lst); return true; } } @@ -369,7 +364,7 @@ public class TermMatcher newTF.handle = newMF.getHandle(); matched.add(newMF); if (lookingAt(newFragments, tokens, new SetOfMarkedTemplates(smt, temp, t))) { - LinkedList<MatchedElement> lst = this.matched.remove(newMF); + LinkedList<MatchedElement> lst = matched.remove(newMF); if (mfList == null) mfList = new LinkedList<LinkedList<MatchedElement>>(); mfList.add(lst); @@ -395,7 +390,7 @@ public class TermMatcher maxLen = len; } } - this.matched.append(lst); + tf.getMatchedFragment().append(lst); return true; } } @@ -463,7 +458,7 @@ public class TermMatcher matched.add(newMF); temp.quantifier = Template.ZERO_OR_MORE; if (lookingAt(newFragments, tokens, smt)) { - LinkedList<MatchedElement> lst = this.matched.remove(newMF); + LinkedList<MatchedElement> lst = matched.remove(newMF); if (mfList == null) mfList = new LinkedList<LinkedList<MatchedElement>>(); mfList.add(lst); @@ -487,7 +482,7 @@ public class TermMatcher maxLen = len; } } - this.matched.append(lst); + tf.getMatchedFragment().append(lst); return true; } } diff --git a/src/TermoPLDocument.java b/src/TermoPLDocument.java index f72d5eb6639bdb1f56b089fdf9129eb8c671a7c7..982243adf32c89e301a144dd3b59ddb88622df73 100644 --- a/src/TermoPLDocument.java +++ b/src/TermoPLDocument.java @@ -964,6 +964,34 @@ public class TermoPLDocument extends Commander if (newFiles != null) for (int i = 0; i < newFiles.length; i++) searchFiles[s++] = newFiles[i]; } + else { + if (preferences.makeGroups) { + if (terms != null) { + for (Term t : terms) { + t.str = calcSimplifiedForm(t); + } + if (terms[0] instanceof TermEx) { + for (Term t : terms) { + ((TermEx)t).clean(); + } + } + else { + for (int i = 0; i < terms.length; i++) { + terms[i] = new TermEx(terms[i].str, terms[i].len, i + 1); + } + } + } + } + else { + if (terms != null) { + if (terms[0] instanceof TermEx) { + for (int i = 0; i < terms.length; i++) { + terms[i] = new TermEx(terms[i].str, terms[i].len, i + 1); + } + } + } + } + } ContrastiveDataLoader loader = null; Finalizer finalizer = new Finalizer(); @@ -1303,25 +1331,31 @@ public class TermoPLDocument extends Commander int i = 0; float progress = 0.0F; - wordNet = WordNet.createWordNet(this, preferences.wordNetPath); - morfeusz = Morph.getAnalyzer(); - wordIndex = new HashMap<String, LinkedList<WordReplacement>>(); - changeProgress(7); - report(progress); - for (Term t : terms) { - if (isCancelled()) break; - analyzeWithWordnet((TermEx) t); - if (++i % 1000 == 0) { - progress = (float)i/(float)terms.length; - report(progress); - System.gc(); + wordNet = WordNet.getWordNet(preferences.wordNetPath); + if (wordNet == null) { + changeProgress(6); + wordNet = WordNet.createWordNet(this, preferences.wordNetPath); + } + if (wordNet != null) { + morfeusz = Morph.getAnalyzer(); + wordIndex = new HashMap<String, LinkedList<WordReplacement>>(); + changeProgress(7); + report(progress); + for (Term t : terms) { + if (isCancelled()) break; + analyzeWithWordnet((TermEx) t); + if (++i % 1000 == 0) { + progress = (float)i/(float)terms.length; + report(progress); + System.gc(); + } } + report(1.0F); + wordNet = null; + morfeusz = null; + wordIndex = null; + System.gc(); } - report(1.0F); - wordNet = null; - morfeusz = null; - wordIndex = null; - System.gc(); } public void analyzeWithWordnet(TermEx term) @@ -3758,7 +3792,7 @@ public class TermoPLDocument extends Commander { ObjectInputStream is; Preferences prefs; - LinkedList<FileDescr> af; + ArrayList<Pair<String, Integer>> af; BaseFormGuesser guesser = null; Term term; int snt = 0, tok = 0, trm = 0; @@ -3780,7 +3814,7 @@ public class TermoPLDocument extends Commander prefs = (Preferences)is.readObject(); is.readObject(); is.readObject(); - af = (LinkedList<FileDescr>)is.readObject(); + af = (ArrayList<Pair<String, Integer>>) is.readObject(); bf = prefs.calculateBaseForms; addForms = preferences.collectAllForms && prefs.collectAllForms; addSentenceRef = preferences.makeIndex && prefs.makeIndex; @@ -3838,7 +3872,8 @@ public class TermoPLDocument extends Commander applyContrastiveRanking(); } prepareTable(); - analyzedFiles.addAll(af); + for (Pair<String, Integer> pair : af) + analyzedFiles.add(new FileDescr(new File(preferences.resolvePath(pair.first)), pair.second)); preferences.makeGroups = false; modified = true; } diff --git a/src/WordNet.java b/src/WordNet.java index a41f9d640b4ee7dd81ba5f4a5b4571a40d03048d..ffa646fa1461279e040f6539fb314c3cec35e572 100644 --- a/src/WordNet.java +++ b/src/WordNet.java @@ -27,7 +27,7 @@ public class WordNet 244 - L - synonimia międzyparadygmatyczna */ - public static WordNet wordNet = null; + public static HashMap<String, WordNet> wordNets = new HashMap<String, WordNet>(); public static final String NOUN = "rzeczownik"; public static final String ADJECTIVE = "przymiotnik"; @@ -39,7 +39,6 @@ public class WordNet public static final int SYNONYMY = 1; public static final int HIPERONYMY = 11; - private TermoPLDocument doc; private File input; private HashMap<String, LinkedList<LexicalUnit>> words; private HashMap<Integer, LexicalUnit> wordIndex; @@ -56,9 +55,8 @@ public class WordNet private boolean unitIDStarted; private boolean ignorePWN; - public WordNet(TermoPLDocument doc, File input, boolean ignorePWN) + public WordNet(File input, boolean ignorePWN) { - this.doc = doc; this.input = input; this.ignorePWN = ignorePWN; currentSynset = null; @@ -70,28 +68,34 @@ public class WordNet synsetRelationTypes.setRelationTypes(10, 11, 108); } - public WordNet(TermoPLDocument doc, File input) + public WordNet(File input) { - this(doc, input, true); + this(input, true); + } + + public static WordNet getWordNet(String wordNetPath) + { + return wordNets.get(wordNetPath); } public static WordNet createWordNet(TermoPLDocument doc, String wordNetPath) { - if (wordNet == null) { - File f = new File(wordNetPath); + synchronized(wordNetPath) { + WordNet wdn = getWordNet(wordNetPath); - if (f.exists()) { - doc.changeProgress(6); - wordNet = new WordNet(doc, f); - wordNet.load(); + if (wdn == null) { + File f = new File(wordNetPath); + + if (f.exists()) { + wdn = new WordNet(f); + wdn.load(doc); + wordNets.put(wordNetPath, wdn); + return wdn; + } + return null; } + return wdn; } - return wordNet; - } - - public static WordNet getWordNet() - { - return wordNet; } public LinkedList<WordReplacement> getRelatedWords(String w, String pos) @@ -196,7 +200,7 @@ public class WordNet } }*/ - public void load() + public void load(TermoPLDocument doc) { XMLInputFactory inputFactory = XMLInputFactory.newInstance();