target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void copyOfValuesTest() { IntValueMap<String> set = new IntValueMap<>(); for (int i = 0; i < 1000; i++) { set.put(String.valueOf(i), i + 1); } int[] values = set.copyOfValues(); Assert.assertEquals(1000, values.length); Arrays.sort(values); for (int i = 0; i < 1000; i++) { Assert.assertEquals(i + 1, values...
public int[] copyOfValues() { int[] result = new int[keyCount]; int k = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[k] = values[i]; k++; } } return result; }
IntValueMap extends HashBase<T> implements Iterable<T> { public int[] copyOfValues() { int[] result = new int[keyCount]; int k = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[k] = values[i]; k++; } } return result; } }
IntValueMap extends HashBase<T> implements Iterable<T> { public int[] copyOfValues() { int[] result = new int[keyCount]; int k = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[k] = values[i]; k++; } } return result; } IntValueMap(); IntValueMap(int size); }
IntValueMap extends HashBase<T> implements Iterable<T> { public int[] copyOfValues() { int[] result = new int[keyCount]; int k = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[k] = values[i]; k++; } } return result; } IntValueMap(); IntValueMap(int size); int addOrIncrement(T key); void addOrI...
IntValueMap extends HashBase<T> implements Iterable<T> { public int[] copyOfValues() { int[] result = new int[keyCount]; int k = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[k] = values[i]; k++; } } return result; } IntValueMap(); IntValueMap(int size); int addOrIncrement(T key); void addOrI...
@Test @Ignore("Not a unit test") public void perfStrings() { for (int i = 0; i < 5; i++) { Set<String> strings = uniqueStrings(1000000, 7); Stopwatch sw = Stopwatch.createStarted(); Set<String> newSet = new HashSet<>(strings); System.out.println("Java Set : " + sw.elapsed(TimeUnit.MILLISECONDS)); System.out.println("Si...
public void addOrIncrementAll(Iterable<T> keys) { for (T t : keys) { incrementByAmount(t, 1); } }
IntValueMap extends HashBase<T> implements Iterable<T> { public void addOrIncrementAll(Iterable<T> keys) { for (T t : keys) { incrementByAmount(t, 1); } } }
IntValueMap extends HashBase<T> implements Iterable<T> { public void addOrIncrementAll(Iterable<T> keys) { for (T t : keys) { incrementByAmount(t, 1); } } IntValueMap(); IntValueMap(int size); }
IntValueMap extends HashBase<T> implements Iterable<T> { public void addOrIncrementAll(Iterable<T> keys) { for (T t : keys) { incrementByAmount(t, 1); } } IntValueMap(); IntValueMap(int size); int addOrIncrement(T key); void addOrIncrementAll(Iterable<T> keys); int get(T key); int decrement(T key); int incrementByAmou...
IntValueMap extends HashBase<T> implements Iterable<T> { public void addOrIncrementAll(Iterable<T> keys) { for (T t : keys) { incrementByAmount(t, 1); } } IntValueMap(); IntValueMap(int size); int addOrIncrement(T key); void addOrIncrementAll(Iterable<T> keys); int get(T key); int decrement(T key); int incrementByAmou...
@Test(expected = IllegalArgumentException.class) public void safeGet() { FixedBitVector vector = new FixedBitVector(10); vector.safeGet(10); }
public boolean safeGet(int n) { check(n); return (words[n >> 5] & setMasks[n & 31]) != 0; }
FixedBitVector { public boolean safeGet(int n) { check(n); return (words[n >> 5] & setMasks[n & 31]) != 0; } }
FixedBitVector { public boolean safeGet(int n) { check(n); return (words[n >> 5] & setMasks[n & 31]) != 0; } FixedBitVector(int length); }
FixedBitVector { public boolean safeGet(int n) { check(n); return (words[n >> 5] & setMasks[n & 31]) != 0; } FixedBitVector(int length); boolean get(int n); boolean safeGet(int n); void set(int n); void safeSet(int n); void clear(int n); void safeClear(int n); int numberOfOnes(); int numberOfNewOneBitCount(FixedBitVect...
FixedBitVector { public boolean safeGet(int n) { check(n); return (words[n >> 5] & setMasks[n & 31]) != 0; } FixedBitVector(int length); boolean get(int n); boolean safeGet(int n); void set(int n); void safeSet(int n); void clear(int n); void safeClear(int n); int numberOfOnes(); int numberOfNewOneBitCount(FixedBitVect...
@Test(expected = IllegalArgumentException.class) public void safeSet() { FixedBitVector vector = new FixedBitVector(10); vector.safeSet(10); }
public void safeSet(int n) { check(n); words[n >> 5] |= setMasks[n & 31]; }
FixedBitVector { public void safeSet(int n) { check(n); words[n >> 5] |= setMasks[n & 31]; } }
FixedBitVector { public void safeSet(int n) { check(n); words[n >> 5] |= setMasks[n & 31]; } FixedBitVector(int length); }
FixedBitVector { public void safeSet(int n) { check(n); words[n >> 5] |= setMasks[n & 31]; } FixedBitVector(int length); boolean get(int n); boolean safeGet(int n); void set(int n); void safeSet(int n); void clear(int n); void safeClear(int n); int numberOfOnes(); int numberOfNewOneBitCount(FixedBitVector other); int d...
FixedBitVector { public void safeSet(int n) { check(n); words[n >> 5] |= setMasks[n & 31]; } FixedBitVector(int length); boolean get(int n); boolean safeGet(int n); void set(int n); void safeSet(int n); void clear(int n); void safeClear(int n); int numberOfOnes(); int numberOfNewOneBitCount(FixedBitVector other); int d...
@Test public void nounVoicingTest() { String[] voicing = {"kabak", "kabak [A:Voicing]", "psikolog", "havuç", "turp [A:Voicing]", "galip", "nohut", "cenk", "kükürt"}; for (String s : voicing) { DictionaryItem item = TurkishDictionaryLoader.loadFromString(s); Assert.assertEquals(Noun, item.primaryPos); Assert.assertTrue(...
public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
@Test(expected = IllegalArgumentException.class) public void safeClear() { FixedBitVector vector = new FixedBitVector(10); vector.safeClear(10); }
public void safeClear(int n) { check(n); words[n >> 5] &= resetMasks[n & 31]; }
FixedBitVector { public void safeClear(int n) { check(n); words[n >> 5] &= resetMasks[n & 31]; } }
FixedBitVector { public void safeClear(int n) { check(n); words[n >> 5] &= resetMasks[n & 31]; } FixedBitVector(int length); }
FixedBitVector { public void safeClear(int n) { check(n); words[n >> 5] &= resetMasks[n & 31]; } FixedBitVector(int length); boolean get(int n); boolean safeGet(int n); void set(int n); void safeSet(int n); void clear(int n); void safeClear(int n); int numberOfOnes(); int numberOfNewOneBitCount(FixedBitVector other); i...
FixedBitVector { public void safeClear(int n) { check(n); words[n >> 5] &= resetMasks[n & 31]; } FixedBitVector(int length); boolean get(int n); boolean safeGet(int n); void set(int n); void safeSet(int n); void clear(int n); void safeClear(int n); int numberOfOnes(); int numberOfNewOneBitCount(FixedBitVector other); i...
@Test public void testValues() { FloatValueMap<String> set = new FloatValueMap<>(); set.set("a", 7); set.set("b", 2); set.set("c", 3); set.set("d", 4); set.set("d", 5); Assert.assertEquals(4, set.size()); float[] values = set.values(); Arrays.sort(values); Assert.assertTrue(Arrays.equals(new float[]{2f, 3f, 5f, 7f}, va...
public float[] values() { float[] result = new float[size()]; int j = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[j++] = values[i]; } } return result; }
FloatValueMap extends HashBase<T> implements Iterable<T> { public float[] values() { float[] result = new float[size()]; int j = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[j++] = values[i]; } } return result; } }
FloatValueMap extends HashBase<T> implements Iterable<T> { public float[] values() { float[] result = new float[size()]; int j = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[j++] = values[i]; } } return result; } FloatValueMap(); FloatValueMap(int size); private FloatValueMap(FloatValueMap<...
FloatValueMap extends HashBase<T> implements Iterable<T> { public float[] values() { float[] result = new float[size()]; int j = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[j++] = values[i]; } } return result; } FloatValueMap(); FloatValueMap(int size); private FloatValueMap(FloatValueMap<...
FloatValueMap extends HashBase<T> implements Iterable<T> { public float[] values() { float[] result = new float[size()]; int j = 0; for (int i = 0; i < keys.length; i++) { if (hasValidKey(i)) { result[j++] = values[i]; } } return result; } FloatValueMap(); FloatValueMap(int size); private FloatValueMap(FloatValueMap<...
@Test public void addTest() { Foo f1 = new Foo("abc", 1); Foo f2 = new Foo("abc", 2); LookupSet<Foo> fooSet = new LookupSet<>(); Assert.assertTrue(fooSet.add(f1)); Assert.assertFalse(fooSet.add(f2)); }
public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCount++; return true; } }
LookupSet extends HashBase<T> implements Iterable<T> { public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCoun...
LookupSet extends HashBase<T> implements Iterable<T> { public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCoun...
LookupSet extends HashBase<T> implements Iterable<T> { public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCoun...
LookupSet extends HashBase<T> implements Iterable<T> { public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCoun...
@Test public void lookupTest() { Foo f1 = new Foo("abc", 1); Foo f2 = new Foo("abc", 2); LookupSet<Foo> fooSet = new LookupSet<>(); Assert.assertNull(fooSet.lookup(f1)); Assert.assertNull(fooSet.lookup(f2)); fooSet.add(f1); Assert.assertEquals(1, fooSet.lookup(f1).b); Assert.assertEquals(1, fooSet.lookup(f2).b); fooSet...
public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCount++; return true; } }
LookupSet extends HashBase<T> implements Iterable<T> { public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCoun...
LookupSet extends HashBase<T> implements Iterable<T> { public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCoun...
LookupSet extends HashBase<T> implements Iterable<T> { public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCoun...
LookupSet extends HashBase<T> implements Iterable<T> { public boolean add(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return false; } else { loc = -loc - 1; keys[loc] = key; keyCoun...
@Test public void getOrAddTest() { Foo f1 = new Foo("abc", 1); Foo f2 = new Foo("abc", 2); LookupSet<Foo> fooSet = new LookupSet<>(); Assert.assertEquals(1, fooSet.getOrAdd(f1).b); Assert.assertEquals(1, fooSet.getOrAdd(f2).b); }
public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyCount++; return key; } }
LookupSet extends HashBase<T> implements Iterable<T> { public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyC...
LookupSet extends HashBase<T> implements Iterable<T> { public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyC...
LookupSet extends HashBase<T> implements Iterable<T> { public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyC...
LookupSet extends HashBase<T> implements Iterable<T> { public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyC...
@Test public void removeTest() { Foo f1 = new Foo("abc", 1); Foo f2 = new Foo("abc", 2); LookupSet<Foo> fooSet = new LookupSet<>(); Assert.assertEquals(1, fooSet.getOrAdd(f1).b); Assert.assertEquals(1, fooSet.getOrAdd(f2).b); Assert.assertEquals(1, fooSet.remove(f2).b); Assert.assertEquals(2, fooSet.getOrAdd(f2).b); }
public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyCount++; return key; } }
LookupSet extends HashBase<T> implements Iterable<T> { public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyC...
LookupSet extends HashBase<T> implements Iterable<T> { public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyC...
LookupSet extends HashBase<T> implements Iterable<T> { public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyC...
LookupSet extends HashBase<T> implements Iterable<T> { public T getOrAdd(T key) { if (key == null) { throw new IllegalArgumentException("Key cannot be null."); } if (keyCount + removeCount == threshold) { expand(); } int loc = locate(key); if (loc >= 0) { return keys[loc]; } else { loc = -loc - 1; keys[loc] = key; keyC...
@Test public void removeSpansWorksCorrectly2() { IntFloatMap im = createMap(); int limit = 9999; insertSpan(im, 0, limit); int[] r = TestUtils.createRandomUintArray(1000, limit); for (int i : r) { im.remove(i); } for (int i : r) { assertEqualsF(im.get(i), IntIntMap.NO_RESULT); } insertSpan(im, 0, limit); checkSpan(im, ...
public float get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return Float.intBitsToFloat((int) (entry >>> 32)); } if (t == EMPTY) { return NO_RESULT; } slot = probe(slot); } }
IntFloatMap extends CompactIntMapBase { public float get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return Float.intBitsToFloat((int) (entry >>> 32)); } if (t == EMPTY) { return NO_RESULT; } slot = pr...
IntFloatMap extends CompactIntMapBase { public float get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return Float.intBitsToFloat((int) (entry >>> 32)); } if (t == EMPTY) { return NO_RESULT; } slot = pr...
IntFloatMap extends CompactIntMapBase { public float get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return Float.intBitsToFloat((int) (entry >>> 32)); } if (t == EMPTY) { return NO_RESULT; } slot = pr...
IntFloatMap extends CompactIntMapBase { public float get(int key) { checkKey(key); int slot = firstProbe(key); while (true) { final long entry = entries[slot]; final int t = (int) (entry & 0xFFFF_FFFFL); if (t == key) { return Float.intBitsToFloat((int) (entry >>> 32)); } if (t == EMPTY) { return NO_RESULT; } slot = pr...
@Test public void removeTest2() { IntFloatMap map = createMap(); for (int i = 0; i < 10000; i++) { map.put(i, i + 1); } for (int i = 0; i < 10000; i += 3) { map.remove(i); } for (int i = 0; i < 10000; i += 3) { Assert.assertTrue(!map.containsKey(i)); } for (int i = 0; i < 10000; i++) { map.put(i, i + 1); } for (int i =...
public void put(int key, float value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } }
IntFloatMap extends CompactIntMapBase { public void put(int key, float value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } } }
IntFloatMap extends CompactIntMapBase { public void put(int key, float value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } } IntFloatMap(); IntFloatMap(int capacity); }
IntFloatMap extends CompactIntMapBase { public void put(int key, float value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } } IntFloatMap(); IntFloatMap(int capacity); void put(int key, float value); void inc...
IntFloatMap extends CompactIntMapBase { public void put(int key, float value) { checkKey(key); expandIfNecessary(); int loc = locate(key); if (loc >= 0) { setValue(loc, value); } else { setKeyValue(-loc - 1, key, value); keyCount++; } } IntFloatMap(); IntFloatMap(int capacity); void put(int key, float value); void inc...
@Test public void getAllTest() { List<Item> items = createitems("elma", "el", "arm", "armut", "a", "elmas"); additems(items); List<Item> all = lt.getAll(); Assert.assertEquals(6, all.size()); }
public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size() > 0) {...
Trie { public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size()...
Trie { public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size()...
Trie { public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size()...
Trie { public List<T> getAll() { List<T> items = new ArrayList<>(size); List<Node<T>> toWalk = Lists.newArrayList(root); while (toWalk.size() > 0) { List<Node<T>> n = new ArrayList<>(); for (Node<T> tNode : toWalk) { if (tNode.hasItem()) { items.addAll(tNode.items); } if (tNode.children != null && tNode.children.size()...
@Test public void removeStems() { List<Item> items = createitems("el", "elmas", "elma", "ela"); additems(items); checkitemsExist(items); checkitemsMatches("el", createitems("el")); checkitemsMatches("el", createitems()); lt.remove(items.get(1).surfaceForm, items.get(1)); checkitemsMatches("elmas", createitems()); check...
public void remove(String s, T item) { Node node = walkToNode(s); if (node != null && node.hasItem()) { node.items.remove(item); size--; } }
Trie { public void remove(String s, T item) { Node node = walkToNode(s); if (node != null && node.hasItem()) { node.items.remove(item); size--; } } }
Trie { public void remove(String s, T item) { Node node = walkToNode(s); if (node != null && node.hasItem()) { node.items.remove(item); size--; } } }
Trie { public void remove(String s, T item) { Node node = walkToNode(s); if (node != null && node.hasItem()) { node.items.remove(item); size--; } } void add(String s, T item); void remove(String s, T item); int size(); boolean containsItem(String s, T item); List<T> getItems(String s); List<T> getAll(); List<T> getPre...
Trie { public void remove(String s, T item) { Node node = walkToNode(s); if (node != null && node.hasItem()) { node.items.remove(item); size--; } } void add(String s, T item); void remove(String s, T item); int size(); boolean containsItem(String s, T item); List<T> getItems(String s); List<T> getAll(); List<T> getPre...
@Test public void referenceTest1() { String[] ref = {"ad", "ad [A:Doubling,InverseHarmony]", "soy", "soyadı [A:CompoundP3sg; Roots:soy-ad]"}; RootLexicon lexicon = TurkishDictionaryLoader.load(ref); DictionaryItem item = lexicon.getItemById("soyadı_Noun"); Assert.assertNotNull(item); Assert.assertFalse(item.attributes....
public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
@Test public void formatNumbersTest() throws IOException { TurkishMorphology morphology = TurkishMorphology.builder() .disableCache() .setLexicon("bir [P:Num]", "dört [P:Num;A:Voicing]", "üç [P:Num]", "beş [P:Num]") .build(); TurkishSpellChecker spellChecker = new TurkishSpellChecker(morphology); String[] inputs = { "1...
public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { co...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
@Test public void isVowelTest() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String vowels = "aeiuüıoöâîû"; for (char c : vowels.toCharArray()) { Assert.assertTrue(alphabet.isVowel(c)); } String nonvowels = "bcçdfgğjklmnprştvxwzq."; for (char c : nonvowels.toCharArray()) { Assert.assertFalse(alphabet.isVowel(...
public boolean isVowel(char c) { return lookup(vowelLookup, c); }
TurkishAlphabet { public boolean isVowel(char c) { return lookup(vowelLookup, c); } }
TurkishAlphabet { public boolean isVowel(char c) { return lookup(vowelLookup, c); } private TurkishAlphabet(); }
TurkishAlphabet { public boolean isVowel(char c) { return lookup(vowelLookup, c); } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap getTurkishToAsciiMap(); char getAsciiEqual(char c); boolean isAsciiEqual(char c1, cha...
TurkishAlphabet { public boolean isVowel(char c) { return lookup(vowelLookup, c); } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap getTurkishToAsciiMap(); char getAsciiEqual(char c); boolean isAsciiEqual(char c1, cha...
@Test public void vowelCountTest() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String[] entries = {"a", "aa", "", "bb", "bebaba"}; int[] expCounts = {1, 2, 0, 0, 3}; int i = 0; for (String entry : entries) { Assert.assertEquals(expCounts[i++], alphabet.vowelCount(entry)); } }
public int vowelCount(String s) { int result = 0; for (int i = 0; i < s.length(); i++) { if (isVowel(s.charAt(i))) { result++; } } return result; }
TurkishAlphabet { public int vowelCount(String s) { int result = 0; for (int i = 0; i < s.length(); i++) { if (isVowel(s.charAt(i))) { result++; } } return result; } }
TurkishAlphabet { public int vowelCount(String s) { int result = 0; for (int i = 0; i < s.length(); i++) { if (isVowel(s.charAt(i))) { result++; } } return result; } private TurkishAlphabet(); }
TurkishAlphabet { public int vowelCount(String s) { int result = 0; for (int i = 0; i < s.length(); i++) { if (isVowel(s.charAt(i))) { result++; } } return result; } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap get...
TurkishAlphabet { public int vowelCount(String s) { int result = 0; for (int i = 0; i < s.length(); i++) { if (isVowel(s.charAt(i))) { result++; } } return result; } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap get...
@Test public void voiceTest() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String iStr = "çÇgGkKpPtTaAbB"; String oStr = "cCğĞğĞbBdDaAbB"; for (int i = 0; i < iStr.length(); i++) { char in = iStr.charAt(i); char outExpected = oStr.charAt(i); Assert.assertEquals("", String.valueOf(outExpected), String.valueOf(...
public char voice(char c) { int res = voicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; }
TurkishAlphabet { public char voice(char c) { int res = voicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } }
TurkishAlphabet { public char voice(char c) { int res = voicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); }
TurkishAlphabet { public char voice(char c) { int res = voicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap getTurkishToAsciiMap(); char getAsciiEqu...
TurkishAlphabet { public char voice(char c) { int res = voicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap getTurkishToAsciiMap(); char getAsciiEqu...
@Test public void devoiceTest() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String iStr = "bBcCdDgGğĞaAkK"; String oStr = "pPçÇtTkKkKaAkK"; for (int i = 0; i < iStr.length(); i++) { char in = iStr.charAt(i); char outExpected = oStr.charAt(i); Assert.assertEquals("", String.valueOf(outExpected), String.valueO...
public char devoice(char c) { int res = devoicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; }
TurkishAlphabet { public char devoice(char c) { int res = devoicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } }
TurkishAlphabet { public char devoice(char c) { int res = devoicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); }
TurkishAlphabet { public char devoice(char c) { int res = devoicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap getTurkishToAsciiMap(); char getAsci...
TurkishAlphabet { public char devoice(char c) { int res = devoicingMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap getTurkishToAsciiMap(); char getAsci...
@Test public void circumflexTest() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String iStr = "abcâîûÂÎÛ fg12"; String oStr = "abcaiuAİU fg12"; Assert.assertEquals(oStr, alphabet.normalizeCircumflex(iStr)); }
public char normalizeCircumflex(char c) { int res = circumflexMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; }
TurkishAlphabet { public char normalizeCircumflex(char c) { int res = circumflexMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } }
TurkishAlphabet { public char normalizeCircumflex(char c) { int res = circumflexMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); }
TurkishAlphabet { public char normalizeCircumflex(char c) { int res = circumflexMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap getTurkishToAsciiMap();...
TurkishAlphabet { public char normalizeCircumflex(char c) { int res = circumflexMap.get(c); return res == IntIntMap.NO_RESULT ? c : (char) res; } private TurkishAlphabet(); String toAscii(String in); String foreignDiacriticsToTurkish(String in); boolean containsAsciiRelated(String s); IntIntMap getTurkishToAsciiMap();...
@Test public void toAsciiTest() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String iStr = "abcçğıiİIoöüşâîûÂÎÛz"; String oStr = "abccgiiIIoousaiuAIUz"; Assert.assertEquals(oStr, alphabet.toAscii(iStr)); }
public String toAscii(String in) { StringBuilder sb = new StringBuilder(in.length()); for (int i = 0; i < in.length(); i++) { char c = in.charAt(i); int res = turkishToAsciiMap.get(c); char map = res == IntIntMap.NO_RESULT ? c : (char) res; sb.append(map); } return sb.toString(); }
TurkishAlphabet { public String toAscii(String in) { StringBuilder sb = new StringBuilder(in.length()); for (int i = 0; i < in.length(); i++) { char c = in.charAt(i); int res = turkishToAsciiMap.get(c); char map = res == IntIntMap.NO_RESULT ? c : (char) res; sb.append(map); } return sb.toString(); } }
TurkishAlphabet { public String toAscii(String in) { StringBuilder sb = new StringBuilder(in.length()); for (int i = 0; i < in.length(); i++) { char c = in.charAt(i); int res = turkishToAsciiMap.get(c); char map = res == IntIntMap.NO_RESULT ? c : (char) res; sb.append(map); } return sb.toString(); } private TurkishAlp...
TurkishAlphabet { public String toAscii(String in) { StringBuilder sb = new StringBuilder(in.length()); for (int i = 0; i < in.length(); i++) { char c = in.charAt(i); int res = turkishToAsciiMap.get(c); char map = res == IntIntMap.NO_RESULT ? c : (char) res; sb.append(map); } return sb.toString(); } private TurkishAlp...
TurkishAlphabet { public String toAscii(String in) { StringBuilder sb = new StringBuilder(in.length()); for (int i = 0; i < in.length(); i++) { char c = in.charAt(i); int res = turkishToAsciiMap.get(c); char map = res == IntIntMap.NO_RESULT ? c : (char) res; sb.append(map); } return sb.toString(); } private TurkishAlp...
@Test public void equalsIgnoreDiacritics() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String[] a = {"siraci", "ağac", "ağaç"}; String[] b = {"şıracı", "ağaç", "agac"}; for (int i = 0; i < a.length; i++) { Assert.assertTrue(alphabet.equalsIgnoreDiacritics(a[i], b[i])); } }
public boolean equalsIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() != s2.length()) { return false; } for (int i = 0; i < s1.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } return true; }
TurkishAlphabet { public boolean equalsIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() != s2.length()) { return false; } for (int i = 0; i < s1.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } return ...
TurkishAlphabet { public boolean equalsIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() != s2.length()) { return false; } for (int i = 0; i < s1.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } return ...
TurkishAlphabet { public boolean equalsIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() != s2.length()) { return false; } for (int i = 0; i < s1.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } return ...
TurkishAlphabet { public boolean equalsIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() != s2.length()) { return false; } for (int i = 0; i < s1.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } return ...
@Test public void vowelHarmonyA() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String[] a = {"elma", "kedi", "turp"}; String[] b= {"lar", "cik", "un"}; for (int i = 0; i < a.length; i++) { Assert.assertTrue(alphabet.checkVowelHarmonyA(a[i], b[i])); } }
public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); }
TurkishAlphabet { public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); } }
TurkishAlphabet { public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); }
TurkishAlphabet { public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); String toAscii(String in)...
TurkishAlphabet { public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); String toAscii(String in)...
@Test public void vowelHarmonyA2() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String[] a = {"elma", "kedi", "turp"}; String[] b = {"ler", "cık", "in"}; for (int i = 0; i < a.length; i++) { Assert.assertFalse(alphabet.checkVowelHarmonyA(a[i], b[i])); } }
public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); }
TurkishAlphabet { public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); } }
TurkishAlphabet { public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); }
TurkishAlphabet { public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); String toAscii(String in)...
TurkishAlphabet { public boolean checkVowelHarmonyA(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyA(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); String toAscii(String in)...
@Test public void vowelHarmonyI1() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String[] a = {"elma", "kedi", "turp"}; String[] b = {"yı", "yi", "u"}; for (int i = 0; i < a.length; i++) { Assert.assertTrue(alphabet.checkVowelHarmonyI(a[i], b[i])); } }
public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); }
TurkishAlphabet { public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); } }
TurkishAlphabet { public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); }
TurkishAlphabet { public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); String toAscii(String in)...
TurkishAlphabet { public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); String toAscii(String in)...
@Test public void referenceTest2() { String[] ref = {"ad", "ad [A:Doubling,InverseHarmony;Index:1]", "soy", "soyadı [A:CompoundP3sg; Roots:soy-ad]"}; RootLexicon lexicon = TurkishDictionaryLoader.load(ref); DictionaryItem item = lexicon.getItemById("soyadı_Noun"); Assert.assertNotNull(item); Assert.assertFalse(item.att...
public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
@Test public void vowelHarmonyI2() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String[] a = {"elma", "kedi", "turp"}; String[] b = {"yu", "yü", "ı"}; for (int i = 0; i < a.length; i++) { Assert.assertFalse(alphabet.checkVowelHarmonyI(a[i], b[i])); } }
public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); }
TurkishAlphabet { public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); } }
TurkishAlphabet { public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); }
TurkishAlphabet { public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); String toAscii(String in)...
TurkishAlphabet { public boolean checkVowelHarmonyI(CharSequence source, CharSequence target) { TurkicLetter sourceLastVowel = getLastVowel(source); TurkicLetter targetFirstVowel = getLastVowel(target); return checkVowelHarmonyI(sourceLastVowel, targetFirstVowel); } private TurkishAlphabet(); String toAscii(String in)...
@Test public void startsWithDiacriticsIgnoredTest() { TurkishAlphabet alphabet = TurkishAlphabet.INSTANCE; String[] a = {"siraci", "çağlayan"}; String[] b = {"şıracı", "cag"}; for (int i = 0; i < a.length; i++) { Assert.assertTrue(alphabet.startsWithIgnoreDiacritics(a[i], b[i])); } }
public boolean startsWithIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() < s2.length()) { return false; } for (int i = 0; i < s2.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } return true; }
TurkishAlphabet { public boolean startsWithIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() < s2.length()) { return false; } for (int i = 0; i < s2.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } retu...
TurkishAlphabet { public boolean startsWithIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() < s2.length()) { return false; } for (int i = 0; i < s2.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } retu...
TurkishAlphabet { public boolean startsWithIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() < s2.length()) { return false; } for (int i = 0; i < s2.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } retu...
TurkishAlphabet { public boolean startsWithIgnoreDiacritics(String s1, String s2) { if (s1 == null || s2 == null) { return false; } if (s1.length() < s2.length()) { return false; } for (int i = 0; i < s2.length(); i++) { char c1 = s1.charAt(i); char c2 = s2.charAt(i); if (!isAsciiEqual(c1, c2)) { return false; } } retu...
@Test public void specialWordsTest() throws IOException { LmVocabulary vocabulary = new LmVocabulary("<S>", "Hello", "</S>"); vocabulary.containsAll("<S>", "Hello", "</S>", "<unk>"); }
public boolean containsAll(int... indexes) { for (int index : indexes) { if (!contains(index)) { return false; } } return true; }
LmVocabulary { public boolean containsAll(int... indexes) { for (int index : indexes) { if (!contains(index)) { return false; } } return true; } }
LmVocabulary { public boolean containsAll(int... indexes) { for (int index : indexes) { if (!contains(index)) { return false; } } return true; } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); }
LmVocabulary { public boolean containsAll(int... indexes) { for (int index : indexes) { if (!contains(index)) { return false; } } return true; } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmV...
LmVocabulary { public boolean containsAll(int... indexes) { for (int index : indexes) { if (!contains(index)) { return false; } } return true; } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmV...
@Test public void binaryFileGenerationTest() throws IOException { File tmp = getBinaryVocFile(); LmVocabulary vocabulary = LmVocabulary.loadFromBinary(tmp); simpleCheck(vocabulary); }
public static LmVocabulary loadFromBinary(File binaryVocabularyFile) throws IOException { try (DataInputStream dis = new DataInputStream( new BufferedInputStream(new FileInputStream(binaryVocabularyFile)))) { return new LmVocabulary(dis); } }
LmVocabulary { public static LmVocabulary loadFromBinary(File binaryVocabularyFile) throws IOException { try (DataInputStream dis = new DataInputStream( new BufferedInputStream(new FileInputStream(binaryVocabularyFile)))) { return new LmVocabulary(dis); } } }
LmVocabulary { public static LmVocabulary loadFromBinary(File binaryVocabularyFile) throws IOException { try (DataInputStream dis = new DataInputStream( new BufferedInputStream(new FileInputStream(binaryVocabularyFile)))) { return new LmVocabulary(dis); } } LmVocabulary(String... vocabulary); LmVocabulary(List<String>...
LmVocabulary { public static LmVocabulary loadFromBinary(File binaryVocabularyFile) throws IOException { try (DataInputStream dis = new DataInputStream( new BufferedInputStream(new FileInputStream(binaryVocabularyFile)))) { return new LmVocabulary(dis); } } LmVocabulary(String... vocabulary); LmVocabulary(List<String>...
LmVocabulary { public static LmVocabulary loadFromBinary(File binaryVocabularyFile) throws IOException { try (DataInputStream dis = new DataInputStream( new BufferedInputStream(new FileInputStream(binaryVocabularyFile)))) { return new LmVocabulary(dis); } } LmVocabulary(String... vocabulary); LmVocabulary(List<String>...
@Test public void utf8FileGenerationTest() throws IOException { File tmp = getUtf8VocFile(); LmVocabulary vocabulary = LmVocabulary.loadFromUtf8File(tmp); simpleCheck(vocabulary); }
public static LmVocabulary loadFromUtf8File(File utfVocabularyFile) throws IOException { return new LmVocabulary(SimpleTextReader.trimmingUTF8Reader(utfVocabularyFile).asStringList()); }
LmVocabulary { public static LmVocabulary loadFromUtf8File(File utfVocabularyFile) throws IOException { return new LmVocabulary(SimpleTextReader.trimmingUTF8Reader(utfVocabularyFile).asStringList()); } }
LmVocabulary { public static LmVocabulary loadFromUtf8File(File utfVocabularyFile) throws IOException { return new LmVocabulary(SimpleTextReader.trimmingUTF8Reader(utfVocabularyFile).asStringList()); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf...
LmVocabulary { public static LmVocabulary loadFromUtf8File(File utfVocabularyFile) throws IOException { return new LmVocabulary(SimpleTextReader.trimmingUTF8Reader(utfVocabularyFile).asStringList()); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf...
LmVocabulary { public static LmVocabulary loadFromUtf8File(File utfVocabularyFile) throws IOException { return new LmVocabulary(SimpleTextReader.trimmingUTF8Reader(utfVocabularyFile).asStringList()); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf...
@Test public void streamGenerationTest() throws IOException { File tmp = getBinaryVocFile(); try (DataInputStream dis = new DataInputStream(new FileInputStream(tmp))) { LmVocabulary vocabulary = LmVocabulary.loadFromDataInputStream(dis); simpleCheck(vocabulary); } }
public static LmVocabulary loadFromDataInputStream(DataInputStream dis) throws IOException { return new LmVocabulary(dis); }
LmVocabulary { public static LmVocabulary loadFromDataInputStream(DataInputStream dis) throws IOException { return new LmVocabulary(dis); } }
LmVocabulary { public static LmVocabulary loadFromDataInputStream(DataInputStream dis) throws IOException { return new LmVocabulary(dis); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); }
LmVocabulary { public static LmVocabulary loadFromDataInputStream(DataInputStream dis) throws IOException { return new LmVocabulary(dis); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmVocabu...
LmVocabulary { public static LmVocabulary loadFromDataInputStream(DataInputStream dis) throws IOException { return new LmVocabulary(dis); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmVocabu...
@Test public void randomAccessGenerationTest() throws IOException { File tmp = getBinaryVocFile(); try (RandomAccessFile raf = new RandomAccessFile(tmp, "r")) { LmVocabulary vocabulary = LmVocabulary.loadFromRandomAccessFile(raf); simpleCheck(vocabulary); } }
public static LmVocabulary loadFromRandomAccessFile(RandomAccessFile raf) throws IOException { return new LmVocabulary(raf); }
LmVocabulary { public static LmVocabulary loadFromRandomAccessFile(RandomAccessFile raf) throws IOException { return new LmVocabulary(raf); } }
LmVocabulary { public static LmVocabulary loadFromRandomAccessFile(RandomAccessFile raf) throws IOException { return new LmVocabulary(raf); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); }
LmVocabulary { public static LmVocabulary loadFromRandomAccessFile(RandomAccessFile raf) throws IOException { return new LmVocabulary(raf); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmVoca...
LmVocabulary { public static LmVocabulary loadFromRandomAccessFile(RandomAccessFile raf) throws IOException { return new LmVocabulary(raf); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmVoca...
@Test public void contains() throws IOException { LmVocabulary vocabulary = new LmVocabulary("Hello", "World"); int helloIndex = vocabulary.indexOf("Hello"); int worldIndex = vocabulary.indexOf("World"); Assert.assertTrue(vocabulary.contains(helloIndex)); Assert.assertTrue(vocabulary.contains(worldIndex)); int unkIndex...
public boolean contains(int index) { return index >= 0 && index < vocabulary.size(); }
LmVocabulary { public boolean contains(int index) { return index >= 0 && index < vocabulary.size(); } }
LmVocabulary { public boolean contains(int index) { return index >= 0 && index < vocabulary.size(); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); }
LmVocabulary { public boolean contains(int index) { return index >= 0 && index < vocabulary.size(); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmVocabulary loadFromBinary(File binaryVocabul...
LmVocabulary { public boolean contains(int index) { return index >= 0 && index < vocabulary.size(); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmVocabulary loadFromBinary(File binaryVocabul...
@Test public void encodedTrigramTest() throws IOException { LmVocabulary vocabulary = new LmVocabulary("a", "b", "c", "d", "e"); long k = ((1L << 21 | 2L) << 21) | 3L; Assert.assertEquals(k, vocabulary.encodeTrigram(3, 2, 1)); Assert.assertEquals(k, vocabulary.encodeTrigram(3, 2, 1)); }
public long encodeTrigram(int g0, int g1, int g2) { long encoded = g2; encoded = (encoded << 21) | g1; return (encoded << 21) | g0; }
LmVocabulary { public long encodeTrigram(int g0, int g1, int g2) { long encoded = g2; encoded = (encoded << 21) | g1; return (encoded << 21) | g0; } }
LmVocabulary { public long encodeTrigram(int g0, int g1, int g2) { long encoded = g2; encoded = (encoded << 21) | g1; return (encoded << 21) | g0; } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); }
LmVocabulary { public long encodeTrigram(int g0, int g1, int g2) { long encoded = g2; encoded = (encoded << 21) | g1; return (encoded << 21) | g0; } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static...
LmVocabulary { public long encodeTrigram(int g0, int g1, int g2) { long encoded = g2; encoded = (encoded << 21) | g1; return (encoded << 21) | g0; } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static...
@Test public void toWordsTest() throws IOException { LmVocabulary vocabulary = new LmVocabulary("a", "b", "c", "d", "e"); int[] indexes = vocabulary.toIndexes("a", "e", "b"); Assert.assertEquals("a e b", Joiner.on(" ").join(vocabulary.toWords(indexes))); indexes = vocabulary.toIndexes("a", "e", "foo"); Assert.assertEqu...
public String[] toWords(int... indexes) { String[] words = new String[indexes.length]; int k = 0; for (int index : indexes) { if (contains(index)) { words[k++] = vocabulary.get(index); } else { Log.warn("Out of bounds word index is used:" + index); words[k++] = unknownWord; } } return words; }
LmVocabulary { public String[] toWords(int... indexes) { String[] words = new String[indexes.length]; int k = 0; for (int index : indexes) { if (contains(index)) { words[k++] = vocabulary.get(index); } else { Log.warn("Out of bounds word index is used:" + index); words[k++] = unknownWord; } } return words; } }
LmVocabulary { public String[] toWords(int... indexes) { String[] words = new String[indexes.length]; int k = 0; for (int index : indexes) { if (contains(index)) { words[k++] = vocabulary.get(index); } else { Log.warn("Out of bounds word index is used:" + index); words[k++] = unknownWord; } } return words; } LmVocabula...
LmVocabulary { public String[] toWords(int... indexes) { String[] words = new String[indexes.length]; int k = 0; for (int index : indexes) { if (contains(index)) { words[k++] = vocabulary.get(index); } else { Log.warn("Out of bounds word index is used:" + index); words[k++] = unknownWord; } } return words; } LmVocabula...
LmVocabulary { public String[] toWords(int... indexes) { String[] words = new String[indexes.length]; int k = 0; for (int index : indexes) { if (contains(index)) { words[k++] = vocabulary.get(index); } else { Log.warn("Out of bounds word index is used:" + index); words[k++] = unknownWord; } } return words; } LmVocabula...
@Test public void pronunciation1() { String[] ref = { "VST [P:Noun, Abbrv; Pr:viesti]", "VST [P:Noun, Abbrv; Pr:vesete; Ref:VST_Noun_Abbrv; Index:2]"}; RootLexicon lexicon = TurkishDictionaryLoader.load(ref); DictionaryItem item = lexicon.getItemById("VST_Noun_Abbrv"); Assert.assertNotNull(item); DictionaryItem item2 =...
public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
@Test public void builderTest() throws IOException { LmVocabulary.Builder builder = LmVocabulary.builder(); String[] words = {"elma", "çilek", "karpuz", "armut", "elma", "armut"}; for (String word : words) { builder.add(word); } Assert.assertEquals(4, builder.size()); Assert.assertEquals(0, builder.indexOf("elma")); As...
public static Builder builder() { return new Builder(); }
LmVocabulary { public static Builder builder() { return new Builder(); } }
LmVocabulary { public static Builder builder() { return new Builder(); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); }
LmVocabulary { public static Builder builder() { return new Builder(); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmVocabulary loadFromBinary(File binaryVocabularyFile); static LmVocabulary...
LmVocabulary { public static Builder builder() { return new Builder(); } LmVocabulary(String... vocabulary); LmVocabulary(List<String> vocabulary); private LmVocabulary(RandomAccessFile raf); private LmVocabulary(DataInputStream dis); static LmVocabulary loadFromBinary(File binaryVocabularyFile); static LmVocabulary...
@Test public void testGeneration() throws IOException { SmoothLm lm = getTinyLm(); Assert.assertEquals(3, lm.getOrder()); }
@Override public int getOrder() { return order; }
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { @Override public int getOrder() { return order; } }
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { @Override public int getOrder() { return order; } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean useStupidBackoff, float stupidBackoffAlpha, File...
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { @Override public int getOrder() { return order; } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean useStupidBackoff, float stupidBackoffAlpha, File...
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { @Override public int getOrder() { return order; } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean useStupidBackoff, float stupidBackoffAlpha, File...
@Test public void testVocabulary() throws IOException { SmoothLm lm = getTinyLm(); LmVocabulary vocab = lm.getVocabulary(); Assert.assertTrue(vocab.contains("Ahmet")); int i1 = vocab.indexOf("Ahmet"); Assert.assertTrue(vocab.contains("elma")); int i2 = vocab.indexOf("elma"); Assert.assertTrue(i1 != i2); Assert.assertEq...
@Override public LmVocabulary getVocabulary() { return vocabulary; }
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { @Override public LmVocabulary getVocabulary() { return vocabulary; } }
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { @Override public LmVocabulary getVocabulary() { return vocabulary; } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean useStupidBackoff, float stupidBacko...
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { @Override public LmVocabulary getVocabulary() { return vocabulary; } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean useStupidBackoff, float stupidBacko...
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { @Override public LmVocabulary getVocabulary() { return vocabulary; } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean useStupidBackoff, float stupidBacko...
@Test public void testExplain() throws IOException { SmoothLm lm = getTinyLm(); LmVocabulary vocabulary = lm.getVocabulary(); int[] is = {vocabulary.indexOf("<s>")}; System.out.println(lm.explain(is)); int[] is2 = vocabulary.toIndexes("<s>", "kedi"); System.out.println(lm.explain(is2)); int[] is3 = vocabulary.toIndexes...
public String explain(int... wordIndexes) { return explain(new Explanation(), wordIndexes).sb.toString(); }
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { public String explain(int... wordIndexes) { return explain(new Explanation(), wordIndexes).sb.toString(); } }
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { public String explain(int... wordIndexes) { return explain(new Explanation(), wordIndexes).sb.toString(); } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean us...
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { public String explain(int... wordIndexes) { return explain(new Explanation(), wordIndexes).sb.toString(); } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean us...
SmoothLm extends BaseLanguageModel implements NgramLanguageModel { public String explain(int... wordIndexes) { return explain(new Explanation(), wordIndexes).sb.toString(); } private SmoothLm( DataInputStream dis, float logBase, float unigramWeight, float unknownBackoffPenalty, boolean us...
@Test public void testOpenNlpStyle() throws IOException { Path p = TestUtil.tempFileWithData( "<Start:ABC> Foo Bar <End> ivir zivir <Start:DEF> haha <End> . "); NerDataSet set = NerDataSet.load(p, AnnotationStyle.OPEN_NLP); System.out.println("types= " + set.types); Assert.assertTrue(TestUtil.containsAll(set.types, "AB...
public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with style %s", path...
NerDataSet { public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with st...
NerDataSet { public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with st...
NerDataSet { public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with st...
NerDataSet { public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with st...
@Test public void testBracketStyle() throws IOException { Path p = TestUtil.tempFileWithData( "[ABC Foo Bar] ivir zivir [DEF haha] . "); NerDataSet set = NerDataSet.load(p, AnnotationStyle.BRACKET); System.out.println("types= " + set.types); Assert.assertTrue(TestUtil.containsAll(set.types, "ABC", "DEF", "OUT")); }
public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with style %s", path...
NerDataSet { public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with st...
NerDataSet { public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with st...
NerDataSet { public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with st...
NerDataSet { public static NerDataSet load(Path path, AnnotationStyle style) throws IOException { switch (style) { case BRACKET: return loadBracketStyle(path); case ENAMEX: return loadEnamexStyle(path); case OPEN_NLP: return loadOpenNlpStyle(path); } throw new IOException(String.format("Cannot load data from %s with st...
@Test public void testInstances() { TurkishTokenizer t = TurkishTokenizer.DEFAULT; matchToken(t, "a b \t c \n \r", "a", "b", "c"); t = TurkishTokenizer.ALL; matchToken(t, " a b\t\n\rc", " ", "a", " ", "b", "\t", "\n", "\r", "c"); t = TurkishTokenizer.builder().ignoreAll().acceptTypes(Type.Number).build(); matchToken(t,...
public static Builder builder() { return new Builder(); }
TurkishTokenizer { public static Builder builder() { return new Builder(); } }
TurkishTokenizer { public static Builder builder() { return new Builder(); } private TurkishTokenizer(long acceptedTypeBits); }
TurkishTokenizer { public static Builder builder() { return new Builder(); } private TurkishTokenizer(long acceptedTypeBits); static Builder builder(); boolean isTypeAccepted(Token.Type i); boolean isTypeIgnored(Token.Type i); List<Token> tokenize(File file); List<Token> tokenize(String input); List<Token> tokenize(Re...
TurkishTokenizer { public static Builder builder() { return new Builder(); } private TurkishTokenizer(long acceptedTypeBits); static Builder builder(); boolean isTypeAccepted(Token.Type i); boolean isTypeIgnored(Token.Type i); List<Token> tokenize(File file); List<Token> tokenize(String input); List<Token> tokenize(Re...
@Test public void testTokenBoundaries() { TurkishTokenizer t = TurkishTokenizer.ALL; List<Token> tokens = t.tokenize("bir av. geldi."); Token t0 = tokens.get(0); Assert.assertEquals("bir", t0.getText()); Assert.assertEquals(0, t0.getStart()); Assert.assertEquals(2, t0.getEnd()); Token t1 = tokens.get(1); Assert.assertE...
public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); }
TurkishTokenizer { public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); } }
TurkishTokenizer { public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); } private TurkishTokenizer(long acceptedTypeBits); }
TurkishTokenizer { public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); } private TurkishTokenizer(long acceptedTypeBits); static Builder builder(); boolean isTypeAccepted(Token.Type i); boolean isTypeIgnored(Token.Type i); List<Token> tok...
TurkishTokenizer { public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); } private TurkishTokenizer(long acceptedTypeBits); static Builder builder(); boolean isTypeAccepted(Token.Type i); boolean isTypeIgnored(Token.Type i); List<Token> tok...
@Test @Ignore("Not an actual test. Requires external data.") public void performance() throws IOException { TurkishTokenizer tokenizer = TurkishTokenizer.DEFAULT; for (int it = 0; it < 5; it++) { List<String> lines = Files.readAllLines( Paths.get("/media/aaa/Data/aaa/corpora/dunya.100k")); Stopwatch clock = Stopwatch.c...
public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); }
TurkishTokenizer { public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); } }
TurkishTokenizer { public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); } private TurkishTokenizer(long acceptedTypeBits); }
TurkishTokenizer { public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); } private TurkishTokenizer(long acceptedTypeBits); static Builder builder(); boolean isTypeAccepted(Token.Type i); boolean isTypeIgnored(Token.Type i); List<Token> tok...
TurkishTokenizer { public List<Token> tokenize(File file) throws IOException { return getAllTokens(lexerInstance(CharStreams.fromPath(file.toPath()))); } private TurkishTokenizer(long acceptedTypeBits); static Builder builder(); boolean isTypeAccepted(Token.Type i); boolean isTypeIgnored(Token.Type i); List<Token> tok...
@Test public void substringTest() { Assert.assertEquals("", new Span(0, 0).getSubstring("hello")); Assert.assertEquals("h", new Span(0, 1).getSubstring("hello")); Assert.assertEquals("ello", new Span(1, 5).getSubstring("hello")); }
public String getSubstring(String input) { return input.substring(start, end); }
Span { public String getSubstring(String input) { return input.substring(start, end); } }
Span { public String getSubstring(String input) { return input.substring(start, end); } Span(int start, int end); }
Span { public String getSubstring(String input) { return input.substring(start, end); } Span(int start, int end); int length(); int middleValue(); Span copy(int offset); String getSubstring(String input); boolean inSpan(int i); }
Span { public String getSubstring(String input) { return input.substring(start, end); } Span(int start, int end); int length(); int middleValue(); Span copy(int offset); String getSubstring(String input); boolean inSpan(int i); final int start; final int end; }
@Test public void implicitP3sgTest() { String[] lines = { "üzeri [A:CompoundP3sg;Roots:üzer]"}; RootLexicon lexicon = TurkishDictionaryLoader.load(lines); Assert.assertEquals(2, lexicon.size()); }
public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
@Test public void lengthTest() { Assert.assertEquals(0, new Span(0, 0).length()); Assert.assertEquals(1, new Span(0, 1).length()); Assert.assertEquals(4, new Span(1, 5).length()); }
public int length() { return end - start; }
Span { public int length() { return end - start; } }
Span { public int length() { return end - start; } Span(int start, int end); }
Span { public int length() { return end - start; } Span(int start, int end); int length(); int middleValue(); Span copy(int offset); String getSubstring(String input); boolean inSpan(int i); }
Span { public int length() { return end - start; } Span(int start, int end); int length(); int middleValue(); Span copy(int offset); String getSubstring(String input); boolean inSpan(int i); final int start; final int end; }
@Test public void singletonAccessShouldNotThrowException() throws IOException { TurkishSentenceExtractor.DEFAULT.fromParagraph("hello"); }
public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) { sentences.add(sentence); } } return sentences; }
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
@Test public void shouldExtractSentences1() throws IOException { String test = "Merhaba Dünya.| Nasılsın?"; List<String> expected = getSentences(test); Assert.assertEquals(expected, TurkishSentenceExtractor.DEFAULT.fromParagraph(test.replace("|", ""))); }
public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) { sentences.add(sentence); } } return sentences; }
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
@Test public void shouldExtractSingleSentences() throws IOException { String test = "Merhaba Dünya."; List<String> expected = getSentences(test); Assert.assertEquals(expected, TurkishSentenceExtractor.DEFAULT.fromParagraph(test.replace("|", ""))); }
public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) { sentences.add(sentence); } } return sentences; }
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
@Test public void shouldExtractSentencesSecondDoesNotEndWithDot() throws IOException { String test = "Merhaba Dünya.| Nasılsın"; List<String> expected = getSentences(test); Assert.assertEquals(expected, TurkishSentenceExtractor.DEFAULT.fromParagraph(test.replace("|", ""))); }
public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) { sentences.add(sentence); } } return sentences; }
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
@Test public void shouldReturnDotForDot() throws IOException { List<String> expected = getSentences("."); Assert.assertEquals(expected, TurkishSentenceExtractor.DEFAULT.fromParagraph(".")); }
public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) { sentences.add(sentence); } } return sentences; }
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
@Test public void shouldReturn0ForEmpty() throws IOException { Assert.assertEquals(0, TurkishSentenceExtractor.DEFAULT.fromParagraph("").size()); }
public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) { sentences.add(sentence); } } return sentences; }
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
@Test public void shouldReturn0ForEmptyff() { List<String> sentences = TurkishSentenceExtractor.DEFAULT.fromParagraph(""); Assert.assertEquals(0, sentences.size()); }
public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) { sentences.add(sentence); } } return sentences; }
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
TurkishSentenceExtractor extends PerceptronSegmenter { public List<String> fromParagraph(String paragraph) { List<Span> spans = extractToSpans(paragraph); List<String> sentences = new ArrayList<>(spans.size()); for (Span span : spans) { String sentence = span.getSubstring(paragraph).trim(); if (sentence.length() > 0) {...
@Test public void testDoubleQuotes() throws IOException { TurkishSentenceExtractor e = TurkishSentenceExtractor .builder() .doNotSplitInDoubleQuotes() .useDefaultModel().build(); Assert.assertEquals( "\"Merhaba! Bugün hava çok güzel. Ne dersin?\" dedi tavşan.|Havucu kemirirken.", markBoundariesParagraph( e, "\"Merhaba!...
public static Builder builder() { return new Builder(); }
TurkishSentenceExtractor extends PerceptronSegmenter { public static Builder builder() { return new Builder(); } }
TurkishSentenceExtractor extends PerceptronSegmenter { public static Builder builder() { return new Builder(); } private TurkishSentenceExtractor(FloatValueMap<String> weights); private TurkishSentenceExtractor(FloatValueMap<String> weights, boolean doNotSplitInDoubleQuotes); }
TurkishSentenceExtractor extends PerceptronSegmenter { public static Builder builder() { return new Builder(); } private TurkishSentenceExtractor(FloatValueMap<String> weights); private TurkishSentenceExtractor(FloatValueMap<String> weights, boolean doNotSplitInDoubleQuotes); static Builder builder(); List<Stri...
TurkishSentenceExtractor extends PerceptronSegmenter { public static Builder builder() { return new Builder(); } private TurkishSentenceExtractor(FloatValueMap<String> weights); private TurkishSentenceExtractor(FloatValueMap<String> weights, boolean doNotSplitInDoubleQuotes); static Builder builder(); List<Stri...
@Test public void nounAttributesTest() { List<ItemAttrPair> testList = Lists.newArrayList( testPair("takat [A:NoVoicing, InverseHarmony]", NoVoicing, InverseHarmony), testPair("nakit [A: LastVowelDrop]", Voicing, LastVowelDrop), testPair("ret [A:Voicing, Doubling]", Voicing, Doubling) ); for (ItemAttrPair pair : testLi...
public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } }
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
TurkishDictionaryLoader { public static DictionaryItem loadFromString(String dictionaryLine) { String lemma = dictionaryLine; if (dictionaryLine.contains(" ")) { lemma = dictionaryLine.substring(0, dictionaryLine.indexOf(" ")); } return load(dictionaryLine).getMatchingItems(lemma).get(0); } static RootLexicon loadDefa...
@Test @Ignore("Not a unit test") public void shouldPrintItemsInDevlDictionary() throws IOException { RootLexicon items = TurkishDictionaryLoader .load(new File(Resources.getResource("dev-lexicon.txt").getFile())); for (DictionaryItem item : items) { System.out.println(item); } }
public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } }
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
TurkishDictionaryLoader { public static RootLexicon load(File input) throws IOException { return Files.asCharSource(input, Charsets.UTF_8).readLines(new TextLexiconProcessor()); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromRes...
@Test @Ignore("Not a unit test") public void saveFullAttributes() throws IOException { RootLexicon items = TurkishDictionaryLoader.loadDefaultDictionaries(); PrintWriter p = new PrintWriter(new File("dictionary-all-attributes.txt"), "utf-8"); for (DictionaryItem item : items) { p.println(item.toString()); } }
public static RootLexicon loadDefaultDictionaries() throws IOException { return loadFromResources(DEFAULT_DICTIONARY_RESOURCES); }
TurkishDictionaryLoader { public static RootLexicon loadDefaultDictionaries() throws IOException { return loadFromResources(DEFAULT_DICTIONARY_RESOURCES); } }
TurkishDictionaryLoader { public static RootLexicon loadDefaultDictionaries() throws IOException { return loadFromResources(DEFAULT_DICTIONARY_RESOURCES); } }
TurkishDictionaryLoader { public static RootLexicon loadDefaultDictionaries() throws IOException { return loadFromResources(DEFAULT_DICTIONARY_RESOURCES); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromResources(Collection<Strin...
TurkishDictionaryLoader { public static RootLexicon loadDefaultDictionaries() throws IOException { return loadFromResources(DEFAULT_DICTIONARY_RESOURCES); } static RootLexicon loadDefaultDictionaries(); static RootLexicon loadFromResources(String... resourcePaths); static RootLexicon loadFromResources(Collection<Strin...
@Test public void cardinalTest() { Assert.assertEquals("sıfır", TurkishNumbers.convertToString(0)); Assert.assertEquals("bin", TurkishNumbers.convertToString(1000)); Assert.assertEquals("bir", TurkishNumbers.convertToString(1)); Assert.assertEquals("on bir", TurkishNumbers.convertToString(11)); Assert.assertEquals("yüz...
public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int uclu = (int) (gi...
TurkishNumbers { public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int...
TurkishNumbers { public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int...
TurkishNumbers { public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int...
TurkishNumbers { public static String convertToString(long input) { if (input == 0) { return "sıfır"; } if (input < MIN_NUMBER || input > MAX_NUMBER) { throw new IllegalArgumentException("number is out of bounds:" + input); } String result = ""; long girisPos = Math.abs(input); int sayac = 0; while (girisPos > 0) { int...
@Test public void cardinalTest2() { Assert.assertEquals("sıfır", TurkishNumbers.convertNumberToString("0")); Assert.assertEquals("sıfır sıfır", TurkishNumbers.convertNumberToString("00")); Assert.assertEquals("sıfır sıfır sıfır", TurkishNumbers.convertNumberToString("000")); Assert.assertEquals("sıfır sıfır sıfır bir",...
public static String convertNumberToString(String input) { if (input.startsWith("+")) { input = input.substring(1); } List<String> sb = new ArrayList<>(); int i; for (i = 0; i < input.length(); i++) { if (input.charAt(i) == '0') { sb.add("sıfır"); } else { break; } } String rest = input.substring(i); if (rest.length() ...
TurkishNumbers { public static String convertNumberToString(String input) { if (input.startsWith("+")) { input = input.substring(1); } List<String> sb = new ArrayList<>(); int i; for (i = 0; i < input.length(); i++) { if (input.charAt(i) == '0') { sb.add("sıfır"); } else { break; } } String rest = input.substring(i); i...
TurkishNumbers { public static String convertNumberToString(String input) { if (input.startsWith("+")) { input = input.substring(1); } List<String> sb = new ArrayList<>(); int i; for (i = 0; i < input.length(); i++) { if (input.charAt(i) == '0') { sb.add("sıfır"); } else { break; } } String rest = input.substring(i); i...
TurkishNumbers { public static String convertNumberToString(String input) { if (input.startsWith("+")) { input = input.substring(1); } List<String> sb = new ArrayList<>(); int i; for (i = 0; i < input.length(); i++) { if (input.charAt(i) == '0') { sb.add("sıfır"); } else { break; } } String rest = input.substring(i); i...
TurkishNumbers { public static String convertNumberToString(String input) { if (input.startsWith("+")) { input = input.substring(1); } List<String> sb = new ArrayList<>(); int i; for (i = 0; i < input.length(); i++) { if (input.charAt(i) == '0') { sb.add("sıfır"); } else { break; } } String rest = input.substring(i); i...
@Test public void ordinalTest() { Assert.assertEquals("sıfırıncı", TurkishNumbers.convertOrdinalNumberString("0.")); }
public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); String lastNumber = w...
TurkishNumbers { public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); Stri...
TurkishNumbers { public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); Stri...
TurkishNumbers { public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); Stri...
TurkishNumbers { public static String convertOrdinalNumberString(String input) { String numberPart = input; if (input.endsWith(".")) { numberPart = Strings.subStringUntilFirst(input, "."); } long number = Long.parseLong(numberPart); String text = convertToString(number); String[] words = text.trim().split("[ ]+"); Stri...
@Test public void separateNumbersTest() { Assert.assertEquals(Lists.newArrayList("H", "12", "A", "5") , TurkishNumbers.separateNumbers("H12A5")); Assert.assertEquals(Lists.newArrayList("F", "16", "'ya") , TurkishNumbers.separateNumbers("F16'ya")); }
public static List<String> separateNumbers(String s) { return Regexps.allMatches(NUMBER_SEPARATION, s); }
TurkishNumbers { public static List<String> separateNumbers(String s) { return Regexps.allMatches(NUMBER_SEPARATION, s); } }
TurkishNumbers { public static List<String> separateNumbers(String s) { return Regexps.allMatches(NUMBER_SEPARATION, s); } }
TurkishNumbers { public static List<String> separateNumbers(String s) { return Regexps.allMatches(NUMBER_SEPARATION, s); } static Map<String, String> getOrdinalMap(); static String convertToString(long input); static String convertNumberToString(String input); static long singleWordNumberValue(String word); static Lis...
TurkishNumbers { public static List<String> separateNumbers(String s) { return Regexps.allMatches(NUMBER_SEPARATION, s); } static Map<String, String> getOrdinalMap(); static String convertToString(long input); static String convertNumberToString(String input); static long singleWordNumberValue(String word); static Lis...
@Test @Ignore("Slow. Uses actual data.") public void suggestWord1() throws Exception { TurkishMorphology morphology = TurkishMorphology.builder() .setLexicon("Türkiye", "Bayram").build(); List<String> endings = Lists.newArrayList("ında", "de"); StemEndingGraph graph = new StemEndingGraph(morphology, endings); TurkishSp...
public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { co...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
@Test public void separateConnectedNumbersTest() { Assert.assertEquals(Lists.newArrayList("on") , TurkishNumbers.seperateConnectedNumbers("on")); Assert.assertEquals(Lists.newArrayList("on", "iki", "bin", "altı", "yüz") , TurkishNumbers.seperateConnectedNumbers("onikibinaltıyüz")); Assert.assertEquals(Lists.newArrayLis...
public static List<String> seperateConnectedNumbers(List<String> inputSequence) { List<String> output = new ArrayList<>(inputSequence.size()); for (String s : inputSequence) { if (stringToNumber.containsKey(s)) { output.add(valueOf(stringToNumber.get(s))); continue; } output.addAll(seperateConnectedNumbers(s)); } retur...
TurkishNumbers { public static List<String> seperateConnectedNumbers(List<String> inputSequence) { List<String> output = new ArrayList<>(inputSequence.size()); for (String s : inputSequence) { if (stringToNumber.containsKey(s)) { output.add(valueOf(stringToNumber.get(s))); continue; } output.addAll(seperateConnectedNum...
TurkishNumbers { public static List<String> seperateConnectedNumbers(List<String> inputSequence) { List<String> output = new ArrayList<>(inputSequence.size()); for (String s : inputSequence) { if (stringToNumber.containsKey(s)) { output.add(valueOf(stringToNumber.get(s))); continue; } output.addAll(seperateConnectedNum...
TurkishNumbers { public static List<String> seperateConnectedNumbers(List<String> inputSequence) { List<String> output = new ArrayList<>(inputSequence.size()); for (String s : inputSequence) { if (stringToNumber.containsKey(s)) { output.add(valueOf(stringToNumber.get(s))); continue; } output.addAll(seperateConnectedNum...
TurkishNumbers { public static List<String> seperateConnectedNumbers(List<String> inputSequence) { List<String> output = new ArrayList<>(inputSequence.size()); for (String s : inputSequence) { if (stringToNumber.containsKey(s)) { output.add(valueOf(stringToNumber.get(s))); continue; } output.addAll(seperateConnectedNum...
@Test public void testTextToNumber1() { Assert.assertEquals(11, TurkishNumbers.convertToNumber("on bir")); Assert.assertEquals(111, TurkishNumbers.convertToNumber("yüz on bir")); Assert.assertEquals(101, TurkishNumbers.convertToNumber("yüz bir")); Assert.assertEquals(1000_000, TurkishNumbers.convertToNumber("bir milyon...
public static long convertToNumber(String... words) { return textToNumber.convert(words); }
TurkishNumbers { public static long convertToNumber(String... words) { return textToNumber.convert(words); } }
TurkishNumbers { public static long convertToNumber(String... words) { return textToNumber.convert(words); } }
TurkishNumbers { public static long convertToNumber(String... words) { return textToNumber.convert(words); } static Map<String, String> getOrdinalMap(); static String convertToString(long input); static String convertNumberToString(String input); static long singleWordNumberValue(String word); static List<String> repl...
TurkishNumbers { public static long convertToNumber(String... words) { return textToNumber.convert(words); } static Map<String, String> getOrdinalMap(); static String convertToString(long input); static String convertNumberToString(String input); static long singleWordNumberValue(String word); static List<String> repl...
@Test public void romanNumberTest() { Assert.assertEquals(-1, TurkishNumbers.romanToDecimal("foo")); Assert.assertEquals(-1, TurkishNumbers.romanToDecimal("IIIIIII")); Assert.assertEquals(1987, TurkishNumbers.romanToDecimal("MCMLXXXVII")); }
public static int romanToDecimal(String s) { if (s == null || s.isEmpty() || !romanNumeralPattern.matcher(s).matches()) { return -1; } final Matcher matcher = Pattern.compile("M|CM|D|CD|C|XC|L|XL|X|IX|V|IV|I").matcher(s); final int[] decimalValues = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; final String[]...
TurkishNumbers { public static int romanToDecimal(String s) { if (s == null || s.isEmpty() || !romanNumeralPattern.matcher(s).matches()) { return -1; } final Matcher matcher = Pattern.compile("M|CM|D|CD|C|XC|L|XL|X|IX|V|IV|I").matcher(s); final int[] decimalValues = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1...
TurkishNumbers { public static int romanToDecimal(String s) { if (s == null || s.isEmpty() || !romanNumeralPattern.matcher(s).matches()) { return -1; } final Matcher matcher = Pattern.compile("M|CM|D|CD|C|XC|L|XL|X|IX|V|IV|I").matcher(s); final int[] decimalValues = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1...
TurkishNumbers { public static int romanToDecimal(String s) { if (s == null || s.isEmpty() || !romanNumeralPattern.matcher(s).matches()) { return -1; } final Matcher matcher = Pattern.compile("M|CM|D|CD|C|XC|L|XL|X|IX|V|IV|I").matcher(s); final int[] decimalValues = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1...
TurkishNumbers { public static int romanToDecimal(String s) { if (s == null || s.isEmpty() || !romanNumeralPattern.matcher(s).matches()) { return -1; } final Matcher matcher = Pattern.compile("M|CM|D|CD|C|XC|L|XL|X|IX|V|IV|I").matcher(s); final int[] decimalValues = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1...
@Test public void getPosTest() { RuleBasedAnalyzer analyzer = getAnalyzer("görmek"); List<SingleAnalysis> analyses = analyzer.analyze("görmek"); Assert.assertEquals(1, analyses.size()); SingleAnalysis analysis = analyses.get(0); Assert.assertEquals(analysis.getDictionaryItem(), analyzer.getLexicon().getItemById("görmek...
public PrimaryPos getPos() { return getGroup(groupCount() - 1).getPos(); }
SingleAnalysis { public PrimaryPos getPos() { return getGroup(groupCount() - 1).getPos(); } }
SingleAnalysis { public PrimaryPos getPos() { return getGroup(groupCount() - 1).getPos(); } SingleAnalysis( DictionaryItem item, List<MorphemeData> morphemeDataList, int[] groupBoundaries); }
SingleAnalysis { public PrimaryPos getPos() { return getGroup(groupCount() - 1).getPos(); } SingleAnalysis( DictionaryItem item, List<MorphemeData> morphemeDataList, int[] groupBoundaries); static SingleAnalysis unknown(String input); static SingleAnalysis dummy(String input, DictionaryItem item); Str...
SingleAnalysis { public PrimaryPos getPos() { return getGroup(groupCount() - 1).getPos(); } SingleAnalysis( DictionaryItem item, List<MorphemeData> morphemeDataList, int[] groupBoundaries); static SingleAnalysis unknown(String input); static SingleAnalysis dummy(String input, DictionaryItem item); Str...
@Test public void getStemsTest() { RuleBasedAnalyzer analyzer = getAnalyzer("kitap"); SingleAnalysis analysis = analyzer.analyze("kitap").get(0); Assert.assertEquals(toList("kitap"), analysis.getStems()); analysis = analyzer.analyze("kitaplı").get(0); Assert.assertEquals(toList("kitap", "kitaplı"), analysis.getStems())...
public List<String> getStems() { List<String> stems = Lists.newArrayListWithCapacity(2); stems.add(getStem()); String previousStem = getGroup(0).surfaceForm(); if (groupBoundaries.length > 1) { for (int i = 1; i < groupBoundaries.length; i++) { MorphemeGroup ig = getGroup(i); MorphemeData suffixData = ig.morphemes.get(...
SingleAnalysis { public List<String> getStems() { List<String> stems = Lists.newArrayListWithCapacity(2); stems.add(getStem()); String previousStem = getGroup(0).surfaceForm(); if (groupBoundaries.length > 1) { for (int i = 1; i < groupBoundaries.length; i++) { MorphemeGroup ig = getGroup(i); MorphemeData suffixData = ...
SingleAnalysis { public List<String> getStems() { List<String> stems = Lists.newArrayListWithCapacity(2); stems.add(getStem()); String previousStem = getGroup(0).surfaceForm(); if (groupBoundaries.length > 1) { for (int i = 1; i < groupBoundaries.length; i++) { MorphemeGroup ig = getGroup(i); MorphemeData suffixData = ...
SingleAnalysis { public List<String> getStems() { List<String> stems = Lists.newArrayListWithCapacity(2); stems.add(getStem()); String previousStem = getGroup(0).surfaceForm(); if (groupBoundaries.length > 1) { for (int i = 1; i < groupBoundaries.length; i++) { MorphemeGroup ig = getGroup(i); MorphemeData suffixData = ...
SingleAnalysis { public List<String> getStems() { List<String> stems = Lists.newArrayListWithCapacity(2); stems.add(getStem()); String previousStem = getGroup(0).surfaceForm(); if (groupBoundaries.length > 1) { for (int i = 1; i < groupBoundaries.length; i++) { MorphemeGroup ig = getGroup(i); MorphemeData suffixData = ...
@Test public void getLemmasTest() { RuleBasedAnalyzer analyzer = getAnalyzer("kitap"); SingleAnalysis analysis = analyzer.analyze("kitap").get(0); Assert.assertEquals(toList("kitap"), analysis.getLemmas()); analysis = analyzer.analyze("kitaplı").get(0); Assert.assertEquals(toList("kitap", "kitaplı"), analysis.getLemmas...
public List<String> getLemmas() { List<String> lemmas = Lists.newArrayListWithCapacity(2); lemmas.add(item.root); String previousStem = getGroup(0).surfaceForm(); if (!previousStem.equals(item.root)) { if (previousStem.endsWith("ğ")) { previousStem = previousStem.substring(0, previousStem.length() - 1) + "k"; } } if (g...
SingleAnalysis { public List<String> getLemmas() { List<String> lemmas = Lists.newArrayListWithCapacity(2); lemmas.add(item.root); String previousStem = getGroup(0).surfaceForm(); if (!previousStem.equals(item.root)) { if (previousStem.endsWith("ğ")) { previousStem = previousStem.substring(0, previousStem.length() - 1)...
SingleAnalysis { public List<String> getLemmas() { List<String> lemmas = Lists.newArrayListWithCapacity(2); lemmas.add(item.root); String previousStem = getGroup(0).surfaceForm(); if (!previousStem.equals(item.root)) { if (previousStem.endsWith("ğ")) { previousStem = previousStem.substring(0, previousStem.length() - 1)...
SingleAnalysis { public List<String> getLemmas() { List<String> lemmas = Lists.newArrayListWithCapacity(2); lemmas.add(item.root); String previousStem = getGroup(0).surfaceForm(); if (!previousStem.equals(item.root)) { if (previousStem.endsWith("ğ")) { previousStem = previousStem.substring(0, previousStem.length() - 1)...
SingleAnalysis { public List<String> getLemmas() { List<String> lemmas = Lists.newArrayListWithCapacity(2); lemmas.add(item.root); String previousStem = getGroup(0).surfaceForm(); if (!previousStem.equals(item.root)) { if (previousStem.endsWith("ğ")) { previousStem = previousStem.substring(0, previousStem.length() - 1)...
@Test public void getLemmasAfterZeroMorphemeTest_Issue_175() { RuleBasedAnalyzer analyzer = getAnalyzer("gün"); List<SingleAnalysis> analyses = analyzer.analyze("günlüğüm"); boolean found = false; for (SingleAnalysis analysis : analyses) { if (analysis.formatLong().contains("Ness→Noun+A3sg|Zero→Verb")) { found = true; ...
public String formatLong() { return AnalysisFormatters.DEFAULT.format(this); }
SingleAnalysis { public String formatLong() { return AnalysisFormatters.DEFAULT.format(this); } }
SingleAnalysis { public String formatLong() { return AnalysisFormatters.DEFAULT.format(this); } SingleAnalysis( DictionaryItem item, List<MorphemeData> morphemeDataList, int[] groupBoundaries); }
SingleAnalysis { public String formatLong() { return AnalysisFormatters.DEFAULT.format(this); } SingleAnalysis( DictionaryItem item, List<MorphemeData> morphemeDataList, int[] groupBoundaries); static SingleAnalysis unknown(String input); static SingleAnalysis dummy(String input, DictionaryItem item);...
SingleAnalysis { public String formatLong() { return AnalysisFormatters.DEFAULT.format(this); } SingleAnalysis( DictionaryItem item, List<MorphemeData> morphemeDataList, int[] groupBoundaries); static SingleAnalysis unknown(String input); static SingleAnalysis dummy(String input, DictionaryItem item);...
@Test public void formatNonProperNoun() { TurkishMorphology morphology = TurkishMorphology.builder() .disableCache() .setLexicon("elma", "kitap", "demek", "evet") .build(); String[] inputs = {"elmamadaki", "elma", "kitalarımdan", "kitabımızsa", "diyebileceğimiz", "dedi", "evet"}; WordAnalysisSurfaceFormatter formatter ...
public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ? item.normalizedLemma() + apost...
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ?...
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ?...
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ?...
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ?...
@Test public void formatNumerals() { TurkishMorphology morphology = TurkishMorphology.builder().disableCache().build(); String[] inputs = {"1e", "4ten", "123ü", "12,5ten"}; String[] expected = {"1'e", "4'ten", "123'ü", "12,5ten"}; WordAnalysisSurfaceFormatter formatter = new WordAnalysisSurfaceFormatter(); int i = 0; f...
public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ? item.normalizedLemma() + apost...
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ?...
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ?...
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ?...
WordAnalysisSurfaceFormatter { public String format(SingleAnalysis analysis, String apostrophe) { DictionaryItem item = analysis.getDictionaryItem(); String ending = analysis.getEnding(); if (apostrophe != null || apostropheRequired(analysis)) { if (apostrophe == null) { apostrophe = "'"; } return ending.length() > 0 ?...
@Test public void formatToCase() { TurkishMorphology morphology = TurkishMorphology.builder() .disableCache() .setLexicon("kış", "şiir", "Aydın", "Google [Pr:gugıl]") .build(); String[] inputs = {"aydında", "googledan", "Google", "şiirde", "kışçığa", "kış"}; String[] expectedDefaultCase = {"Aydın'da", "Google'dan", "Go...
public String formatToCase(SingleAnalysis analysis, CaseType type, String apostrophe) { String formatted = format(analysis, apostrophe); Locale locale = analysis.getDictionaryItem().hasAttribute(RootAttribute.LocaleEn) ? Locale.ENGLISH : Turkish.LOCALE; switch (type) { case DEFAULT_CASE: return formatted; case LOWER_CA...
WordAnalysisSurfaceFormatter { public String formatToCase(SingleAnalysis analysis, CaseType type, String apostrophe) { String formatted = format(analysis, apostrophe); Locale locale = analysis.getDictionaryItem().hasAttribute(RootAttribute.LocaleEn) ? Locale.ENGLISH : Turkish.LOCALE; switch (type) { case DEFAULT_CASE: ...
WordAnalysisSurfaceFormatter { public String formatToCase(SingleAnalysis analysis, CaseType type, String apostrophe) { String formatted = format(analysis, apostrophe); Locale locale = analysis.getDictionaryItem().hasAttribute(RootAttribute.LocaleEn) ? Locale.ENGLISH : Turkish.LOCALE; switch (type) { case DEFAULT_CASE: ...
WordAnalysisSurfaceFormatter { public String formatToCase(SingleAnalysis analysis, CaseType type, String apostrophe) { String formatted = format(analysis, apostrophe); Locale locale = analysis.getDictionaryItem().hasAttribute(RootAttribute.LocaleEn) ? Locale.ENGLISH : Turkish.LOCALE; switch (type) { case DEFAULT_CASE: ...
WordAnalysisSurfaceFormatter { public String formatToCase(SingleAnalysis analysis, CaseType type, String apostrophe) { String formatted = format(analysis, apostrophe); Locale locale = analysis.getDictionaryItem().hasAttribute(RootAttribute.LocaleEn) ? Locale.ENGLISH : Turkish.LOCALE; switch (type) { case DEFAULT_CASE: ...
@Test public void suggestVerb1() { TurkishMorphology morphology = TurkishMorphology.builder().setLexicon("okumak").build(); List<String> endings = Lists.newArrayList("dum"); StemEndingGraph graph = new StemEndingGraph(morphology, endings); TurkishSpellChecker spellChecker = new TurkishSpellChecker(morphology, graph.ste...
public List<String> suggestForWord(String word, NgramLanguageModel lm) { List<String> unRanked = getUnrankedSuggestions(word); return rankWithUnigramProbability(unRanked, lm); }
TurkishSpellChecker { public List<String> suggestForWord(String word, NgramLanguageModel lm) { List<String> unRanked = getUnrankedSuggestions(word); return rankWithUnigramProbability(unRanked, lm); } }
TurkishSpellChecker { public List<String> suggestForWord(String word, NgramLanguageModel lm) { List<String> unRanked = getUnrankedSuggestions(word); return rankWithUnigramProbability(unRanked, lm); } TurkishSpellChecker(TurkishMorphology morphology); TurkishSpellChecker(TurkishMorphology morphology, CharacterGraph gra...
TurkishSpellChecker { public List<String> suggestForWord(String word, NgramLanguageModel lm) { List<String> unRanked = getUnrankedSuggestions(word); return rankWithUnigramProbability(unRanked, lm); } TurkishSpellChecker(TurkishMorphology morphology); TurkishSpellChecker(TurkishMorphology morphology, CharacterGraph gra...
TurkishSpellChecker { public List<String> suggestForWord(String word, NgramLanguageModel lm) { List<String> unRanked = getUnrankedSuggestions(word); return rankWithUnigramProbability(unRanked, lm); } TurkishSpellChecker(TurkishMorphology morphology); TurkishSpellChecker(TurkishMorphology morphology, CharacterGraph gra...
@Test public void guessCaseTest() { String[] inputs = {"abc", "Abc", "ABC", "Abc'de", "ABC'DE", "ABC.", "ABC'de", "a", "12", "A", "A1"}; WordAnalysisSurfaceFormatter.CaseType[] expected = { LOWER_CASE, TITLE_CASE, UPPER_CASE, TITLE_CASE, UPPER_CASE, UPPER_CASE, UPPER_CASE_ROOT_LOWER_CASE_ENDING, LOWER_CASE, DEFAULT_CAS...
public CaseType guessCase(String input) { boolean firstLetterUpperCase = false; int lowerCaseCount = 0; int upperCaseCount = 0; int letterCount = 0; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (!Character.isAlphabetic(c)) { continue; } if (i == 0) { firstLetterUpperCase = Character.isUpperCa...
WordAnalysisSurfaceFormatter { public CaseType guessCase(String input) { boolean firstLetterUpperCase = false; int lowerCaseCount = 0; int upperCaseCount = 0; int letterCount = 0; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (!Character.isAlphabetic(c)) { continue; } if (i == 0) { firstLetter...
WordAnalysisSurfaceFormatter { public CaseType guessCase(String input) { boolean firstLetterUpperCase = false; int lowerCaseCount = 0; int upperCaseCount = 0; int letterCount = 0; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (!Character.isAlphabetic(c)) { continue; } if (i == 0) { firstLetter...
WordAnalysisSurfaceFormatter { public CaseType guessCase(String input) { boolean firstLetterUpperCase = false; int lowerCaseCount = 0; int upperCaseCount = 0; int letterCount = 0; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (!Character.isAlphabetic(c)) { continue; } if (i == 0) { firstLetter...
WordAnalysisSurfaceFormatter { public CaseType guessCase(String input) { boolean firstLetterUpperCase = false; int lowerCaseCount = 0; int upperCaseCount = 0; int letterCount = 0; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (!Character.isAlphabetic(c)) { continue; } if (i == 0) { firstLetter...
@Test public void test() throws IOException { String input = "4 Neden önemli?"; TurkishMorphology analyzer = TurkishMorphology.createWithDefaults(); RuleBasedDisambiguator disambiguator = new RuleBasedDisambiguator(analyzer, Rules.fromResources()); ResultSentence resultSentence = disambiguator.disambiguate(input); Syst...
public ResultSentence disambiguate(String sentence) { List<WordAnalysis> ambiguous = analyzer.analyzeSentence(sentence); ResultSentence s = new ResultSentence(sentence, ambiguous); s.makeDecisions(rules); return s; }
RuleBasedDisambiguator { public ResultSentence disambiguate(String sentence) { List<WordAnalysis> ambiguous = analyzer.analyzeSentence(sentence); ResultSentence s = new ResultSentence(sentence, ambiguous); s.makeDecisions(rules); return s; } }
RuleBasedDisambiguator { public ResultSentence disambiguate(String sentence) { List<WordAnalysis> ambiguous = analyzer.analyzeSentence(sentence); ResultSentence s = new ResultSentence(sentence, ambiguous); s.makeDecisions(rules); return s; } RuleBasedDisambiguator(TurkishMorphology analyzer, Rules rules); }
RuleBasedDisambiguator { public ResultSentence disambiguate(String sentence) { List<WordAnalysis> ambiguous = analyzer.analyzeSentence(sentence); ResultSentence s = new ResultSentence(sentence, ambiguous); s.makeDecisions(rules); return s; } RuleBasedDisambiguator(TurkishMorphology analyzer, Rules rules); ResultSentenc...
RuleBasedDisambiguator { public ResultSentence disambiguate(String sentence) { List<WordAnalysis> ambiguous = analyzer.analyzeSentence(sentence); ResultSentence s = new ResultSentence(sentence, ambiguous); s.makeDecisions(rules); return s; } RuleBasedDisambiguator(TurkishMorphology analyzer, Rules rules); ResultSentenc...
@Test public void testTitleWithDoubleQuotes() { String meta = "<doc id=\"http: String content = "Fernandao yeni yıldan şampiyonluk bekliyor\n" + "30.12.2016 Cuma 17:04 (Güncellendi: 30.12.2016 Cuma 17:09)\n" + "Fernandao yeni yıldan şampiyonluk bekliyor\n" + "</doc>"; WebDocument d = WebDocument.fromText(meta, Splitter...
public static WebDocument fromText(String meta, List<String> pageData) { String url = Regexps.firstMatch(urlPattern, meta, 2); String id = url.replaceAll("http: String source = Regexps.firstMatch(sourcePattern, meta, 2); String crawlDate = Regexps.firstMatch(crawlDatePattern, meta, 2); String labels = getAttribute(labe...
WebDocument { public static WebDocument fromText(String meta, List<String> pageData) { String url = Regexps.firstMatch(urlPattern, meta, 2); String id = url.replaceAll("http: String source = Regexps.firstMatch(sourcePattern, meta, 2); String crawlDate = Regexps.firstMatch(crawlDatePattern, meta, 2); String labels = get...
WebDocument { public static WebDocument fromText(String meta, List<String> pageData) { String url = Regexps.firstMatch(urlPattern, meta, 2); String id = url.replaceAll("http: String source = Regexps.firstMatch(sourcePattern, meta, 2); String crawlDate = Regexps.firstMatch(crawlDatePattern, meta, 2); String labels = get...
WebDocument { public static WebDocument fromText(String meta, List<String> pageData) { String url = Regexps.firstMatch(urlPattern, meta, 2); String id = url.replaceAll("http: String source = Regexps.firstMatch(sourcePattern, meta, 2); String crawlDate = Regexps.firstMatch(crawlDatePattern, meta, 2); String labels = get...
WebDocument { public static WebDocument fromText(String meta, List<String> pageData) { String url = Regexps.firstMatch(urlPattern, meta, 2); String id = url.replaceAll("http: String source = Regexps.firstMatch(sourcePattern, meta, 2); String crawlDate = Regexps.firstMatch(crawlDatePattern, meta, 2); String labels = get...
@Test public void saveLoadDocument() throws IOException, SQLException { Path tempDir = Files.createTempDirectory("foo"); CorpusDb storage = new CorpusDb(tempDir); Map<Integer, CorpusDocument> docMap = saveDocuments(storage); for (Integer key : docMap.keySet()) { CorpusDocument expected = docMap.get(key); CorpusDocument...
public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); }
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } }
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } CorpusDb(Path dbRoot); private CorpusDb(JdbcConnectionPool connectionPool); }
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } CorpusDb(Path dbRoot); private CorpusDb(JdbcConnectionPool connectionPool); void addAll(List<CorpusDocumen...
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } CorpusDb(Path dbRoot); private CorpusDb(JdbcConnectionPool connectionPool); void addAll(List<CorpusDocumen...
@Test public void search() throws IOException, SQLException { Path tempDir = Files.createTempDirectory("foo"); CorpusDb storage = new CorpusDb(tempDir); Map<Integer, CorpusDocument> docMap = saveDocuments(storage); for (Integer key : docMap.keySet()) { CorpusDocument doc = docMap.get(key); List<String> paragraphs = Spl...
public List<SentenceSearchResult> search(String text) { try (Connection connection = connectionPool.getConnection()) { String sql = "SELECT T.* FROM FT_SEARCH_DATA('" + text + "', 0, 0) FT, SENTENCE_TABLE T " + "WHERE FT.TABLE='SENTENCE_TABLE' AND T.ID=FT.KEYS[0];"; Statement stat = connection.createStatement(); Result...
CorpusDb { public List<SentenceSearchResult> search(String text) { try (Connection connection = connectionPool.getConnection()) { String sql = "SELECT T.* FROM FT_SEARCH_DATA('" + text + "', 0, 0) FT, SENTENCE_TABLE T " + "WHERE FT.TABLE='SENTENCE_TABLE' AND T.ID=FT.KEYS[0];"; Statement stat = connection.createStatemen...
CorpusDb { public List<SentenceSearchResult> search(String text) { try (Connection connection = connectionPool.getConnection()) { String sql = "SELECT T.* FROM FT_SEARCH_DATA('" + text + "', 0, 0) FT, SENTENCE_TABLE T " + "WHERE FT.TABLE='SENTENCE_TABLE' AND T.ID=FT.KEYS[0];"; Statement stat = connection.createStatemen...
CorpusDb { public List<SentenceSearchResult> search(String text) { try (Connection connection = connectionPool.getConnection()) { String sql = "SELECT T.* FROM FT_SEARCH_DATA('" + text + "', 0, 0) FT, SENTENCE_TABLE T " + "WHERE FT.TABLE='SENTENCE_TABLE' AND T.ID=FT.KEYS[0];"; Statement stat = connection.createStatemen...
CorpusDb { public List<SentenceSearchResult> search(String text) { try (Connection connection = connectionPool.getConnection()) { String sql = "SELECT T.* FROM FT_SEARCH_DATA('" + text + "', 0, 0) FT, SENTENCE_TABLE T " + "WHERE FT.TABLE='SENTENCE_TABLE' AND T.ID=FT.KEYS[0];"; Statement stat = connection.createStatemen...
@Test public void WriteStringTest() throws IOException { new SimpleTextWriter(tmpFile).write("Hello World!"); Assert.assertEquals(new SimpleTextReader(tmpFile).asString(), "Hello World!"); new SimpleTextWriter(tmpFile).write(null); Assert.assertEquals(new SimpleTextReader(tmpFile).asString(), ""); new SimpleTextWriter(...
public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } }
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } }
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
@Test public void WriteStringKeepOpenTest() throws IOException { try (SimpleTextWriter sfw = new SimpleTextWriter .Builder(tmpFile) .keepOpen() .build()) { sfw.write("Hello"); sfw.write("Merhaba"); sfw.write(""); sfw.write(null); } Assert.assertEquals("HelloMerhaba", new SimpleTextReader(tmpFile).asString()); }
public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } }
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } }
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
@Test(expected = IOException.class) public void keepOpenExcepionTest() throws IOException { SimpleTextWriter sfw = new SimpleTextWriter .Builder(tmpFile) .build(); sfw.write("Hello"); sfw.write("Now it will throw an exception.."); }
public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } }
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } }
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, ...
@Test public void WriteMultiLineStringTest() throws IOException { List<String> strs = new ArrayList<>(Arrays.asList("Merhaba", "Dunya", "")); new SimpleTextWriter(tmpFile).writeLines(strs); List<String> read = new SimpleTextReader(tmpFile).asStringList(); for (int i = 0; i < read.size(); i++) { Assert.assertEquals(read...
public SimpleTextWriter writeLines(Collection<String> lines) throws IOException { try { IOs.writeLines(lines, writer); return this; } finally { if (!keepOpen) { close(); } } }
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter writeLines(Collection<String> lines) throws IOException { try { IOs.writeLines(lines, writer); return this; } finally { if (!keepOpen) { close(); } } } }
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter writeLines(Collection<String> lines) throws IOException { try { IOs.writeLines(lines, writer); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, String encoding...
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter writeLines(Collection<String> lines) throws IOException { try { IOs.writeLines(lines, writer); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, String encoding...
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter writeLines(Collection<String> lines) throws IOException { try { IOs.writeLines(lines, writer); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter( BufferedWriter writer, OutputStream os, String encoding...
@Test public void testReader() throws IOException { Map<String, String> map = new KeyValueReader(":") .loadFromFile(new File(key_value_colon_separator.getFile())); Assert.assertEquals(map.size(), 4); Assert.assertTrue(TestUtil.containsAllKeys(map, "1", "2", "3", "4")); Assert.assertTrue(TestUtil.containsAllValues(map, ...
public Map<String, String> loadFromFile(File file) throws IOException { return loadFromFile(new SimpleTextReader. Builder(file) .trim() .ignoreIfStartsWith(ignorePrefix) .ignoreWhiteSpaceLines() .build()); }
KeyValueReader { public Map<String, String> loadFromFile(File file) throws IOException { return loadFromFile(new SimpleTextReader. Builder(file) .trim() .ignoreIfStartsWith(ignorePrefix) .ignoreWhiteSpaceLines() .build()); } }
KeyValueReader { public Map<String, String> loadFromFile(File file) throws IOException { return loadFromFile(new SimpleTextReader. Builder(file) .trim() .ignoreIfStartsWith(ignorePrefix) .ignoreWhiteSpaceLines() .build()); } KeyValueReader(String seperator); KeyValueReader(String seperator, String ignorePrefix); }
KeyValueReader { public Map<String, String> loadFromFile(File file) throws IOException { return loadFromFile(new SimpleTextReader. Builder(file) .trim() .ignoreIfStartsWith(ignorePrefix) .ignoreWhiteSpaceLines() .build()); } KeyValueReader(String seperator); KeyValueReader(String seperator, String ignorePrefix); Map<S...
KeyValueReader { public Map<String, String> loadFromFile(File file) throws IOException { return loadFromFile(new SimpleTextReader. Builder(file) .trim() .ignoreIfStartsWith(ignorePrefix) .ignoreWhiteSpaceLines() .build()); } KeyValueReader(String seperator); KeyValueReader(String seperator, String ignorePrefix); Map<S...
@Test public void checkVerb1() { TurkishMorphology morphology = TurkishMorphology.builder().setLexicon("okumak").build(); List<String> endings = Lists.newArrayList("dum"); StemEndingGraph graph = new StemEndingGraph(morphology, endings); TurkishSpellChecker spellChecker = new TurkishSpellChecker(morphology, graph.stemG...
public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicate.test(analysis)) { co...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
TurkishSpellChecker { public boolean check(String input) { WordAnalysis analyses = morphology.analyze(input); WordAnalysisSurfaceFormatter.CaseType caseType = formatter.guessCase(input); for (SingleAnalysis analysis : analyses) { if (analysis.isUnknown()) { continue; } if (analysisPredicate != null && !analysisPredicat...
@Test public void isEmptyTest() { assertTrue(isNullOrEmpty(null)); assertTrue(isNullOrEmpty("")); assertFalse(isNullOrEmpty("\n")); assertFalse(isNullOrEmpty("\t")); assertFalse(isNullOrEmpty(" ")); assertFalse(isNullOrEmpty("a")); assertFalse(isNullOrEmpty("as")); }
public static boolean isNullOrEmpty(String str) { return str == null || str.length() == 0; }
Strings { public static boolean isNullOrEmpty(String str) { return str == null || str.length() == 0; } }
Strings { public static boolean isNullOrEmpty(String str) { return str == null || str.length() == 0; } private Strings(); }
Strings { public static boolean isNullOrEmpty(String str) { return str == null || str.length() == 0; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static boolean allNullOrEmpty(String... strings); static String leftTrim(St...
Strings { public static boolean isNullOrEmpty(String str) { return str == null || str.length() == 0; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static boolean allNullOrEmpty(String... strings); static String leftTrim(St...
@Test public void hasTextTest() { assertFalse(hasText(null)); assertTrue(hasText("a")); assertTrue(hasText("abc")); assertFalse(hasText("")); assertFalse(hasText(null)); assertFalse(hasText(" ")); assertFalse(hasText("\t")); assertFalse(hasText("\n")); assertFalse(hasText(" \t")); }
public static boolean hasText(String s) { return s != null && s.length() > 0 && s.trim().length() > 0; }
Strings { public static boolean hasText(String s) { return s != null && s.length() > 0 && s.trim().length() > 0; } }
Strings { public static boolean hasText(String s) { return s != null && s.length() > 0 && s.trim().length() > 0; } private Strings(); }
Strings { public static boolean hasText(String s) { return s != null && s.length() > 0 && s.trim().length() > 0; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static boolean allNullOrEmpty(String... strings); static String...
Strings { public static boolean hasText(String s) { return s != null && s.length() > 0 && s.trim().length() > 0; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static boolean allNullOrEmpty(String... strings); static String...
@Test public void testIfAllHasText() { assertTrue(allHasText("fg", "a", "hyh")); assertFalse(allHasText("fg", null, "hyh")); assertFalse(allHasText("fg", " ", "hyh")); }
public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; }
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } }
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } private Strings(); }
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static ...
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static ...
@Test(expected = IllegalArgumentException.class) public void testIfAllHasTextExceptionIAE() { allHasText(); }
public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; }
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } }
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } private Strings(); }
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static ...
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static ...
@Test public void testAllEmpty() { assertTrue(allNullOrEmpty("", "", null)); assertFalse(allNullOrEmpty("", null, "hyh")); assertFalse(allNullOrEmpty(" ", "", "")); }
public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; }
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } }
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } private Strings(); }
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings...
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings...
@Test(expected = IllegalArgumentException.class) public void testAllEmptyExceptionIAE() { allNullOrEmpty(); }
public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; }
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } }
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } private Strings(); }
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings...
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings...
@Test public void leftTrimTest() { assertNull(leftTrim(null)); assertEquals(leftTrim(""), ""); assertEquals(leftTrim(" \t "), ""); assertEquals(leftTrim(" 123"), "123"); assertEquals(leftTrim("\t123"), "123"); assertEquals(leftTrim("\n123"), "123"); assertEquals(leftTrim("123"), "123"); assertEquals(leftTrim(" \n 123")...
public static String leftTrim(String s) { if (s == null) { return null; } if (s.length() == 0) { return EMPTY_STRING; } int j = 0; for (int i = 0; i < s.length(); i++) { if (Character.isWhitespace(s.charAt(i))) { j++; } else { break; } } return s.substring(j); }
Strings { public static String leftTrim(String s) { if (s == null) { return null; } if (s.length() == 0) { return EMPTY_STRING; } int j = 0; for (int i = 0; i < s.length(); i++) { if (Character.isWhitespace(s.charAt(i))) { j++; } else { break; } } return s.substring(j); } }
Strings { public static String leftTrim(String s) { if (s == null) { return null; } if (s.length() == 0) { return EMPTY_STRING; } int j = 0; for (int i = 0; i < s.length(); i++) { if (Character.isWhitespace(s.charAt(i))) { j++; } else { break; } } return s.substring(j); } private Strings(); }
Strings { public static String leftTrim(String s) { if (s == null) { return null; } if (s.length() == 0) { return EMPTY_STRING; } int j = 0; for (int i = 0; i < s.length(); i++) { if (Character.isWhitespace(s.charAt(i))) { j++; } else { break; } } return s.substring(j); } private Strings(); static boolean isNullOrEmpt...
Strings { public static String leftTrim(String s) { if (s == null) { return null; } if (s.length() == 0) { return EMPTY_STRING; } int j = 0; for (int i = 0; i < s.length(); i++) { if (Character.isWhitespace(s.charAt(i))) { j++; } else { break; } } return s.substring(j); } private Strings(); static boolean isNullOrEmpt...
@Test public void rightTrimTest() { assertNull(rightTrim(null)); assertEquals(rightTrim(""), ""); assertEquals(rightTrim(" \t"), ""); assertEquals(rightTrim("aaa "), "aaa"); assertEquals(rightTrim("aaa \t "), "aaa"); assertEquals(rightTrim("aaa\n "), "aaa"); assertEquals(rightTrim("aaa"), "aaa"); assertEquals(rightTrim...
public static String rightTrim(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } int j = str.length(); for (int i = str.length() - 1; i >= 0; --i) { if (Character.isWhitespace(str.charAt(i))) { j--; } else { break; } } return str.substring(0, j); }
Strings { public static String rightTrim(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } int j = str.length(); for (int i = str.length() - 1; i >= 0; --i) { if (Character.isWhitespace(str.charAt(i))) { j--; } else { break; } } return str.substring(0, j); } }
Strings { public static String rightTrim(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } int j = str.length(); for (int i = str.length() - 1; i >= 0; --i) { if (Character.isWhitespace(str.charAt(i))) { j--; } else { break; } } return str.substring(0, j); } private String...
Strings { public static String rightTrim(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } int j = str.length(); for (int i = str.length() - 1; i >= 0; --i) { if (Character.isWhitespace(str.charAt(i))) { j--; } else { break; } } return str.substring(0, j); } private String...
Strings { public static String rightTrim(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } int j = str.length(); for (int i = str.length() - 1; i >= 0; --i) { if (Character.isWhitespace(str.charAt(i))) { j--; } else { break; } } return str.substring(0, j); } private String...
@Test public void repeatTest() { assertEquals(repeat('c', -1), ""); assertEquals(repeat('c', 3), "ccc"); assertEquals(repeat('c', 1), "c"); assertEquals(repeat('c', 0), ""); assertNull(repeat(null, 1)); assertEquals(repeat("ab", -1), ""); assertEquals(repeat("ab", 3), "ababab"); assertEquals(repeat("ab", 1), "ab"); ass...
public static String repeat(char c, int count) { if (count < 1) { return EMPTY_STRING; } char[] chars = new char[count]; Arrays.fill(chars, c); return new String(chars); }
Strings { public static String repeat(char c, int count) { if (count < 1) { return EMPTY_STRING; } char[] chars = new char[count]; Arrays.fill(chars, c); return new String(chars); } }
Strings { public static String repeat(char c, int count) { if (count < 1) { return EMPTY_STRING; } char[] chars = new char[count]; Arrays.fill(chars, c); return new String(chars); } private Strings(); }
Strings { public static String repeat(char c, int count) { if (count < 1) { return EMPTY_STRING; } char[] chars = new char[count]; Arrays.fill(chars, c); return new String(chars); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... string...
Strings { public static String repeat(char c, int count) { if (count < 1) { return EMPTY_STRING; } char[] chars = new char[count]; Arrays.fill(chars, c); return new String(chars); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... string...
@Test public void reverseTest() { assertNull(reverse(null), null); assertEquals(reverse(""), ""); assertEquals(reverse("a"), "a"); assertEquals(reverse("ab"), "ba"); assertEquals(reverse("ab cd "), " dc ba"); }
public static String reverse(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } return new StringBuilder(str).reverse().toString(); }
Strings { public static String reverse(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } return new StringBuilder(str).reverse().toString(); } }
Strings { public static String reverse(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } return new StringBuilder(str).reverse().toString(); } private Strings(); }
Strings { public static String reverse(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } return new StringBuilder(str).reverse().toString(); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String......
Strings { public static String reverse(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } return new StringBuilder(str).reverse().toString(); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String......
@Test public void stemEndingTest1() { TurkishMorphology morphology = TurkishMorphology.builder() .setLexicon("bakmak", "gelmek").build(); List<String> endings = Lists.newArrayList("acak", "ecek"); StemEndingGraph graph = new StemEndingGraph(morphology, endings); CharacterGraphDecoder spellChecker = new CharacterGraphDe...
public List<String> getSuggestions(String input) { return new Decoder().decode(input).getKeyList(); }
CharacterGraphDecoder { public List<String> getSuggestions(String input) { return new Decoder().decode(input).getKeyList(); } }
CharacterGraphDecoder { public List<String> getSuggestions(String input) { return new Decoder().decode(input).getKeyList(); } CharacterGraphDecoder(float maxPenalty); CharacterGraphDecoder(); CharacterGraphDecoder(CharacterGraph graph); CharacterGraphDecoder(float maxPenalty, Map<Character, String> nearKeyMap); }
CharacterGraphDecoder { public List<String> getSuggestions(String input) { return new Decoder().decode(input).getKeyList(); } CharacterGraphDecoder(float maxPenalty); CharacterGraphDecoder(); CharacterGraphDecoder(CharacterGraph graph); CharacterGraphDecoder(float maxPenalty, Map<Character, String> nearKeyMap); Char...
CharacterGraphDecoder { public List<String> getSuggestions(String input) { return new Decoder().decode(input).getKeyList(); } CharacterGraphDecoder(float maxPenalty); CharacterGraphDecoder(); CharacterGraphDecoder(CharacterGraph graph); CharacterGraphDecoder(float maxPenalty, Map<Character, String> nearKeyMap); Char...