How to give folder of files as input to SyntaxNet - syntaxnet

I am new to Syntaxnet. I followed the basic tutorial, installed syntaxnet and I modified the syntaxnet/demo.sh file and added the following code to context.pbtxt file:
input {
name: 'MAIN-IN'
record_format: 'english-text'
Part {
file_pattern:'/path_to_0095.txt'
}
}
This is helpful only to give the test.txt file as input, Now I want to give a folder of files, ex folder with 100 files as input and get it processed. I tried to give the folder as input which failed. I googled about it, but couldn't find anything useful. So Could any one please let me know how to process multiple files in a folder using syntaxnet ?

We built a Java program around SyntaxNet that dynamically updates the context.pbtxt file with the current file name (after pulling in all of the files in the directory). I don't know if SyntaxNet will allow you to use a directory of files as input.

Related

How to test more than one file in testbook

I have more than one jupyter file to test, with the framework testbook.
Does anyone know how to alter the path, so that i can for example test every file in a folder?

Reading Error when trying to compile SASS in vs code

I installed SASS on my machine via path ( environment variables ).
I can access help and other options(version etc.) but whenever I initiate
`--watch styles.scss:styles.css`
I get the following error :
`Error reading styles.scss: Cannot open file.`
I checked the documentation but to no avail. I get the same error when trying to get more information via
--trace styles.scss:styles.css
I found the reason of my self-inflicted error.
When you initiate
--watch styles.scss styles.css
make sure you add the directory in case you placed your css styles in an external folder
--watch css/styles.scss css/styles.css
Wow, thanks for your description of your self-inflicted error. It solved my problem of not seeing any output for half an hour. I had given the full path for the input file (path from the folder where the command runs to the input file), but had taken that the path of the output file would be relative to the input file (ie: the path from the input file to the output file), but it should also be the full path to the output file (path from the folder where the command runs to the output file). In fact easier, but if one has a wrong expectation in one's head it can take a long time to realize. Your description put me on the right track!

Why is Scout trying to alter files in non-specified directory?

I've used Scout before but haven't run into this problem... when I save a change to an scss file (the scss directory is specified as the "input" folder) which should then rewrite my styles.css file (in the specified "output" folder), I am given an error from scout stating "Error on line 61 of c: File not found or cannot be read:", and it then point to an image file in a separate folder within the site I'm working on.
Why could this be happening? I tried create two Scout projects for the same site: One where the root folder of the site is selected as the main directory and one where the folder a few levels into the site containing the scss and css files are held, but got the same results from both. I don't know why scout would be going into an image folder when the input/output folder are explicitly selected.
How can I make it so Scout just detects changes to my scss files and rewrites the css file without any nonsense about image files? Any help would be appreciated.
Edit: I hope this can give some insight, but the file that seems to be causing the error is being described in a location it is not in: C:\Users\me\Desktop\project/logo.png
There is a logo.png file in another location (C:\Users\me\Desktop\project\apply\assets\img\logo.png) but that doesn't seem to account for the error message. Very puzzled.
Second Edit: I'll try to give this one last bump with a little more info. At this point when I save a scss file I am still getting the same long error message in the scout app about an error, but my style.css file has stopped being affected at all since yesterday. The last message I got was a syntax error and then a very long backtrace message that looks something like this...
Backtrace:
C:/Users/me/Desktop/project/apply/assets/scss/_base.scss:6
C:/Users/me/Desktop/project/apply/assets/scss/style.scss:12
c:/program files (x86)/scout/vendor/gems/gems/sass- 3.2.1/lib/sass/../sass/script/variable.rb:49:in `_perform'
c:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/script/node.rb:40:in `perform'
c:/program files (x86)/scout/vendor/gems/gems/sass-3.2.1/lib/sass/../sass/tree/visitors/perform.rb:294:in `visit_prop'
org/jruby/RubyKernel.java:2096:in `send'

changing home directory in R

In R, if I use the command
write.csv(res,"~/table1_n500.csv")
, then the result is saved in C:\Users\John Smith\Documents.
But I expected it to be saved in C:\Users\John Smith\.
Can I change this home directory (referred by ~ mark) to C:\Users\John Smith\?
From my personal experience, i usually import data from a file (for example in the directory C:\Users\John Smith\DATA)
then i will set working directory as
setwd("C:/Users/John Smith/DATA")
While i want to save the output file in other directory like "C:\Users\John Smith" but not in the data folder.
so i will set relative working directory like
setwd("../")
And when you type getwd()
you will get [1] "C:/Users/John Smith"
Wish this help.
There are two ways to deal with this problem.
1.) Use the function setwd() to set the working directory (or home directory). All save and read commands will look for files in that working directory. I use this only sparingly, and for quick tiny project.
2.) A more preferred approach is to define a variable like dataInputDir, and use function file.path(dataInputDir, <your filename>) to generate a file path. The advantage is that if you are reading (writing) data from (to) multiple directories, you can do this more efficiently:
file.path(dataInputDir1, <your file or dir name>)
file.path(dataInputDir2, <your file or dir name>)
file.path(dataOutputDir1, <your file or dir name>)
file.path(dataOutputDir2, <your file or dir name>)
This approach is really handy for large complicated projects, and is highly recommended.
This is also helpful, if your program is to be executed on multiple platform like Windows, Mac, Linux. You'll have to change the directory location only at one place, and everything else will work smoothly.
Additionally, following functions/handles will be useful for dealing with directory names:
Quick fix:
setwd("../") # setwd to parent folder of current working directory (getwd())
More robust:
setwd(dirname(dataInputDir)) # Setwd to parent folder of dataInputDir

Problem in creating text file(Qt application) in installation directory (using CMake to install)

I am new to programming. I am creating a small word jumble game to practice qt programming. In this application I am creating a text file (score.txt) to keep score of player. I have done this by:
QFile scoreFile("score.txt");
if (QFile::exists("score.txt"))
{
scoreFile.open(QIODevice::ReadWrite | QIODevice::Text)
// and update the score.
}
else
{
scoreFile.open(QIODevice::ReadWrite | QIODevice::Text);//create score file
//and write the score to it.
}
this code is working good here. Now I am using CMake to build and install generated binary (I am working on Ubuntu) using this code:
#set project name, version and build code here.
install(TARGETS wordJumbleGame DESTINATION bin)
I build project in /home/myname/project/build/
My source code is in /home/myname/project/src/
CMakeLists.txt is in /home/myname/project/CMakeLists.txt
I installed program using make install.
Till here all things working fine. But now problem is that when I run this program (I run it from terminal giving command wordJumbleGame) It creates score.txt in /home/myname/project/build directory. It is not being created in installation dir bin.
So please help me out, what am I doing wrong. And please also tell me how do I make my program to appear in application->game lists so I can run it from there not from command prompt.
Unless you prefix it with a slash (on unix) or a drive path (Windows), QFile's constructor parameter is a relative path - relative to the current working directory. score.txt is created in the build/ directory because that's probably where you're executing the binary from.
You can't store score.txt in the /usr/bin directory because, typically, you can't write there without root privileges.
What you want to do is get a path to some directory where you can store your score.txt file. To do that, you can use the QDesktopServices class. That will give you directory information on a per-user basis. Here's an example:
#include <QDesktopServices>
// this would go in main(), probably
QCoreApplication::setApplicationName( "word jumble game" );
// now when you want to read/write the scores file:
QString dataPath = QDesktopService::storageLocation( QDesktopService::DataLocation );
QFile scoreFile( dataPath + "score.txt" );
// on my system, this produces: "/home/adam/.local/share/data/word jumble game/score.txt"
// it will produce something similar for Windows and Mac too
You should set your appication name via QCoreApplication::setApplicationName before getting path information to keep the user data directory nice and organised.
As for getting your application in the games list, you'll need to create a menu entry that follows the freedesktop.org spec. I can't help you more with that, but this is a good starting point. Somebody else might have more info for you.
You need to create a .desktop entry file and install it using xdg-desktop-menu install. Here are two resources for you: freedesktop.org menu spec and adding .desktop files using CMake

Resources