@Test public void testWordNetVersionAlignment() throws IOException { URL alignmentURL = resolveLocation(testFile, new WordNetVersionAlignmentTest(), null); WordNetVersionAlignment a = new WordNetVersionAlignment(alignmentURL); assertEquals(3, a.getWeightedAlignments(source).size()); assertEquals(3, a.getAlignments(source).size()); assertTrue(a.getAlignments(nonexistent).isEmpty()); assertTrue(a.getWeightedAlignments(nonexistent).isEmpty()); assertEquals(target, (int) a.getBestWeightedAlignment(source) .getFirst()); assertEquals(0.808, a.getBestWeightedAlignment(source).getSecond(), 0.001); assertEquals(0.808, a.getWeight(source, target), 0.001); assertTrue(a.hasAlignment(source)); assertFalse(a.hasAlignment(nonexistent)); assertEquals(target, a.getBestAlignment(source)); }
public WordNetVersionAlignment(URL url) throws IOException { InputStream is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); map = TreeMultimap.create(Ordering.natural(), new CompareSecond()); String line; while ((line = br.readLine()) != null) { Scanner s = new Scanner(line); s.useLocale(new Locale("en", "us")); Integer source = s.nextInt(); while (s.hasNextInt()) { Integer target = s.nextInt(); Double weight = s.nextDouble(); map.put(source, new Pair<Integer, Double>(target, weight)); } s.close(); } br.close(); is.close(); }
WordNetVersionAlignment { public WordNetVersionAlignment(URL url) throws IOException { InputStream is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); map = TreeMultimap.create(Ordering.natural(), new CompareSecond()); String line; while ((line = br.readLine()) != null) { Scanner s = new Scanner(line); s.useLocale(new Locale("en", "us")); Integer source = s.nextInt(); while (s.hasNextInt()) { Integer target = s.nextInt(); Double weight = s.nextDouble(); map.put(source, new Pair<Integer, Double>(target, weight)); } s.close(); } br.close(); is.close(); } }
WordNetVersionAlignment { public WordNetVersionAlignment(URL url) throws IOException { InputStream is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); map = TreeMultimap.create(Ordering.natural(), new CompareSecond()); String line; while ((line = br.readLine()) != null) { Scanner s = new Scanner(line); s.useLocale(new Locale("en", "us")); Integer source = s.nextInt(); while (s.hasNextInt()) { Integer target = s.nextInt(); Double weight = s.nextDouble(); map.put(source, new Pair<Integer, Double>(target, weight)); } s.close(); } br.close(); is.close(); } WordNetVersionAlignment(URL url); }
WordNetVersionAlignment { public WordNetVersionAlignment(URL url) throws IOException { InputStream is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); map = TreeMultimap.create(Ordering.natural(), new CompareSecond()); String line; while ((line = br.readLine()) != null) { Scanner s = new Scanner(line); s.useLocale(new Locale("en", "us")); Integer source = s.nextInt(); while (s.hasNextInt()) { Integer target = s.nextInt(); Double weight = s.nextDouble(); map.put(source, new Pair<Integer, Double>(target, weight)); } s.close(); } br.close(); is.close(); } WordNetVersionAlignment(URL url); Double getWeight(int synset1, int synset2); SortedSet<Pair<Integer, Double>> getWeightedAlignments(int synset); Collection<Integer> getAlignments(int synset); boolean hasAlignment(int synset); Pair<Integer, Double> getBestWeightedAlignment(int synset); int getBestAlignment(int synset); Map<Integer, V> convertMapKeys(Map<Integer, V> map,
			boolean skipDuplicateKeys, boolean skipUnknownKeys); Multimap<Integer, V> convertMultimapKeys(Map<Integer, V> map,
			boolean addAllAlignments, boolean skipUnknownKeys); }
WordNetVersionAlignment { public WordNetVersionAlignment(URL url) throws IOException { InputStream is = url.openStream(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); map = TreeMultimap.create(Ordering.natural(), new CompareSecond()); String line; while ((line = br.readLine()) != null) { Scanner s = new Scanner(line); s.useLocale(new Locale("en", "us")); Integer source = s.nextInt(); while (s.hasNextInt()) { Integer target = s.nextInt(); Double weight = s.nextDouble(); map.put(source, new Pair<Integer, Double>(target, weight)); } s.close(); } br.close(); is.close(); } WordNetVersionAlignment(URL url); Double getWeight(int synset1, int synset2); SortedSet<Pair<Integer, Double>> getWeightedAlignments(int synset); Collection<Integer> getAlignments(int synset); boolean hasAlignment(int synset); Pair<Integer, Double> getBestWeightedAlignment(int synset); int getBestAlignment(int synset); Map<Integer, V> convertMapKeys(Map<Integer, V> map,
			boolean skipDuplicateKeys, boolean skipUnknownKeys); Multimap<Integer, V> convertMultimapKeys(Map<Integer, V> map,
			boolean addAllAlignments, boolean skipUnknownKeys);  }