Esempio n. 1
0
 public static void main(String[] args) throws Exception {
   File symbolsFile = new File("entries.txt");
   SymbolFileReader reader = new SymbolFileReader(symbolsFile);
   SymbolExtractor extractor = new SymbolExtractor(reader);
   EntryOcr ocr = new EntryOcr();
   for (int i = 0; i < 3; i++) {
     List<String> symbols = extractor.extractNextLine();
     System.out.println(ocr.recognize(symbols));
   }
 }
Esempio n. 2
0
  @Test
  public void canExtractTwoSymbolsFromLine() throws Exception {
    String xSymbol = "";
    xSymbol += "xxx\n";
    xSymbol += "xxx\n";
    xSymbol += "xxx\n";

    String ySymbol = "";
    ySymbol += "yyy\n";
    ySymbol += "yyy\n";
    ySymbol += "yyy\n";

    String symbols = "";
    symbols += "xxxyyy\n";
    symbols += "xxxyyy\n";
    symbols += "xxxyyy\n";

    when(symbolReader.nextLine()).thenReturn(symbols);

    List<String> expectedSymbols = new ArrayList<>();
    expectedSymbols.add(xSymbol);
    expectedSymbols.add(ySymbol);

    assertEquals(expectedSymbols, symbolExtractor.extractNextLine());
  }
Esempio n. 3
0
  @Test
  public void canExtractOneSymbolFromLine() throws Exception {
    String symbol = "";
    symbol += "xxx\n";
    symbol += "xxx\n";
    symbol += "xxx\n";

    when(symbolReader.nextLine()).thenReturn(symbol);

    List<String> expectedSymbols = asList(symbol);
    assertEquals(expectedSymbols, symbolExtractor.extractNextLine());
  }
Esempio n. 4
0
    private SubPlan buildFragment(
        PlanNode root, FragmentProperties properties, PlanFragmentId fragmentId) {
      Set<Symbol> dependencies = SymbolExtractor.extract(root);

      PlanFragment fragment =
          new PlanFragment(
              fragmentId,
              root,
              Maps.filterKeys(types, in(dependencies)),
              properties.getOutputLayout(),
              properties.getDistribution(),
              properties.getDistributeBy(),
              properties.getOutputPartitioning(),
              properties.getPartitionBy(),
              properties.getNullPartitionPolicy(),
              properties.getHash());

      return new SubPlan(fragment, properties.getChildren());
    }