当前位置: 首页>>代码示例>>Java>>正文


Java TextInput类代码示例

本文整理汇总了Java中nars.io.TextInput的典型用法代码示例。如果您正苦于以下问题:Java TextInput类的具体用法?Java TextInput怎么用?Java TextInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TextInput类属于nars.io包,在下文中一共展示了TextInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import nars.io.TextInput; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    NAR n = new NAR();
    
    /*
    new TextInput(n, "<a --> b>.");
    new TextInput(n, "<b --> c>.");
    new TextInput(n, "<d <-> c>. %0.75;0.90%");
    new TextInput(n, "<a --> c>?");      
    new TextInput(n, "<a --> d>?");
    n.run(12);
    */
    
    new TextInput(n, "<0 --> num>. %1.00;0.90% {0 : 1}");
    new TextInput(n, "<<$1 --> num> ==> <(*,$1) --> num>>. %1.00;0.90% {0 : 2}"); 
    new TextInput(n, "<(*,(*,(*,0))) --> num>?  {0 : 3}");
   
    n.run(500);
    
    new ProcessingGraphPanel(n);
}
 
开发者ID:automenta,项目名称:opennars,代码行数:21,代码来源:ProcessingGraphPanel.java

示例2: loadFile

import nars.io.TextInput; //导入依赖的package包/类
public void loadFile(String filePath) throws IOException, FileNotFoundException {
    BufferedReader r = new BufferedReader(new FileReader(filePath));
    String s;

    while ((s = r.readLine()) != null) {

        try {

            doc.insertString(doc.getLength(), s + "\n", null);
        } catch (BadLocationException ex) {
            Logger.getLogger(NARWindow.class.getName()).log(Level.SEVERE, null, ex);
        }

        new TextInput(nar, s); //TODO use a stream to avoid reallocate experiencereader
    }
}
 
开发者ID:opennars,项目名称:pei,代码行数:17,代码来源:NARWindow.java

示例3: main

import nars.io.TextInput; //导入依赖的package包/类
public static void main(String[] args) {
    NAR n = new NAR();
    
    /*
    new TextInput(n, "<a --> b>.");
    new TextInput(n, "<b --> c>.");
    new TextInput(n, "<d <-> c>. %0.75;0.90%");
    new TextInput(n, "<a --> c>?");      
    new TextInput(n, "<a --> d>?");
    n.run(12);
    */
    
    new TextInput(n, "<0 --> num>. %1.00;0.90% {0 : 1}");
    new TextInput(n, "<<$1 --> num> ==> <(*,$1) --> num>>. %1.00;0.90% {0 : 2}"); 
    new TextInput(n, "<(*,(*,(*,0))) --> num>?  {0 : 3}");
   
    n.run(50);
    

    new ProcessingGraphPanel(n);
}
 
开发者ID:opennars,项目名称:pei,代码行数:22,代码来源:ProcessingGraphPanel.java

示例4: init

import nars.io.TextInput; //导入依赖的package包/类
/**
 * TODO multiple files
 */
public void init(String[] args) {
    
    if (args.length > 0
            && CommandLineArguments.isReallyFile(args[0])) {

        try {
            new TextInput(nar, new File(args[0]));
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
    CommandLineArguments.decode(args, nar);
}
 
开发者ID:automenta,项目名称:opennars,代码行数:17,代码来源:NARSwing.java

示例5: main

import nars.io.TextInput; //导入依赖的package包/类
public static void main(String[] args) {
    NAR n = new NAR();
    
    /*
    new TextInput(n, "<a --> b>.");
    new TextInput(n, "<b --> c>.");
    new TextInput(n, "<d <-> c>. %0.75;0.90%");
    new TextInput(n, "<a --> c>?");      
    new TextInput(n, "<a --> d>?");
    n.run(12);
    */
    
    new TextInput(n, "<0 --> num>. %1.00;0.90% {0 : 1}");
    new TextInput(n, "<<$1 --> num> ==> <(*,$1) --> num>>. %1.00;0.90% {0 : 2}"); 
    new TextInput(n, "<(*,(*,(*,0))) --> num>?  {0 : 3}");
   
    n.run(220);
    

    
    Window w = new Window("GraphPanel", new JGraphXGraphPanel(n)) {

        @Override           protected void close() {            }
        
    };
    w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    w.setSize(1200,900);
    w.setVisible(true);
}
 
开发者ID:automenta,项目名称:opennars,代码行数:30,代码来源:JGraphXGraphPanel.java

示例6: openLoadFile

import nars.io.TextInput; //导入依赖的package包/类
/**
 * Open an input experience file with a FileDialog
 */
public void openLoadFile() {
    FileDialog dialog = new FileDialog((FileDialog) null, "Load experience", FileDialog.LOAD);
    dialog.setVisible(true);
    String directoryName = dialog.getDirectory();
    String fileName = dialog.getFile();
    String filePath = directoryName + fileName;

    try {
        new TextInput(nar, new File(filePath));
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:automenta,项目名称:opennars,代码行数:17,代码来源:NARControls.java

示例7: nextInput

import nars.io.TextInput; //导入依赖的package包/类
/**
 * Accept text input in a tick, which can be multiple lines TODO some
 * duplicated code with {@link ExperienceReader#nextInput()}
 *
 * @return Whether to check this channel again
 */
public boolean nextInput() {
    if (timer > 0) {  // wait until the timer
        timer--;
        return true;
    }
    if (!ready) {
        return false;
    }
    String text = inputText.getText().trim();
    String line;    // The next line of text
    int endOfLine;
    // The process steps at a number or no more text
    while ((text.length() > 0) && (timer == 0)) {
        endOfLine = text.indexOf('\n');
        if (endOfLine < 0) {	// this code is reached at end of text
            line = text;
            text = "";
        } else {	// this code is reached for ordinary lines
            line = text.substring(0, endOfLine).trim();
            text = text.substring(endOfLine + 1);	// text becomes rest of text
        }
        
        new TextInput(reasoner, line);
        
        inputText.setText(text);	// update input Text widget to rest of text
        if (text.isEmpty()) {
            ready = false;
        }
    }
    return ((text.length() > 0) || (timer > 0));
}
 
开发者ID:automenta,项目名称:opennars,代码行数:38,代码来源:InputPanel.java

示例8: init

import nars.io.TextInput; //导入依赖的package包/类
/**
 * initialize from an input file
 */
public void init(String[] args) {
    if (args.length > 0) {
        try {
            TextInput fileInput = new TextInput(nar, new File(args[0]));
        } catch (FileNotFoundException ex) {
            System.err.println("NARRun.init: " + ex);
        }
    }
    else {
        new TextInput(nar, new BufferedReader(new InputStreamReader(System.in)));
    }
    new TextOutput(nar, new PrintWriter(out, true));
}
 
开发者ID:automenta,项目名称:opennars,代码行数:17,代码来源:NARRun.java

示例9: init

import nars.io.TextInput; //导入依赖的package包/类
/**
 * initialize from an input file
 */
public void init(String[] args) {
    if (args.length > 0) {
        TextInput fileInput = new TextInput(nar);
        fileInput.includeFile(args[0]);
    }
    else {
        new TextInput(nar, new BufferedReader(new InputStreamReader(System.in)));
    }
    new TextOutput(nar, new PrintWriter(out, true));
}
 
开发者ID:opennars,项目名称:pei,代码行数:14,代码来源:NARRun.java

示例10: read

import nars.io.TextInput; //导入依赖的package包/类
public void read(final String message) {
    TextInput e = new TextInput(nar, new BufferedReader( new StringReader(message)), extraParser);
            
    if (!running)
        resume();
}
 
开发者ID:automenta,项目名称:opennars,代码行数:7,代码来源:NARConnection.java

示例11: testConjunctionTreeSet

import nars.io.TextInput; //导入依赖的package包/类
@Test
public void testConjunctionTreeSet() {
    NAR n = new NAR();
    
    try {           
        
        String term1String ="<#1 --> (&,boy,(/,taller_than,{Tom},_))>";
        Term term1 = TextInput.parseTerm(term1String, n.memory);

        // <#1 --> (|,boy,(/,taller_than,{Tom},_))>
        Term term2 = TextInput.parseTerm("<#1 --> (|,boy,(/,taller_than,{Tom},_))>", n.memory);
   
        assertTrue(term1.toString().equals(term1String));
        assertTrue(term1.getComplexity() > 1);
        assertTrue(term1.getComplexity() == term2.getComplexity());
                    
        assertTrue(term1.getClass().equals(Inheritance.class));
        assertTrue(term1.getClass().equals(Inheritance.class));
        
        /*
        System.out.println("t1: " + term1 + ", complexity=" + term1.getComplexity());
        System.out.println("t2: " + term2 + ", complexity=" + term2.getComplexity());
        */
        
        assertTrue(term1.equals(term1.clone()));
        assertTrue(term1.compareTo((Term)term1.clone())==0);            
        assertTrue(term2.equals(term2.clone()));
        assertTrue(term2.compareTo((Term)term2.clone())==0);
        
        boolean t1e2 = term1.equals(term2);
        int t1c2 = term1.compareTo(term2);
        int t2c1 = term2.compareTo(term1);

        assertTrue(!t1e2);
        assertTrue("term1 and term2 inequal, so t1.compareTo(t2) should not = 0", t1c2!=0);
        assertTrue("term1 and term2 inequal, so t2.compareTo(t1) should not = 0", t2c1!=0);
        
        /*
        System.out.println("t1 equals t2 " + t1e2);
        System.out.println("t1 compareTo t2 " + t1c2);
        System.out.println("t2 compareTo t1 " + t2c1);
        */
        
        TreeSet<Term> set = new TreeSet<Term>();
        boolean added1 = set.add((Term) term1.clone());
        boolean added2 = set.add((Term) term2.clone());
        assertTrue("term 1 added to set", added1);
        assertTrue("term 2 added to set", added2);
        
        assertTrue(set.size() == 2);
    }
    catch (InvalidInputException e) {
        assertTrue(e.toString(), false);
    }
}
 
开发者ID:automenta,项目名称:opennars,代码行数:56,代码来源:TermTest.java

示例12: testGraph

import nars.io.TextInput; //导入依赖的package包/类
@Test
public void testGraph() {

    NAR n = new NAR();
    
    new TextInput(n, "<a --> b>.");
    
    n.run(2);
    
    //System.out.println(n);

    
    NARGraph g = new NARGraph();
    g.add(n, IncludeEverything, new DefaultGraphizer(true,true,true,true,true));
    
    //System.out.println(g);
    
    assert(g.vertexSet().size() > 0);
    assert(g.edgeSet().size() > 0);
}
 
开发者ID:automenta,项目名称:opennars,代码行数:21,代码来源:TestNARGraph.java

示例13: parseOutput

import nars.io.TextInput; //导入依赖的package包/类
public Sentence parseOutput(String o) {
    //getTruthString doesnt work yet because it gets confused when Stamp is at the end of the string. either remove that first or make getTruthString aware of that
    return TextInput.parseOutput(o);
}
 
开发者ID:automenta,项目名称:opennars,代码行数:5,代码来源:TestUtil.java

示例14: actionPerformed

import nars.io.TextInput; //导入依赖的package包/类
/**
     * Handling button click
     *
     * @param e The ActionEvent
     */
    @Override
    public void actionPerformed(ActionEvent e) {
        Object obj = e.getSource();
        if (obj instanceof JButton) {
            if (obj == stopButton) {
                setSpeed(0);
                updateGUI();
            } else if (obj == walkButton) {
                nar.walk(1, true);
                updateGUI();
            }
        } else if (obj instanceof JMenuItem) {
            String label = e.getActionCommand();
            if (label.equals("Load Experience")) {
                experienceReader = new TextInput(nar);
                openLoadFile();
            } else if (label.equals("Save Experience")) {
                if (savingExp) {
                    experienceWriter.closeSaveFile();
                } else {
                    experienceWriter.openSaveFile();
                }
                savingExp = !savingExp;
            } else if (label.equals("Record Inference")) {
                if (record.isLogging()) {
                    record.closeLogFile();
                } else {
                    record.openLogFile();
                }
            } else if (label.equals("Reset")) {
                /// TODO mixture of modifier and reporting
                nar.reset();
            } else if (label.equals("Concepts")) {
                /* see design for Bag and {@link BagWindow} in {@link Bag#startPlay(String)} */
                memory.conceptsStartPlay(new BagWindow<Concept>(), "Active Concepts");
            } else if (label.equals("Buffered Tasks")) {
                memory.taskBuffersStartPlay(new BagWindow<Task>(), "Buffered Tasks");
            } else if (label.equals("Concept Content")) {
                conceptWin.setVisible(true);
            } else if (label.equals("Inference Log")) {
                record.show();
                record.play();
            } else if (label.equals("Related Information")) {
//                MessageDialog web = 
                new MessageDialog(NARSwing.WEBSITE);
            } else if (label.equals("About NARS")) {
//                MessageDialog info = 
                new MessageDialog(NARSwing.INFO);
            } 
        }
    }
 
开发者ID:automenta,项目名称:opennars,代码行数:57,代码来源:NARControls.java

示例15: InputPanel

import nars.io.TextInput; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param reasoner The reasoner
 * @param title The title of the window
 */
public InputPanel(final NAR reasoner) {
    super(new BorderLayout());
    
    JTabbedPane jt = new JTabbedPane();
    
    add(jt, BorderLayout.CENTER);
    
    JPanel textInput = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    textInput.setLayout(gridbag);
    c.ipadx = 2;
    c.ipady = 2;
    c.insets = new Insets(2, 2, 2, 2);
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    c.weighty = 1.0;
    inputText = new JTextArea("");
    inputText.setRows(3);        
    textInput.add(new JScrollPane(inputText), c);
    c.weighty = 0.0;
    c.gridwidth = 1;
    okButton = new JButton("Eval");
    okButton.addActionListener(this);
    gridbag.setConstraints(okButton, c);        
    textInput.add(okButton);
    holdButton = new JButton("Hold");
    holdButton.addActionListener(this);
    gridbag.setConstraints(holdButton, c);
    textInput.add(holdButton);
    clearButton = new JButton("Clear");
    clearButton.addActionListener(this);
    gridbag.setConstraints(clearButton, c);
    textInput.add(clearButton);
    
    jt.addTab("Edit", textInput);
    

    
    TreeModel model = new FileTreeModel(new File("./nal"));
    final JTree fileTree = new JTree(model);
    fileTree.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            int selRow = fileTree.getRowForLocation(e.getX(), e.getY());
            TreePath selPath = fileTree.getPathForLocation(e.getX(), e.getY());
            if (selRow != -1) {
                if (e.getClickCount() == 1) {
                } else if (e.getClickCount() == 2) {
                    //DoubleClick
                    File f = (File) selPath.getLastPathComponent();

                    if (!f.isDirectory()) {
                        try {
                            new TextInput(reasoner, f);
                            reasoner.output(OUT.class, "Loaded file: " + f.getAbsolutePath());
                        } catch (IOException ex) {
                            System.err.println(ex);
                        }
                    }
                }
            }
        }
    });
    jt.addTab("Files", new JScrollPane(fileTree));
    
    this.reasoner = reasoner;
}
 
开发者ID:automenta,项目名称:opennars,代码行数:75,代码来源:InputPanel.java


注:本文中的nars.io.TextInput类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。