Skip to content

Assignment 2 UML Diagrams #1

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions OmegaT/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
Expand Down
1,097 changes: 1,097 additions & 0 deletions OmegaT/Assignment_2_1.cld

Large diffs are not rendered by default.

2,864 changes: 2,864 additions & 0 deletions OmegaT/Assignment_2_2.cld

Large diffs are not rendered by default.

2,631 changes: 2,631 additions & 0 deletions OmegaT/Assignment_2_3.cld

Large diffs are not rendered by default.

949 changes: 949 additions & 0 deletions OmegaT/Assignment_3.cld

Large diffs are not rendered by default.

Binary file added OmegaT/Assignment_5_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OmegaT/Assignment_5_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OmegaT/Assignment_5_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file added OmegaT/Assignment_5_4.mnj
Empty file.
672 changes: 672 additions & 0 deletions OmegaT/Assignment_6_1.sqd

Large diffs are not rendered by default.

1,152 changes: 1,152 additions & 0 deletions OmegaT/Assignment_6_2.sqd

Large diffs are not rendered by default.

548 changes: 548 additions & 0 deletions OmegaT/Assignment_6_3.sqd

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions OmegaT/maintainj/META-INF/aop.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<aspectj>
<aspects>
<concrete-aspect name="com.maintainj.inst.J2SEAspect" extends="com.maintainj.aspect.J2SEExecutionAspect">
<pointcut name="anyExecution" expression="execution( * *.*(..)) || execution( *.new(..))"/>
<pointcut name="beforeMain" expression="execution(public static void org.omegat.Main.main(String[])) || execution(public static void org.omegat.Main.main(String...))"/>
</concrete-aspect>
</aspects>
<weaver options="-proceedOnError -nowarn -XaddSerialVersionUID -Xset:makeTjpFieldsTransient=true -Xset:avoidFinal=true">
<include within="gen..*"/>
<include within="org.omegat.convert..*"/>
<include within="org.omegat.core..*"/>
<include within="org.omegat.filters2..*"/>
<include within="org.omegat.filters3..*"/>
<include within="org.omegat.gui..*"/>
<include within="org.omegat.Main"/>
<exclude within="*ObjectFactory"/>
<exclude within="*..*CGLIB*"/>
<exclude within="com.maintainj..*"/>
</weaver>
</aspectj>
15 changes: 0 additions & 15 deletions OmegaT/src/gen/core/tbx/P.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,6 @@

package gen.core.tbx;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlMixed;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;


/**
* <p>Java class for anonymous complex type.
Expand Down
13 changes: 0 additions & 13 deletions OmegaT/src/gen/core/tbx/RevisionDesc.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@

package gen.core.tbx;

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlID;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;


/**
* <p>Java class for anonymous complex type.
Expand Down
88 changes: 87 additions & 1 deletion OmegaT/src/org/omegat/core/dictionaries/DictionariesManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@
*/
public class DictionariesManager implements DirectoryMonitor.Callback {
protected DirectoryMonitor monitor;
protected final Map<String, DictionaryInfo> infos = new TreeMap<String, DictionaryInfo>();
protected final Map<String, DictionaryInfo> infos = new TreeMap<String, DictionaryInfo>();
private final DictionariesTextArea pane;
protected static String DICTIONARY_SUBDIR = "dictionary";

// Alternative storage of dictionary entries for purposes of prefix search
protected final Trie trieInfos = new Trie();

protected final Set<String> ignoreWords = new TreeSet<String>();

public DictionariesManager(final DictionariesTextArea pane) {
Expand Down Expand Up @@ -200,10 +203,20 @@ public List<DictionaryEntry> findWords(Set<String> words) {
for (Object d : (Object[]) data) {
String a = di.dict.readArticle(word, d);
result.add(new DictionaryEntry(word, a));
/*
* When word are aggregated from all dictionaries, build
* trie tree representation
*/
trieInfos.insert(word);
}
} else {
String a = di.dict.readArticle(word, data);
result.add(new DictionaryEntry(word, a));
/*
* Same purpose as above, for words that do not have multiple
* meanings
*/
trieInfos.insert(word);
}
}
} catch (Exception ex) {
Expand All @@ -223,4 +236,77 @@ public DictionaryInfo(final IDictionary dict, final Map<String, Object> info) {
this.info = info;
}
}

/*
* Search all dictionaries for suitable candidates with specified prefix
* Essentially slightly modified version of findWords method, except now instead of
* aggregating all words across all dictionaries, we search across all dictionaries
* for a single word
*
* @param prefix Candidate prefix
* @return List of all known words containing prefix
*/

public List<DictionaryEntry> findPrefixesHash(String prefix) {
List<DictionaryInfo> dicts;
synchronized (this) {
dicts = new ArrayList<DictionaryInfo>(infos.values());
}
List<DictionaryEntry> result = new ArrayList<DictionaryEntry>();
for (DictionaryInfo di : dicts) {
try {
synchronized (ignoreWords) {
if (ignoreWords.contains(prefix)) {
continue;
}
}
Object data = di.info.get(prefix);
if (data == null) {
String lowerCaseWord = prefix.toLowerCase();
synchronized (ignoreWords) {
if (ignoreWords.contains(lowerCaseWord)) {
continue;
}
}
data = di.info.get(lowerCaseWord);
}
if (data != null) {
if (data.getClass().isArray()) {
for (Object d : (Object[]) data) {
String a = di.dict.readArticle(prefix, d);
result.add(new DictionaryEntry(prefix, a));
}
} else {
String a = di.dict.readArticle(prefix, data);
result.add(new DictionaryEntry(prefix, a));
}
}
} catch (Exception ex) {
Log.log(ex);
}
}
return result;
}

/*
* Same as above method, but using trie tree instead of hash table dictionary
* representation
*
* @param prefix Candidate prefix
* @return List of all known words containing prefix
*/
public List<String> findPrefixesTrie(String prefix) {
List<String> result = new ArrayList<String>();
if(trieInfos.startsWith(prefix) == false)
return null;
boolean flag = true;
while(flag == true) {
if(trieInfos.searchNode(prefix) == null)
flag = false;
trieInfos.searchNode(prefix);
if(trieInfos.search(prefix) == true)
result.add(prefix);
}
return result;
}
}
76 changes: 76 additions & 0 deletions OmegaT/src/org/omegat/core/dictionaries/Trie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.omegat.core.dictionaries;

import java.util.HashMap;
import java.util.Map;

/*
* Class for Trie tree
* Java does not contain a Trie tree implementation in its libraries so this particular
* model was taken from: http://www.programcreek.com/2014/05/leetcode-implement-trie-prefix-tree-java/
*/

public class Trie {
private TrieNode root;

public Trie() {
root = new TrieNode();
}

// Inserts a word into the trie.
public void insert(String word) {
HashMap<Character, TrieNode> children = root.children;

for(int i=0; i<word.length(); i++){
char c = word.charAt(i);

TrieNode t;
if(children.containsKey(c)){
t = children.get(c);
}else{
t = new TrieNode(c);
children.put(c, t);
}

children = t.children;

//set leaf node
if(i==word.length()-1)
t.isLeaf = true;
}
}

// Returns if the word is in the trie.
public boolean search(String word) {
TrieNode t = searchNode(word);

if(t != null && t.isLeaf)
return true;
else
return false;
}

// Returns if there is any word in the trie
// that starts with the given prefix.
public boolean startsWith(String prefix) {
if(searchNode(prefix) == null)
return false;
else
return true;
}

public TrieNode searchNode(String str){
Map<Character, TrieNode> children = root.children;
TrieNode t = null;
for(int i=0; i<str.length(); i++){
char c = str.charAt(i);
if(children.containsKey(c)){
t = children.get(c);
children = t.children;
}else{
return null;
}
}

return t;
}
}
20 changes: 20 additions & 0 deletions OmegaT/src/org/omegat/core/dictionaries/TrieNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.omegat.core.dictionaries;

import java.util.HashMap;

/*
* Support class for Trie tree
* Also taken from: http://www.programcreek.com/2014/05/leetcode-implement-trie-prefix-tree-java/
*/

class TrieNode {
char c;
HashMap<Character, TrieNode> children = new HashMap<Character, TrieNode>();
boolean isLeaf;

public TrieNode() {}

public TrieNode(char c){
this.c = c;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@

package org.omegat.filters2.text.bundles;

import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.util.Map;
import java.util.TreeMap;
import javax.swing.AbstractAction;


import org.omegat.util.OStrings;
import org.omegat.util.gui.DockingUI;
import org.omegat.util.gui.StaticUIUtils;
Expand Down
7 changes: 0 additions & 7 deletions OmegaT/src/org/omegat/gui/filters2/InstanceEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@

package org.omegat.gui.filters2;

import java.awt.Dialog;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.border.TitledBorder;

import org.omegat.filters2.AbstractFilter;
import org.omegat.filters2.master.FilterMaster;
import org.omegat.util.OStrings;
Expand Down