protected void beforeGUI1(Form f) {
    try {
      HttpCon con12 = new HttpCon(null, PropertyClass.ServerUrl + "Allfrends");
      con12.SetContype(false, true, true);
      Thread t = new Thread(con12);
      synchronized (t) {
        t.start();
        t.wait();
      }
      final String bf[] = Splitter.Split(con12.getValue().toString(), "-");
      System.out.println(bf);
      final List l = (List) findByName("studentlist", f);

      for (int i = 0; i < bf.length - 1; i++) {

        l.addItem(Splitter.Split(bf[i], "/")[0]);
      }

      l.addActionListener(
          new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
              frndid = Splitter.Split(bf[l.getSelectedIndex()], "/")[1];
              showForm("Userprofile", null);
            }
          });

    } catch (Exception e) {
      System.out.println(e);
    }

    super.beforeGUI1(f);
  }
Exemplo n.º 2
0
  public void loadGridNet(String mapGrid) throws IOException {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(mapGrid));

    logger.debug("loading {}...", mapGrid);

    CSVReader reader = new CSVReader(new FileReader(mapGrid), ',', '"', 1);
    String[] row;
    while ((row = reader.readNext()) != null) {
      String gridId = row[1].trim();
      String dmRoads = row[2].trim();
      String gjRoads = row[3].trim();

      Set<String> x =
          Sets.newHashSet(Splitter.on('|').trimResults().omitEmptyStrings().split(dmRoads));
      Set<String> y =
          Sets.newHashSet(Splitter.on('|').trimResults().omitEmptyStrings().split(gjRoads));
      if (x.size() > 0 || y.size() > 0) {
        MapGrid grid = new MapGrid();
        grid.dmRoads = x;
        grid.gjRoads = y;

        gridNet.put(gridId, grid);
        //                logger.debug("{},{},{}", gridId, x, y);
      }
    }

    reader.close();
  }
Exemplo n.º 3
0
  @Test
  public void shouldSplitPerSinglePosition() {
    Splitter splitter = SplitterBuilder.from("position");

    Split split = splitter.split(positions);

    assertThat(split.size(), is(4));
  }
 private static void validateIfNeeded(final JComponent c, final Rectangle rect) {
   if (!Splitter.isNull(c)) {
     if (!c.getBounds().equals(rect)) {
       c.setBounds(rect);
       c.revalidate();
     }
   } else {
     Splitter.hideNull(c);
   }
 }
Exemplo n.º 5
0
  @Test
  public void shouldSplitByOwner() {
    Splitter splitter = SplitterBuilder.from("owner");

    Split split = splitter.split(positions);
    assertThat(split.size(), is(3));
    hasGroup(split, "accountOwner");
    hasGroup(split, "bondOwner");
    hasGroup(split, "equityOwner");
  }
Exemplo n.º 6
0
 /**
  * Sets whether or not double-clicking on the splitter should toggle the display of the widget.
  *
  * @param child the child whose display toggling will be allowed or not.
  * @param allowed whether or not display toggling is allowed for this widget
  */
 public void setWidgetToggleDisplayAllowed(Widget child, boolean allowed) {
   // assertIsChild(child);
   assert (child == null) || (child.getParent() == this)
       : "The specified widget is not a child of this panel";
   Splitter splitter = getAssociatedSplitter(child);
   // The splitter is null for the center element.
   if (splitter != null) {
     splitter.setToggleDisplayAllowed(allowed);
   }
 }
Exemplo n.º 7
0
 /**
  * Sets a size below which the slider will close completely. This can be used in conjunction with
  * {@link #setWidgetMinSize} to provide a speed-bump effect where the slider will stick to a
  * preferred minimum size before closing completely.
  *
  * <p>This method has no effect for the {@link DockLayoutPanel.Direction#CENTER} widget.
  *
  * @param child the child whose slider should snap closed
  * @param snapClosedSize the width below which the widget will close or -1 to disable.
  */
 public void setWidgetSnapClosedSize(Widget child, int snapClosedSize) {
   // assertIsChild(child);
   assert (child == null) || (child.getParent() == this)
       : "The specified widget is not a child of this panel";
   Splitter splitter = getAssociatedSplitter(child);
   // The splitter is null for the center element.
   if (splitter != null) {
     splitter.setSnapClosedSize(snapClosedSize);
   }
 }
Exemplo n.º 8
0
  @Test
  public void shouldSplitPerCurrency() {
    Splitter splitter = SplitterBuilder.from("currency");

    Split split = splitter.split(positions);

    assertThat(split.size(), is(2));
    hasGroup(split, "CHF");
    hasGroup(split, "USD");
    assertThat(split.positions("CHF").size(), is(3));
    assertThat(split.positions("USD").size(), is(1));
  }
Exemplo n.º 9
0
  /**
   * Sets the order added values of the subtree rooted at this splitter node.
   *
   * @param addChild the root of the subtree
   * @param addingTo the tree that this node will belong to
   */
  private final void setOrderAddedSubtree(Splitter addChild, ADTree addingTo) {

    addChild.orderAdded = addingTo.nextSplitAddedOrder();
    for (int i = 0; i < addChild.getNumOfBranches(); i++) {
      PredictionNode node = addChild.getChildForBranch(i);
      if (node != null) {
        for (Enumeration<Splitter> e = node.children(); e.hasMoreElements(); ) {
          setOrderAddedSubtree(e.nextElement(), addingTo);
        }
      }
    }
  }
Exemplo n.º 10
0
  public Container CreateContentPane() {
    // Create the content-pane-to-be.
    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.setOpaque(true);

    // the log panel
    log = new JTextPane();
    log.setEditable(false);
    log.setBackground(Color.BLACK);
    logPane = new JScrollPane(log);
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    log.setEditorKit(kit);
    log.setDocument(doc);
    DefaultCaret c = (DefaultCaret) log.getCaret();
    c.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    ClearLog();

    // the preview panel
    previewPane = new DrawPanel();
    previewPane.setPaperSize(paper_top, paper_bottom, paper_left, paper_right);

    // status bar
    statusBar = new StatusBar();
    Font f = statusBar.getFont();
    statusBar.setFont(f.deriveFont(Font.BOLD, 15));
    Dimension d = statusBar.getMinimumSize();
    d.setSize(d.getWidth(), d.getHeight() + 30);
    statusBar.setMinimumSize(d);

    // layout
    Splitter split = new Splitter(JSplitPane.VERTICAL_SPLIT);
    split.add(previewPane);
    split.add(logPane);
    split.setDividerSize(8);

    contentPane.add(statusBar, BorderLayout.SOUTH);
    contentPane.add(split, BorderLayout.CENTER);

    // open the file
    if (recentFiles[0].length() > 0) {
      OpenFileOnDemand(recentFiles[0]);
    }

    // connect to the last port
    ListSerialPorts();
    if (Arrays.asList(portsDetected).contains(recentPort)) {
      OpenPort(recentPort);
    }

    return contentPane;
  }
Exemplo n.º 11
0
  @Test
  @Ignore
  public void shouldSplitPerPositionType() {
    Splitter splitter = SplitterBuilder.from("type");

    Split split = splitter.split(positions);

    assertThat(split.size(), is(3));

    hasGroup(split, "Account");
    hasGroup(split, "Bond");
    hasGroup(split, "Equity");
  }
Exemplo n.º 12
0
  @Override
  public Expression parse(String input) {

    input = input.replace(" ", "");

    for (char op : Arrays.asList('+', '-', '*')) {
      if (input.contains("" + op)) {
        Splitter split = new Splitter(op, input);
        return BinaryExpressionFactory.makeBinaryExpression(op, split.getLHS(), split.getRHS());
      }
    }

    return new IntExpression(new Integer(input).intValue());
  }
Exemplo n.º 13
0
  protected boolean onHtmlpasrecoverRetrieve() {

    try {
      String Email = Splitter.Split(new String(record.getRecord(4)), "-")[4];
      if (!Email.equals("n")) {
        HttpCon con =
            new HttpCon(
                new String(record.getRecord(1)) + "-" + Email,
                PropertyClass.ServerUrl + "PasswordRecvoer");
        con.SetContype(true, true, true);
        Thread t = new Thread(con);
        showContainer("AlertBox", null, null);
        synchronized (t) {
          t.start();
          t.wait();
        }

        ((TextField) findByName("status1", HTTPemailsender)).setText(con.getValue().toString());
      } else {
        ((TextField) findByName("status1", HTTPemailsender))
            .setText("Your password need not to retrive, it's default password");
      }
      Email = null;
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    boolean val = super.onHtmlpasrecoverRetrieve();
    return val;
  }
Exemplo n.º 14
0
  protected void beforeMyProfile(Form f) {
    Myprofile = f;
    Label l1 = (Label) findByName("propic", f);
    name = (TextField) findByName("name", Myprofile);
    index = (TextField) findByName("index", Myprofile);
    tel = (TextField) findByName("tel", Myprofile);
    addr = (TextField) findByName("addr", Myprofile);
    email = (TextField) findByName("email", Myprofile);
    group = (TextField) findByName("group", Myprofile);
    try {

      String userde[] = Splitter.Split(new String(record.getRecord(4)), "-");

      name.setText(userde[0]);
      index.setText(userde[1]);
      tel.setText(userde[2]);
      addr.setText(userde[3]);
      email.setText(userde[4]);
      group.setText(userde[5]);

      if (new String(record.getRecord(2)).equals("no")) {
        l1.setIcon(Image.createImage("/no_user.png").scaledHeight(72));

      } else {
        l1.setIcon(Image.createImage(new String(record.getRecord(2))).scaledHeight(72));
      }

      System.gc();
    } catch (Exception e) {
    }
    super.beforeMyProfile(f);
  }
Exemplo n.º 15
0
  public static void main(String[] args) throws Exception {
    parseArguments(args);

    List<Iterator<String>> segments = Splitter.split(inputFilePath, numberOfThreads);

    List<Future<Analytic>> futures = new ArrayList<Future<Analytic>>(segments.size());
    ExecutorService threadPool = Executors.newFixedThreadPool(segments.size());
    for (final Iterator<String> segment : segments) {
      Future<Analytic> future =
          threadPool.submit(
              new Callable<Analytic>() {
                @Override
                public Analytic call() throws Exception {
                  return new Analyzer(segment).parse();
                }
              });
      futures.add(future);
    }

    try {
      ArrayList<Analytic> analytics = new ArrayList<Analytic>(futures.size());
      for (Future<Analytic> future : futures) {
        analytics.add(future.get());
      }
      Analytic result = Synthesizer.synthesize(analytics);
      writeResult(result);
    } finally {
      threadPool.shutdown();
    }
  }
Exemplo n.º 16
0
 private String getNameFor(final String key) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   return parts[parts.length - 1];
 }
Exemplo n.º 17
0
 private List<String> _pro_unreg(String piece) {
   List<String> R = new ArrayList<String>();
   String[] tmp =
       piece
           .replaceAll("。|,|,|!|…|!|《|》|<|>|\"|'|:|:|?|\\?|、|\\||“|”|‘|’|;|—|(|)|·|\\(|\\)| ", " ")
           .split("\\s");
   Splitter spliter = new Splitter("([0-9A-Za-z\\-\\+#@_\\.]+)", true);
   for (int i = tmp.length - 1; i > -1; i--) {
     String[] mc = spliter.split(tmp[i]);
     for (int j = mc.length - 1; j > -1; j--) {
       String r = mc[j];
       if (Pattern.matches("([0-9A-Za-z\\-\\+#@_\\.]+)", r)) R.add(r);
       else R.addAll(_binary_seg(r));
     }
   }
   return R;
 }
Exemplo n.º 18
0
Arquivo: Main.java Projeto: darzul/rdn
  private static void prepare() {
    List<String[]> data = new LinkedList<>();
    data.addAll(Parser.parse("/home/desktop/Documents/Git/fann/project/garcon.csv", ";"));
    data.addAll(Parser.parse("/home/desktop/Documents/Git/fann/project/fille.csv", ";"));
    Person[] persons = Person.buildFrom(data);

    Shuffler<Person> shuffler = new Shuffler<>();
    shuffler.shuffle(persons);

    String[] names = new String[persons.length];
    for (int line = 0; line < persons.length; line++) {
      Person person = persons[line];
      names[line] = person.getName();
    }

    char[] charset = {
      'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
      'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
    };
    int[][] charsFrequency = Analyzer.computeCharsFrequency(names, charset);
    float[][] charsFrequencyNormalized = Analyzer.normalize(charsFrequency, 0, 1);
    //        float[][] firstChar = Analyzer.computeFirstChar(names, charset);
    //        float[][] lastChar = Analyzer.computeLastChar(names, charset);
    //        float[][] twoLastCharsWithoutOrder = Analyzer.computeTwoLastCharWithoutOrder(names,
    // charset);
    float[][] twoLastCharsWithOrder = Analyzer.computeTwoLastCharWithOrder(names, charset);
    for (int line = 0; line < persons.length; line++) {
      Person person = persons[line];
      person.addInputs(charsFrequencyNormalized[line]);
      //            person.addInputs(firstChar[line]);
      //            person.addInputs(lastChar[line]);
      //            person.addInputs(twoLastCharsWithoutOrder[line]);
      person.addInputs(twoLastCharsWithOrder[line]);
    }

    Splitter<Person> splitter = new Splitter<>();
    List<Person[]> bases = splitter.split(Person.class, persons, 0.2f);

    Person[] trainingBase = bases.get(0);
    Person[] testingBase = bases.get(1);

    Converter.toFile(
        "/home/desktop/Documents/Git/fann/project/base/training_base.txt", trainingBase, ' ');
    Converter.toFile(
        "/home/desktop/Documents/Git/fann/project/base/testing_base.txt", testingBase, ' ');
  }
Exemplo n.º 19
0
 public void lex() {
   try {
     tok = split.getToken();
     text = tok.getString();
     val = tok.getType();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Exemplo n.º 20
0
 @Override
 public void removeKey(final String key) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   final Map<String, Tag> parent = this.findLastParent(parts);
   parent.remove(parts[parts.length - 1]);
 }
  /** Iterates and executes the list of batchEventPhases. */
  private void doBatchEventPhases() {
    // Must be called after initialization and before anything else.
    detailSplitter.prePhaseExecute();

    // Get checkpoint from context after checkpoint phase.initialize().
    if (checkpointService != null) {
      traversDetailWithCheckpoint(checkpointService.getCheckpoint());
    } else {
      traversDetailWithOutCheckpoint();
    }
  }
  protected void traversDetailWithOutCheckpoint() {
    final List<Phase> phases = batchPhaseList;

    while (detailSplitter.hasNextRow()) {
      for (Phase phase : phases) {
        context.setCurrentPhaseId(phase.getName());
        feedJobManager.startPhaseStats(phase, context);
        phase.execute();
        feedJobManager.endPhaseStats(phase, context);
      }
    }
  }
Exemplo n.º 23
0
  /**
   * Adds a child to this node. If possible will merge, and will perform a deep copy of the child
   * tree.
   *
   * @param newChild the new child to add (will be cloned)
   * @param addingTo the tree that this node belongs to
   */
  public final void addChild(Splitter newChild, ADTree addingTo) {

    // search for an equivalent child
    Splitter oldEqual = null;
    for (Enumeration<Splitter> e = children(); e.hasMoreElements(); ) {
      Splitter split = e.nextElement();
      if (newChild.equalTo(split)) {
        oldEqual = split;
        break;
      }
    }
    if (oldEqual == null) { // didn't find one so just add
      Splitter addChild = (Splitter) newChild.clone();
      setOrderAddedSubtree(addChild, addingTo);
      children.add(addChild);
    } else { // found one, so do a merge
      for (int i = 0; i < newChild.getNumOfBranches(); i++) {
        PredictionNode oldPred = oldEqual.getChildForBranch(i);
        PredictionNode newPred = newChild.getChildForBranch(i);
        if (oldPred != null && newPred != null) {
          oldPred.merge(newPred, addingTo);
        }
      }
    }
  }
Exemplo n.º 24
0
 private void putTag(final String key, final Tag tag) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.').split((CharSequence) this.createRelativeKey(key)),
               (Class) String.class);
   Map<String, Tag> parent = NBTStorage.this.root;
   for (int i = 0; i < parts.length - 1; ++i) {
     if (!parent.containsKey(parts[i]) || !(parent.get(parts[i]) instanceof CompoundTag)) {
       parent.put(parts[i], new CompoundTag(parts[i]));
     }
     parent = parent.get(parts[i]).getValue();
   }
   parent.put(tag.getName(), tag);
 }
Exemplo n.º 25
0
 private Tag findLastTag(final String key, final boolean relative) {
   final String[] parts =
       (String[])
           Iterables.toArray(
               Splitter.on('.')
                   .omitEmptyStrings()
                   .split((CharSequence) (relative ? this.createRelativeKey(key) : key)),
               (Class) String.class);
   if (parts.length == 0) {
     return new CompoundTag(NBTStorage.this.name, NBTStorage.this.root);
   }
   final Map<String, Tag> map = this.findLastParent(parts);
   if (!map.containsKey(parts[parts.length - 1])) {
     return null;
   }
   return map.get(parts[parts.length - 1]);
 }
Exemplo n.º 26
0
  protected void beforeDepartments(Form f) {
    department = f;
    Label l = (Label) findByName("Label2", f);
    try {
      HttpCon con12 =
          new HttpCon(
              String.valueOf(departmentPerson) + "-p",
              PropertyClass.ServerUrl + "DepartmentOffiecer");
      con12.SetContype(true, true, true);
      Thread t = new Thread(con12);
      synchronized (t) {
        t.start();
        t.wait();
      }

      String a[] = Splitter.Split(con12.getValue().toString(), "-");
      ((Label) findByName("Label3", f)).setText(a[4]);
      ((TextArea) findByName("aboutDepartmentt", f)).setText(a[0]);
      ((Label) findByName("name", f)).setText("Head Dept: " + a[1]);
      ((Label) findByName("Label7", f)).setText(a[2]);
      ((Label) findByName("Label8", f)).setText("Tel : " + a[3]);

      switch (departmentPerson) {
        case 1:
          l.setIcon(Image.createImage("/ceo.png").scaledHeight(78));

          break;
        case 2:
          l.setIcon(Image.createImage("/div1.png").scaledHeight(78));
          break;
        case 3:
          l.setIcon(Image.createImage("/div2.png").scaledHeight(78));
          break;
        case 4:
          l.setIcon(Image.createImage("/div3.png").scaledHeight(78));
          break;
        default:
          l.setIcon(Image.createImage("no_user.png").scaledHeight(78));
          break;
      }
      departmentPerson = 0;
      super.beforeDepartments(f);
      System.gc();
    } catch (Exception e) {
    }
  }
Exemplo n.º 27
0
  public static NbestEntry parse(String cdecStr, int origRank, int numMetrics) {

    NbestEntry result = new NbestEntry();

    // 0 ||| the transactions with the shares of čez achieved almost half of
    // the normal agenda . ||| Glue=8 LanguageModel=-39.2525 PassThrough=1
    // PhraseModel_0=2.18572 PhraseModel_1=13.4858 PhraseModel_2=4.24232
    // WordPenalty=-6.51442 ContextCRF=-35.9812 crf.ContentWordCount=7
    // crf.NonContentWordCount=26 crf.StopWordCount=7
    // crf.NonStopWordCount=26 ||| -28.842
    Iterator<String> columns = Splitter.on(" ||| ").split(cdecStr).iterator();
    result.sentId = Integer.parseInt(columns.next());
    result.hyp = columns.next();
    result.feats = columns.next();
    result.total = Float.parseFloat(columns.next());
    result.origRank = origRank;
    result.metricRank = new int[numMetrics];

    return result;
  }
Exemplo n.º 28
0
  protected boolean onLoginGUILogme() {
    try {
      showForm("FirstForm", null);
      String values[] = Splitter.Split(new String(record.getRecord(1)), "-");
      showForm("FirstForm", null);
      if (values[0].equals(username.getText()) && values[1].equals(password.getText())) {
        showForm("FirstForm", null);
      } else {

        showForm("Htmlpasrecover", null);
      }

      values = null;
    } catch (Exception e) {
      System.out.println(e);
    }

    boolean val = super.onLoginGUILogme();
    return val;
  }
Exemplo n.º 29
0
  protected void beforeUserprofile(Form f) {
    try {
      ((Label) findByName("Label2", f)).setIcon(Image.createImage("/no_user.png").scaledHeight(72));
      HttpCon con12 = new HttpCon(frndid + "-p", PropertyClass.ServerUrl + "Frends");
      con12.SetContype(true, true, true);
      Thread t = new Thread(con12);
      synchronized (t) {
        t.start();
        t.wait();
      }
      String frnd[] = Splitter.Split(con12.getValue().toString(), "-");
      ((Label) findByName("Label4", f)).setText(frnd[0]);
      ((Label) findByName("Label6", f)).setText(frnd[1]);
      ((Label) findByName("tel", f)).setText("Tel   " + frnd[2]);
      ((Label) findByName("Label81", f)).setText("Address   " + frnd[3]);
      ((Label) findByName("Label7", f)).setText("email   " + frnd[4]);

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    super.beforeUserprofile(f);
  }
  protected void traversDetailWithCheckpoint(FeedCheckpoint checkpoint) {
    final List<Phase> phases = batchPhaseList;

    // Determine if a checkpoint has been created and if so, move to it.
    Boolean movingToCheckpoint = performCheckpoint(detailSplitter, checkpoint);

    while (detailSplitter.hasNextRow()) {
      for (Phase phase : phases) {
        // Bypass phases processing when restart from a checkpoint.
        if (!movingToCheckpoint) {
          context.setCurrentPhaseId(phase.getName());
          feedJobManager.startPhaseStats(phase, context);
          phase.execute();
          feedJobManager.endPhaseStats(phase, context);
        }

        // Checkpoint restart has be reached.
        if (movingToCheckpoint && checkpoint.getPhaseId().equals(phase.getName())) {
          movingToCheckpoint = false;
        }
      }
    }
  }