linqs / psl-examples

Various examples to showcase the functionality of PSL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A question about simple-acquaintances

Zstwizard opened this issue · comments

Hey,
Great work, thanks for your code!
However, as a beginner and someone unfamiliar with Java, I have encountered some very basic questions, but they have indeed troubled me. I look forward to your answers!
When I was running the code for simple-acquaintances that you provided, it worked fine according to the data you provided. However, I found that if I added a pair of data (such as 0 16) to "knows_targets ", the following error would be reported:
'''
java.lang.RuntimeException: java.lang.RuntimeException: com.fasterxml.jackson.databind.JsonMappingException: Non-standard token 'NaN': enable JsonReadFeature.ALLOW_NON_NUMERIC_NUMBERS to allow
at [Source: (String)"{"options": {"runtime.log.level": "INFO", "runtime.learn": false, "runtime.inference": true, "runtime.inference.output.results": false}, "rules": ["5.000000: Knows(P1, P2) & Knows(P2, P3) & (P1 != P3) -> Knows(P1, P3) ^2"], "predicates": {"KNOWS": {"name": "KNOWS", "arity": 2, "types": ["UniqueStringID", "UniqueStringID"], "observations": [[0, 2, 1.0], [0, 3, 1.0], [0, 4, 1.0], [0, 5, 1.0], [0, 6, 0.0], [0, 8, 1.0], [0, 9, 1.0], [0, 10, 1.0], [0, 11, 1.0], [0, 12, 1.0], [0, 13, 1.0], [0, 14, 1.0"[truncated 17118 chars]; line: 1, column: 7273] (through reference chain: org.linqs.psl.runtime.RuntimeConfig$JSONRuntimeConfig["predicates"]->java.util.LinkedHashMap["KNOWS"]->org.linqs.psl.runtime.RuntimeConfig$JSONPredicate["targets"])
ERROR: Failed to run.
'''
According to my understanding, simply adding a pair of data to calculate the probability should not result in errors. Is there anything I did not understand, or what are the necessary requirements for building a dataset? I am eager to know this information!
Looking forward to your reply very much, thank you!

commented

From the error, it looks like you have malformed data.
This is not a PSL issue (since it never even sees the data), your data is just formatted incorrectly.

It's a bit hard to see in your message (next time, try using three backticks ` instead of quotes to format code),
but you may be missing a comma or closing bracket.
You can use an online JSON parser (like this one) to check your JSON syntax.

Oh! I am honored to receive your reply so quickly! Thank you for your suggestion. I will use three ` to format code in the future.
However, regarding this error, it seems that I did not lose commas or parentheses in JSON, as I only added a line in 'knows_targets.txt', which should not cause an error.
For example, assume that the original data of knows_targets is:
0 15
0 18
0 22
The execution at this point was successful.
However, if I changed it to:
0 15
0 16
0 18
0 22
Then the error occurred.
I am surprised why such a result has occurred. I am now inclined to believe that there may be some issues with the settings of my environment, and I will confirm again. Thank you very much for your previous reply!

commented

Are you separating your numbers with a tab character (these files as tab-separated values (tsv))?

Yes. In fact, to avoid similar input mismatches, I just copied the previous row and only modified the corresponding data

May I ask if data that appears in knows_obs.txt cannot appear in knows_targets.txt?

commented

No, you cannot specify the atom twice.

It would also help me out a lot if you could specify more information.
What interface are you using?
Did you make any other changes?
How are you running the example?
What is the full output?

commented

I also encourage you again to check that you inserted a tab and not spaces in your data file.
(If you are on a unix machine, you can use cat -A to check the exact contents of a file.)

The interface I used is python, I just installed the package: pslpython and executed run.sh to run the example.

I found that it should be my mistake to have the same '0 16' for 'knows_obs. txt' and 'knows_targets. txt'. Therefore, after adding "0 16" to the targets and removing "0 16 1.0" from "knows_targets. txt", the program can execute smoothly again. So the problem should be that I used duplicate data.

After preliminarily solving this problem, I will try to follow this example and use my own data to build a PSL model. I am a beginner, so I'm fortunate to have met a developer like you who is willing to answer my questions. Thank you very much. Have a nice day!

commented

Nice!
I am glad to hear that your problem is resolved.
Good luck!